Package org.eclipse.mat.query
Class BytesFormat
java.lang.Object
java.text.Format
org.eclipse.mat.query.BytesFormat
- All Implemented Interfaces:
Serializable,Cloneable
This class formats an instance of
Bytes,
Long, Integer, or Short
based on the currently configured BytesDisplay
preference.- Since:
- 1.5
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class java.text.Format
Format.Field -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe default format string using for decimal byte values. -
Constructor Summary
ConstructorsConstructorDescriptionCreate 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, useencapsulatedDecimalFormatif the value is more than 1KB.BytesFormat(Format encapsulatedNumberFormat, Format encapsulatedDecimalFormat, BytesDisplay bytesDisplay) Create an instance with the behavior that if the display preference isBytesDisplay.Bytes, always useencapsulatedNumberFormat; otherwise, useencapsulatedDecimalFormatif the value is more than 1KB.BytesFormat(BytesDisplay bytesDisplay) Create an instance with default behavior. -
Method Summary
Modifier and TypeMethodDescriptionformat(Object obj, StringBuffer toAppendTo, FieldPosition pos) Ifobjis an instance of Bytes, long, integer or short, then consider the bytes display preference when formatting the value.Gets the current BytesDisplay if anystatic BytesFormatReturn a new instance of a BytesFormat with default options.parseObject(String source, ParsePosition pos) Parses the input string according to the display mode.voidsetBytesDisplay(BytesDisplay bytesDisplay) Sets the current BytesDisplayMethods inherited from class java.text.Format
clone, format, formatToCharacterIterator, parseObject
-
Field Details
-
DETAILED_DECIMAL_FORMAT
The default format string using for decimal byte values.- See Also:
-
-
Constructor Details
-
BytesFormat
public BytesFormat()Create an instance with default behavior. -
BytesFormat
Create an instance with default behavior.- Parameters:
bytesDisplay- the BytesDisplay to use if any- Since:
- 1.17
-
BytesFormat
Create an instance with the behavior that if the display preference isBytesDisplay.Bytes, always useencapsulatedNumberFormat; otherwise, useencapsulatedDecimalFormatif the value is more than 1KB.- Parameters:
encapsulatedNumberFormat- the format for small sizesencapsulatedDecimalFormat- the format for larger sizes
-
BytesFormat
public BytesFormat(Format encapsulatedNumberFormat, Format encapsulatedDecimalFormat, BytesDisplay bytesDisplay) Create an instance with the behavior that if the display preference isBytesDisplay.Bytes, always useencapsulatedNumberFormat; otherwise, useencapsulatedDecimalFormatif the value is more than 1KB.- Parameters:
encapsulatedNumberFormat- the format for small sizesencapsulatedDecimalFormat- the format for larger sizesbytesDisplay- the BytesDisplay to use if any- Since:
- 1.17
-
-
Method Details
-
getBytesDisplay
Gets the current BytesDisplay if any- Returns:
- the BytesDisplay
- Since:
- 1.17
-
setBytesDisplay
Sets the current BytesDisplay- Parameters:
bytesDisplay- the BytesDisplay to set- Since:
- 1.17
-
format
Ifobjis an instance of Bytes, long, integer or short, then consider the bytes display preference when formatting the value. Otherwise, formatobjusing the default formatter. -
parseObject
Parses the input string according to the display mode. Returns aBytesobject- Specified by:
parseObjectin classFormat
-
getInstance
Return a new instance of a BytesFormat with default options.- Returns:
- a default BytesFormat
-