protected static class SimpleUnitFormat.DefaultFormat extends SimpleUnitFormat
SimpleUnitFormat.ASCIIFormat, SimpleUnitFormat.DefaultFormat, SimpleUnitFormat.Flavor
logger
Modifier | Constructor and Description |
---|---|
protected |
SimpleUnitFormat.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.
|
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.
|
protected 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. |
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.
|
protected String |
prefixFor(javax.measure.UnitConverter converter) |
protected javax.measure.Unit<?> |
unitFor(String name) |
format, getInstance, getInstance, isAllASCII, isLocaleSensitive, parseObject
format
protected SimpleUnitFormat.DefaultFormat()
public void label(javax.measure.Unit<?> unit, String label)
SimpleUnitFormat
SimpleUnitFormat.getInstance().label(DAY.multiply(365), "year");
SimpleUnitFormat.getInstance().label(METER.multiply(0.3048), "ft");
If the specified label is already associated to an unit the previous
association is discarded or ignored.label
in interface javax.measure.format.UnitFormat
label
in class SimpleUnitFormat
unit
- the unit being labeled.label
- the new label for this unit.public void alias(javax.measure.Unit<?> unit, String alias)
SimpleUnitFormat
SimpleUnitFormat.getInstance().alias(METER.multiply(0.3048), "foot");
SimpleUnitFormat.getInstance().alias(METER.multiply(0.3048), "feet"); SimpleUnitFormat.getInstance().alias(METER, "meter");
SimpleUnitFormat.getInstance().alias(METER, "metre");
If the specified label is already associated to an unit the previous association is
discarded or ignored.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 javax.measure.Unit<?> parse(CharSequence csq, int index) throws javax.measure.format.ParserException
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.javax.measure.format.ParserException
Copyright © 2005–2017 Jean-Marie Dautelle, Werner Keil, V2COM. All rights reserved.