SimpleUnitFormat.ASCIIFormatprotected static class SimpleUnitFormat.DefaultFormat extends SimpleUnitFormat
SimpleUnitFormat.ASCIIFormat, SimpleUnitFormat.DefaultFormat, SimpleUnitFormat.Flavor| Modifier and Type | Field | Description |
|---|---|---|
protected HashMap<String,javax.measure.Unit<?>> |
nameToUnit |
Holds the name to unit mapping.
|
protected HashMap<javax.measure.Unit<?>,String> |
unitToName |
Holds the unit to name mapping.
|
| Modifier | Constructor | Description |
|---|---|---|
protected |
DefaultFormat() |
| Modifier and Type | Method | 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. |
protected static boolean |
isUnitIdentifierPart(char ch) |
|
protected 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<?> |
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) |
|
String |
toString() |
|
protected javax.measure.Unit<?> |
unitFor(String name) |
formatclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitformat, getInstance, getInstance, isAllASCII, parseObjectprotected final HashMap<String,javax.measure.Unit<?>> nameToUnit
protected final HashMap<javax.measure.Unit<?>,String> unitToName
protected 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 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.protected 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.protected static boolean isUnitIdentifierPart(char ch)
public javax.measure.Unit<? extends javax.measure.Quantity> parseSingleUnit(CharSequence csq, ParsePosition pos) throws javax.measure.format.MeasurementParseException
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.MeasurementParseExceptionpublic javax.measure.Unit<? extends javax.measure.Quantity> parseProductUnit(CharSequence csq, ParsePosition pos) throws javax.measure.format.MeasurementParseException
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.MeasurementParseExceptionpublic Appendable format(javax.measure.Unit<?> unit, Appendable appendable) throws IOException
SimpleUnitFormatformat 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.MeasurementParseException
javax.measure.format.MeasurementParseExceptionprotected 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).public 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–2020 Units of Measurement project. All rights reserved.