Class 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-classing DisplayFormatter and by adding properties specific for the DisplayFormatter.

    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 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
    • 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()
      • format

        public java.lang.String format​(T o)
        Specified by:
        format in interface IFormatter<T>