This class provides the interface for formatting and parsing units.
For all metric units, the 20 SI prefixes used to form decimal multiples and sub-multiples of SI units are recognized.
As well as the 8 Binary prefixes.
For example:
AbstractUnit.parse("m°C").equals(MetricPrefix.MILLI(Units.CELSIUS))
AbstractUnit.parse("kW").equals(MetricPrefix.KILO(Units.WATT))
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public abstract Appendable | Returns: The appendable destination passed in asappendable, with formatted text appended.the unit to format. unit, Appendable the appendable destination. appendable)Redeclares javax. Formats the specified unit. |
| public final String | Returns: Formatted string.the unit)Unit to format, not nullImplements javax. Formats an object to produce a string. |
| private final StringBuilder | Returns: the specifiedStringBuilder.the unit to format. unit, StringBuilder the appendable destination. dest)Convenience method equivalent to |
| public void | label(Unit<?>
the unit being labeled. unit, String the new label for this unit. label)Implements javax. Attaches a system-wide label to the specified |
| public abstract Unit | Returns: the unit parsed from the specified character sub-sequence.the csq, ParsePosition CharSequence to parse.the cursor holding the current parsing index. cursor)Redeclares javax. Parses a portion of the specified |
| protected abstract Unit | Returns: the unit parsed from the specified character sub-sequence.the csq, int CharSequence to parse.the current parsing index. index)Parses a portion of the specified |
| AbstractUnitFormat | back to summary |
|---|---|
| public AbstractUnitFormat() | |
| format | back to summary |
|---|---|
| public abstract Appendable format(Unit<?> unit, Appendable appendable) throws IOException Redeclares javax. Formats the specified unit.
| |
| format | back to summary |
|---|---|
| public final String format(Unit<?> unit) Implements javax. Formats an object to produce a string. This is equivalent to
| |
| format | back to summary |
|---|---|
| private final StringBuilder format(AbstractUnit<?> unit, StringBuilder dest) Convenience method equivalent to
| |
| label | back to summary |
|---|---|
| public void label(Unit<?> unit, String label) Implements javax. Doc from javax. Attaches a system-wide label to the specified
This method overrides the previous unit's label (e.g. label from unit database or unit system) as units may only have one label. Depending on the
UnitFormat implementation is explicitly immutable, similar to e.g. the result of Collections.unmodifiableList(),
then an UnsupportedOperationException may be thrown upon this call.
Since | |
| parse | back to summary |
|---|---|
| public abstract Unit Redeclares javax. Parses a portion of the specified
| |
| parse | back to summary |
|---|---|
| protected abstract Unit Parses a portion of the specified
| |