public abstract class AbstractUnitFormat extends Object implements javax.measure.format.UnitFormat
This class provides the interface for formatting and parsing units.
For all metric units, the 20 SI prefixes used to form decimal multiples and sub-multiples of SI units are recognized. For example:
AbstractUnit.parse("m°C").equals(MetricPrefix.MILLI(Units.CELSIUS))
AbstractUnit.parse("kW").equals(MetricPrefix.KILO(Units.WATT))
| Modifier and Type | Field and Description |
|---|---|
protected static Logger |
logger
serialVersionUID
|
| Constructor and Description |
|---|
AbstractUnitFormat() |
| Modifier and Type | Method and Description |
|---|---|
String |
format(javax.measure.Unit<?> unit)
Formats an object to produce a string.
|
abstract Appendable |
format(javax.measure.Unit<?> unit,
Appendable appendable)
Formats the specified unit.
|
boolean |
isLocaleSensitive() |
protected abstract javax.measure.Unit<?> |
parse(CharSequence csq,
int index)
Parses a portion of the specified
CharSequence from the specified position to produce a unit. |
public AbstractUnitFormat()
public final String format(javax.measure.Unit<?> unit)
format(unit, new StringBuilder()).toString();
format in interface javax.measure.format.UnitFormatobj - The object to formatIllegalArgumentException - if the Format cannot format the given objectpublic abstract Appendable format(javax.measure.Unit<?> unit, Appendable appendable) throws IOException
format in interface javax.measure.format.UnitFormatunit - the unit to format.appendable - the appendable destination.appendable, with formatted text appended.IOException - if an error occurs.protected abstract javax.measure.Unit<?> parse(CharSequence csq, int index) throws IllegalArgumentException
CharSequence from the specified position to produce a unit. If there is no unit to parse
AbstractUnit.ONE is returned.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).public boolean isLocaleSensitive()
isLocaleSensitive in interface javax.measure.format.UnitFormatCopyright © 2005–2016 Jean-Marie Dautelle, Werner Keil, V2COM. All rights reserved.