javax.measure.unit
protected static class UnitFormat.DefaultFormat extends UnitFormat
UnitFormat.ASCIIFormat, UnitFormat.DefaultFormat
Modifier | Constructor and Description |
---|---|
protected |
UnitFormat.DefaultFormat() |
Modifier and Type | Method and Description |
---|---|
void |
alias(Unit<?> unit,
java.lang.String alias)
Attaches a system-wide alias to this unit.
|
java.lang.Appendable |
format(Unit<?> unit,
java.lang.Appendable appendable)
Formats the specified unit.
|
boolean |
isValidIdentifier(java.lang.String name)
Indicates if the specified name can be used as unit identifier.
|
void |
label(Unit<?> unit,
java.lang.String label)
Attaches a system-wide label to the specified unit.
|
java.lang.String |
nameFor(Unit<?> unit) |
Unit<? extends Quantity> |
parseProductUnit(java.lang.CharSequence csq,
java.text.ParsePosition pos)
Parses a sequence of character to produce a unit or a rational product of unit.
|
Unit<? extends Quantity> |
parseSingleUnit(java.lang.CharSequence csq,
java.text.ParsePosition pos)
Parses a sequence of character to produce a single unit.
|
Unit<?> |
unitFor(java.lang.String name) |
format, getInstance, getInstance, getUCUMInstance, parseObject
public void label(Unit<?> unit, java.lang.String label)
UnitFormat
label
in class UnitFormat
unit
- the unit being labelled.label
- the new label for this unit.public void alias(Unit<?> unit, java.lang.String alias)
UnitFormat
alias
in class UnitFormat
unit
- the unit being aliased.alias
- the alias attached to this unit.public boolean isValidIdentifier(java.lang.String name)
UnitFormat
isValidIdentifier
in class UnitFormat
name
- the identifier to be tested.true
if the name specified can be used as label or alias for this format;false
otherwise.public java.lang.String nameFor(Unit<?> unit)
public Unit<?> unitFor(java.lang.String name)
public Unit<? extends Quantity> parseSingleUnit(java.lang.CharSequence csq, java.text.ParsePosition pos) throws java.text.ParseException
UnitFormat
parseSingleUnit
in class UnitFormat
csq
- the CharSequence
to parse.pos
- an object holding the parsing index and error position.Unit
parsed from the character sequence.java.text.ParseException
public Unit<? extends Quantity> parseProductUnit(java.lang.CharSequence csq, java.text.ParsePosition pos) throws java.text.ParseException
UnitFormat
parseProductUnit
in class UnitFormat
csq
- the CharSequence
to parse.pos
- an object holding the parsing index and error position.Unit
parsed from the character sequence.java.text.ParseException
public java.lang.Appendable format(Unit<?> unit, java.lang.Appendable appendable) throws java.io.IOException
UnitFormat
format
in class UnitFormat
unit
- the unit to format.appendable
- the appendable destination.java.io.IOException
- if an error occurs.