protected static class SimpleUnitFormat.DefaultFormat extends SimpleUnitFormat
SimpleUnitFormat.ASCIIFormat, SimpleUnitFormat.DefaultFormat, SimpleUnitFormat.Flavor| Modifier and Type | Field and Description |
|---|---|
(package private) java.util.HashMap<java.lang.String,javax.measure.Unit<?>> |
_nameToUnit
Holds the name to unit mapping.
|
(package private) java.util.HashMap<javax.measure.Unit<?>,java.lang.String> |
_unitToName
Holds the unit to name mapping.
|
private static int |
CLOSE_PAREN |
private static int |
DIVIDE |
private static int |
EOF |
private static int |
EXPONENT |
private static int |
FLOAT |
private static int |
IDENTIFIER |
private static int |
INTEGER |
private static int |
MULTIPLY |
private static int |
OPEN_PAREN |
private static int |
PLUS |
| Modifier | Constructor and Description |
|---|---|
protected |
DefaultFormat() |
| Modifier and Type | Method and Description |
|---|---|
void |
alias(javax.measure.Unit<?> unit,
java.lang.String alias)
Attaches a system-wide alias to this unit.
|
private void |
append(java.lang.Appendable appendable,
java.lang.CharSequence symbol,
int pow,
int root) |
private void |
check(boolean expr,
java.lang.String message,
java.lang.CharSequence csq,
int index) |
java.lang.Appendable |
format(javax.measure.Unit<?> unit,
java.lang.Appendable appendable)
Formats the specified unit.
|
protected SymbolMap |
getSymbols()
Returns the
SymbolMap for this unit format. |
(package private) static boolean |
isUnitIdentifierPart(char ch) |
boolean |
isValidIdentifier(java.lang.String name)
Indicates if the specified name can be used as unit identifier.
|
void |
label(javax.measure.Unit<?> unit,
java.lang.String label)
Attaches a system-wide label to the specified unit.
|
java.lang.String |
nameFor(javax.measure.Unit<?> unit) |
private int |
nextToken(java.lang.CharSequence csq,
java.text.ParsePosition pos) |
javax.measure.Unit<?> |
parse(java.lang.CharSequence csq) |
protected javax.measure.Unit<?> |
parse(java.lang.CharSequence csq,
int index)
Parses a portion of the specified
CharSequence from the specified position to produce a unit. |
protected javax.measure.Unit<?> |
parse(java.lang.CharSequence csq,
java.text.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(java.lang.CharSequence csq,
java.text.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(java.lang.CharSequence csq,
java.text.ParsePosition pos)
Parses a sequence of character to produce a single unit.
|
private double |
readDouble(java.lang.CharSequence csq,
java.text.ParsePosition pos) |
private SimpleUnitFormat.Exponent |
readExponent(java.lang.CharSequence csq,
java.text.ParsePosition pos) |
private java.lang.String |
readIdentifier(java.lang.CharSequence csq,
java.text.ParsePosition pos) |
private long |
readLong(java.lang.CharSequence csq,
java.text.ParsePosition pos) |
javax.measure.Unit<?> |
unitFor(java.lang.String name) |
format, getInstance, getInstance, isAllASCII, isLocaleSensitive, parseObjectformat, formatfinal java.util.HashMap<java.lang.String,javax.measure.Unit<?>> _nameToUnit
final java.util.HashMap<javax.measure.Unit<?>,java.lang.String> _unitToName
private static final int EOF
private static final int IDENTIFIER
private static final int OPEN_PAREN
private static final int CLOSE_PAREN
private static final int EXPONENT
private static final int MULTIPLY
private static final int DIVIDE
private static final int PLUS
private static final int INTEGER
private static final int FLOAT
public void label(javax.measure.Unit<?> unit,
java.lang.String label)
SimpleUnitFormatlabel in interface javax.measure.format.UnitFormatlabel in class SimpleUnitFormatunit - the unit being labelled.label - the new label for this unit.public void alias(javax.measure.Unit<?> unit,
java.lang.String alias)
SimpleUnitFormatalias in class SimpleUnitFormatunit - the unit being aliased.alias - the alias attached to this unit.public boolean isValidIdentifier(java.lang.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.static boolean isUnitIdentifierPart(char ch)
public java.lang.String nameFor(javax.measure.Unit<?> unit)
public javax.measure.Unit<?> unitFor(java.lang.String name)
public javax.measure.Unit<? extends javax.measure.Quantity> parseSingleUnit(java.lang.CharSequence csq,
java.text.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(java.lang.CharSequence csq,
java.text.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.ParserExceptionprivate int nextToken(java.lang.CharSequence csq,
java.text.ParsePosition pos)
private void check(boolean expr,
java.lang.String message,
java.lang.CharSequence csq,
int index)
throws javax.measure.format.ParserException
javax.measure.format.ParserExceptionprivate SimpleUnitFormat.Exponent readExponent(java.lang.CharSequence csq, java.text.ParsePosition pos)
private long readLong(java.lang.CharSequence csq,
java.text.ParsePosition pos)
private double readDouble(java.lang.CharSequence csq,
java.text.ParsePosition pos)
private java.lang.String readIdentifier(java.lang.CharSequence csq,
java.text.ParsePosition pos)
public java.lang.Appendable format(javax.measure.Unit<?> unit,
java.lang.Appendable appendable)
throws java.io.IOException
SimpleUnitFormatformat in interface javax.measure.format.UnitFormatformat in class SimpleUnitFormatunit - the unit to format.appendable - the appendable destination.appendable, with formatted text appended.java.io.IOException - if an error occurs.private void append(java.lang.Appendable appendable,
java.lang.CharSequence symbol,
int pow,
int root)
throws java.io.IOException
java.io.IOExceptionpublic javax.measure.Unit<?> parse(java.lang.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(java.lang.CharSequence csq,
int index)
throws java.lang.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.java.lang.IllegalArgumentException - if any problem occurs while parsing the specified character sequence (e.g. illegal syntax).protected javax.measure.Unit<?> parse(java.lang.CharSequence csq,
java.text.ParsePosition cursor)
throws java.lang.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.java.lang.IllegalArgumentException - if any problem occurs while parsing the specified character sequence (e.g. illegal syntax).