protected static class SimpleUnitFormat.DefaultFormat extends SimpleUnitFormat
SimpleUnitFormat.ASCIIFormat, SimpleUnitFormat.DefaultFormat, SimpleUnitFormat.Flavor
Modifier | Constructor and Description |
---|---|
protected |
DefaultFormat() |
Modifier and Type | Method and Description |
---|---|
void |
alias(javax.measure.Unit<?> unit,
String alias)
Attaches a system-wide alias to this unit.
|
Appendable |
format(javax.measure.Unit<?> unit,
Appendable appendable)
Formats the specified unit.
|
protected SymbolMap |
getSymbols()
Returns the
SymbolMap for this unit format. |
boolean |
isValidIdentifier(String name)
Indicates if the specified name can be used as unit identifier.
|
void |
label(javax.measure.Unit<?> unit,
String label)
Attaches a system-wide label to the specified unit.
|
String |
nameFor(javax.measure.Unit<?> unit) |
javax.measure.Unit<?> |
parse(CharSequence csq) |
protected javax.measure.Unit<?> |
parse(CharSequence csq,
int index)
Parses a portion of the specified
CharSequence from the specified position to produce a unit. |
protected javax.measure.Unit<?> |
parse(CharSequence csq,
ParsePosition cursor)
Parses a portion of the specified
CharSequence from the specified position to produce a unit. |
javax.measure.Unit<? extends javax.measure.Quantity> |
parseProductUnit(CharSequence csq,
ParsePosition pos)
Parses a sequence of character to produce a unit or a rational product of unit.
|
javax.measure.Unit<? extends javax.measure.Quantity> |
parseSingleUnit(CharSequence csq,
ParsePosition pos)
Parses a sequence of character to produce a single unit.
|
javax.measure.Unit<?> |
unitFor(String name) |
format, getInstance, getInstance, isAllASCII, isLocaleSensitive, parseObject
format
protected DefaultFormat()
public void label(javax.measure.Unit<?> unit, String label)
SimpleUnitFormat
label
in interface javax.measure.format.UnitFormat
label
in class SimpleUnitFormat
unit
- the unit being labelled.label
- the new label for this unit.public void alias(javax.measure.Unit<?> unit, String alias)
SimpleUnitFormat
alias
in class SimpleUnitFormat
unit
- the unit being aliased.alias
- the alias attached to this unit.public boolean isValidIdentifier(String name)
SimpleUnitFormat
isValidIdentifier
in class SimpleUnitFormat
name
- the identifier to be tested.true
if the name specified can be used as label or alias for this format;false
otherwise.public javax.measure.Unit<? extends javax.measure.Quantity> parseSingleUnit(CharSequence csq, ParsePosition pos) throws javax.measure.format.ParserException
SimpleUnitFormat
parseSingleUnit
in class SimpleUnitFormat
csq
- the CharSequence
to parse.pos
- an object holding the parsing index and error position.Unit
parsed from the character sequence.javax.measure.format.ParserException
public javax.measure.Unit<? extends javax.measure.Quantity> parseProductUnit(CharSequence csq, ParsePosition pos) throws javax.measure.format.ParserException
SimpleUnitFormat
parseProductUnit
in class SimpleUnitFormat
csq
- the CharSequence
to parse.pos
- an object holding the parsing index and error position.Unit
parsed from the character sequence.javax.measure.format.ParserException
public Appendable format(javax.measure.Unit<?> unit, Appendable appendable) throws IOException
SimpleUnitFormat
format
in interface javax.measure.format.UnitFormat
format
in class SimpleUnitFormat
unit
- the unit to format.appendable
- the appendable destination.appendable
, with formatted text appended.IOException
- if an error occurs.public javax.measure.Unit<?> parse(CharSequence csq) throws javax.measure.format.ParserException
javax.measure.format.ParserException
protected SymbolMap getSymbols()
AbstractUnitFormat
SymbolMap
for this unit format.getSymbols
in class AbstractUnitFormat
protected javax.measure.Unit<?> parse(CharSequence csq, int index) throws IllegalArgumentException
AbstractUnitFormat
CharSequence
from the specified position to produce a unit. If there is no unit to parse
AbstractUnit.ONE
is returned.parse
in class AbstractUnitFormat
csq
- the CharSequence
to parse.index
- the current parsing index.IllegalArgumentException
- if any problem occurs while parsing the specified character sequence (e.g. illegal syntax).protected javax.measure.Unit<?> parse(CharSequence csq, ParsePosition cursor) throws IllegalArgumentException
AbstractUnitFormat
CharSequence
from the specified position to produce a unit. If there is no unit to parse
AbstractUnit.ONE
is returned.parse
in class AbstractUnitFormat
csq
- the CharSequence
to parse.cursor
- the cursor holding the current parsing index.IllegalArgumentException
- if any problem occurs while parsing the specified character sequence (e.g. illegal syntax).Copyright © 2005-2019 Units of Measurement project. All Rights Reserved.