Package org.eclipse.mat.query
Class BytesFormat
- java.lang.Object
-
- java.text.Format
-
- org.eclipse.mat.query.BytesFormat
-
- All Implemented Interfaces:
Serializable
,Cloneable
public class BytesFormat extends Format
This class formats an instance ofBytes
,Long
,Integer
, orShort
based on the currently configuredBytesDisplay
preference.- Since:
- 1.5
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class java.text.Format
Format.Field
-
-
Field Summary
Fields Modifier and Type Field Description static String
DETAILED_DECIMAL_FORMAT
The default format string using for decimal byte values.
-
Constructor Summary
Constructors Constructor Description BytesFormat()
Create an instance with default behavior.BytesFormat(Format encapsulatedNumberFormat, Format encapsulatedDecimalFormat)
Create an instance with the behavior that if the display preference isBytesDisplay.Bytes
, always useencapsulatedNumberFormat
; otherwise, useencapsulatedDecimalFormat
if the value is more than 1KB.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description StringBuffer
format(Object obj, StringBuffer toAppendTo, FieldPosition pos)
Ifobj
is an instance of Bytes, long, integer or short, then consider the bytes display preference when formatting the value.static BytesFormat
getInstance()
Return a new instance of a BytesFormat with default options.Object
parseObject(String source, ParsePosition pos)
Parses the input string according to the display mode.-
Methods inherited from class java.text.Format
clone, format, formatToCharacterIterator, parseObject
-
-
-
-
Field Detail
-
DETAILED_DECIMAL_FORMAT
public static final String DETAILED_DECIMAL_FORMAT
The default format string using for decimal byte values.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
BytesFormat
public BytesFormat()
Create an instance with default behavior.
-
BytesFormat
public BytesFormat(Format encapsulatedNumberFormat, Format encapsulatedDecimalFormat)
Create an instance with the behavior that if the display preference isBytesDisplay.Bytes
, always useencapsulatedNumberFormat
; otherwise, useencapsulatedDecimalFormat
if the value is more than 1KB.- Parameters:
encapsulatedNumberFormat
- the format for small sizesencapsulatedDecimalFormat
- the format for larger sizes
-
-
Method Detail
-
format
public StringBuffer format(Object obj, StringBuffer toAppendTo, FieldPosition pos)
Ifobj
is an instance of Bytes, long, integer or short, then consider the bytes display preference when formatting the value. Otherwise, formatobj
using the default formatter.
-
parseObject
public Object parseObject(String source, ParsePosition pos)
Parses the input string according to the display mode. Returns aBytes
object- Specified by:
parseObject
in classFormat
-
getInstance
public static BytesFormat getInstance()
Return a new instance of a BytesFormat with default options.- Returns:
- a default BytesFormat
-
-