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.
|
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. |
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.
|
protected String |
prefixFor(javax.measure.UnitConverter converter) |
protected javax.measure.Unit<?> |
unitFor(String name) |
format, getInstance, getInstance, isAllASCII, isLocaleSensitive, parseObjectformatprotected 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.UnitFormatlabel in class SimpleUnitFormatunit - 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 SimpleUnitFormatunit - the unit being aliased.alias - the alias attached to this unit.public boolean isValidIdentifier(String name)
SimpleUnitFormatisValidIdentifier in class SimpleUnitFormatname - 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
SimpleUnitFormatparseSingleUnit in class SimpleUnitFormatcsq - the CharSequence to parse.pos - an object holding the parsing index and error position.Unit parsed from the character sequence.javax.measure.format.ParserExceptionpublic javax.measure.Unit<? extends javax.measure.Quantity> parseProductUnit(CharSequence csq, ParsePosition pos) throws javax.measure.format.ParserException
SimpleUnitFormatparseProductUnit in class SimpleUnitFormatcsq - the CharSequence to parse.pos - an object holding the parsing index and error position.Unit parsed from the character sequence.javax.measure.format.ParserExceptionpublic Appendable format(javax.measure.Unit<?> unit, Appendable appendable) throws IOException
SimpleUnitFormatformat in interface javax.measure.format.UnitFormatformat in class SimpleUnitFormatunit - 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.ParserExceptionprotected SymbolMap getSymbols()
AbstractUnitFormatSymbolMap for this unit format.getSymbols in class AbstractUnitFormatprotected javax.measure.Unit<?> parse(CharSequence csq, int index) throws IllegalArgumentException
AbstractUnitFormatCharSequence from the specified position to produce a unit. If there is no unit to parse
AbstractUnit.ONE is returned.parse in class AbstractUnitFormatcsq - 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
AbstractUnitFormatCharSequence from the specified position to produce a unit. If there is no unit to parse
AbstractUnit.ONE is returned.parse in class AbstractUnitFormatcsq - 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–2017 Units of Measurement project. All rights reserved.