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 java.lang.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 java.lang.String
ENGINEERING_NOTATION_IDENTIFIER
private ContentType<T>
m_contentType
private java.lang.String
m_identifier
private java.lang.String
m_name
static java.lang.String
SCIENTIFIC_NOTATION_IDENTIFIER
-
Constructor Summary
Constructors Modifier Constructor Description protected
DisplayFormatter(ContentType<T> contentType, java.lang.String identifier, java.lang.String name)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.String
format(T o)
ContentType<T>
getContentType()
java.lang.String
getIdentifier()
java.lang.String
getName()
-
-
-
Field Detail
-
ENGINEERING_NOTATION_IDENTIFIER
public static final java.lang.String ENGINEERING_NOTATION_IDENTIFIER
- See Also:
- Constant Field Values
-
SCIENTIFIC_NOTATION_IDENTIFIER
public static final java.lang.String SCIENTIFIC_NOTATION_IDENTIFIER
- See Also:
- Constant Field Values
-
m_name
private final java.lang.String m_name
-
m_identifier
private final java.lang.String m_identifier
-
m_contentType
private final ContentType<T> m_contentType
-
-
Constructor Detail
-
DisplayFormatter
protected DisplayFormatter(ContentType<T> contentType, java.lang.String identifier, java.lang.String name)
-
-
Method Detail
-
getName
public java.lang.String getName()
-
getIdentifier
public java.lang.String getIdentifier()
-
getContentType
public ContentType<T> getContentType()
-
format
public java.lang.String format(T o)
- Specified by:
format
in interfaceIFormatter<T>
-
-