This class implements the UnitFormat interface for formatting and parsing units.
For all SI units, the 24 SI prefixes used to form decimal multiples and sub-multiples are recognized. As well as the 8 binary prefixes.
Units are directly recognized. For example:
UnitFormat format = SimpleUnitFormat.getInstance();
format.parse("m°C").equals(MetricPrefix.MILLI(Units.CELSIUS));
format.parse("kW").equals(MetricPrefix.KILO(Units.WATT));
format.parse("ft").equals(Units.METRE.multiply(0.3048))
| Modifier and Type | Class and Description |
|---|---|
| private static class | SimpleUnitFormat.
This class represents the ASCII_INSTANCE format. |
| pack-priv static class | SimpleUnitFormat.
This class represents the default (Unicode) format. |
| private static class | SimpleUnitFormat.
This class represents an exponent with both a power (numerator) and a root (denominator). |
| public static enum | SimpleUnitFormat.
Flavor of this format |
| Modifier and Type | Field and Description |
|---|---|
| private static final SimpleUnitFormat. | ASCII_INSTANCE
Holds the ASCII_INSTANCE format instance. |
| private static final SimpleUnitFormat. | DEFAULT_INSTANCE
Holds the default format instance. |
| private static final String |
| Access | Constructor and Description |
|---|---|
| protected |
| Modifier and Type | Method and Description |
|---|---|
| public abstract void | |
| public abstract Appendable | format(Unit<?>
the unit to format. unit, Appendable the appendable destination. appendable)Redeclares javax. Implements abstract tech. Formats the specified unit. |
| public final StringBuffer | Returns: toAppendTothe unit to format. unit, final StringBuffer where the text is to be appended toAppendTo, FieldPosition the field position (not used). pos)Formats an unit and appends the resulting text to a given string buffer (implements |
| public static SimpleUnitFormat | Returns: the default unit format.Returns the globally shared unit format instance (used by |
| public static SimpleUnitFormat | Returns: the instance for the givenFlavor.Returns the |
| public static SimpleUnitFormat | Returns: a new instance of the default unit format.Similar to |
| public static SimpleUnitFormat | Returns: a new instance for the givenFlavor.Similar to |
| protected abstract boolean | Returns: true if the name specified can be used as label or alias for this format;false otherwise.the identifier to be tested. name)Indicates if the specified name can be used as unit identifier. |
| public abstract void | label(Unit<?>
the unit being labeled. unit, String the new label for this unit. label)Redeclares javax. Overrides tech. Attaches a system-wide label to the specified unit. |
| public final Unit | Returns: the corresponding unit ornull if the string cannot be parsed.the string source, part of which should be parsed. source, ParsePosition the cursor position. pos)Parses the text from a string to produce an object (implements |
| public abstract Unit | Returns: anUnit parsed from the character sequence.the csq, ParsePosition CharSequence to parse.an object holding the parsing index and error position. pos)Parses a sequence of character to produce a unit or a rational product of unit. |
| public abstract Unit | Returns: anUnit parsed from the character sequence.the csq, ParsePosition CharSequence to parse.an object holding the parsing index and error position. pos)Parses a sequence of character to produce a single unit. |
| public abstract void | removeAlias(Unit<?>
the unit for which alias shall be removed. unit, String the alias to be removed. alias)Removes the given system-wide alias (added by |
| public abstract void | removeAliases(Unit<?>
the unit for which aliases shall be removed. unit)Removes all system-wide aliases (added by |
| public abstract void | removeLabel(Unit<?>
the unit for which label shall be removed. unit)Removes the system-wide label (added by |