Package org.openjdk.jmc.common.unit
Class DisplayFormatter<T>
- java.lang.Object
-
- org.openjdk.jmc.common.unit.DisplayFormatter<T>
-
- Type Parameters:
T
- the type of values that can be formatted
- All Implemented Interfaces:
IFormatter<T>
- Direct Known Subclasses:
KindOfQuantity.ExactFormatter
,KindOfQuantity.VerboseFormatter
,LinearKindOfQuantity.AutoFormatter
,LinearKindOfQuantity.DualUnitFormatter
public class DisplayFormatter<T> extends Object implements IFormatter<T>
A display formatter is basically an identifier that tells a user interface widget how the unit should be formatted, e.g. as a kilobytes. Currently the display unit doesn't contain any information about what makes the unit, for instance 1 kilobyte is 1024 times as much as a byte or the precision. This could be added on later by sub-classingDisplayFormatter
and by adding properties specific for theDisplayFormatter
.A display formatter with the magic identifier "auto" should be used to tells the user interface widget that it can decide by itself how the unit should be formatted. E.g, if it is a large number it may decide show it as GiB, but if it is a low number it may choose bytes.
-
-
Field Summary
Fields Modifier and Type Field Description static String
ENGINEERING_NOTATION_IDENTIFIER
static String
SCIENTIFIC_NOTATION_IDENTIFIER
-
Constructor Summary
Constructors Modifier Constructor Description protected
DisplayFormatter(ContentType<T> contentType, String identifier, String name)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description String
format(T o)
ContentType<T>
getContentType()
String
getIdentifier()
String
getName()
-
-
-
Field Detail
-
ENGINEERING_NOTATION_IDENTIFIER
public static final String ENGINEERING_NOTATION_IDENTIFIER
- See Also:
- Constant Field Values
-
SCIENTIFIC_NOTATION_IDENTIFIER
public static final String SCIENTIFIC_NOTATION_IDENTIFIER
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
DisplayFormatter
protected DisplayFormatter(ContentType<T> contentType, String identifier, String name)
-
-
Method Detail
-
getName
public String getName()
-
getIdentifier
public String getIdentifier()
-
getContentType
public ContentType<T> getContentType()
-
format
public String format(T o)
- Specified by:
format
in interfaceIFormatter<T>
-
-