|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.text.Format
javax.measure.unit.UnitFormat
public abstract class UnitFormat
This class provides the interface for formatting and parsing units.
For all SI units, the 20 SI prefixes used to form decimal
multiples and sub-multiples of SI units are recognized.
NonSI units are directly recognized. For example:
Unit.valueOf("m°C").equals(SI.MILLI(SI.CELSIUS))
Unit.valueOf("kW").equals(SI.KILO(SI.WATT))
Unit.valueOf("ft").equals(SI.METRE.multiply(3048).divide(10000))
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class java.text.Format |
|---|
java.text.Format.Field |
| Constructor Summary | |
|---|---|
protected |
UnitFormat()
Base constructor. |
| Method Summary | |
|---|---|
java.lang.StringBuffer |
format(java.lang.Object obj,
java.lang.StringBuffer toAppendTo,
java.text.FieldPosition pos)
|
abstract java.lang.Appendable |
format(Unit<?> unit,
java.lang.Appendable appendable)
Formats the specified unit. |
java.lang.StringBuilder |
format(Unit<?> unit,
java.lang.StringBuilder dest)
Convenience method equivalent to format(Unit, Appendable)
except it does not raise an IOException. |
static UnitFormat |
getInstance()
Returns the unit format for the default locale. |
static UnitFormat |
getInstance(java.util.Locale locale)
Returns the unit format for the specified locale. |
static UnitFormat |
getStandard()
Returns the standard UCUM unit format. |
abstract 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. |
Unit<?> |
parseObject(java.lang.String source,
java.text.ParsePosition pos)
|
| Methods inherited from class java.text.Format |
|---|
clone, format, formatToCharacterIterator, parseObject |
| Methods inherited from class java.lang.Object |
|---|
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
protected UnitFormat()
| Method Detail |
|---|
public static UnitFormat getInstance()
LocalFormat.getInstance()public static UnitFormat getInstance(java.util.Locale locale)
locale - the locale for which the format is returned.
LocalFormat.getInstance(java.util.Locale)public static UnitFormat getStandard()
Unit.valueOf(CharSequence) and Unit.toString()).
This format uses characters range 0000-007F exclusively
and is not locale-sensitive. For example: kg.m/s2
For a description of the UCUM format including BNF, see: The Unified Code for Units of Measure
UCUMFormat.getCaseSensitiveInstance()
public abstract java.lang.Appendable format(Unit<?> unit,
java.lang.Appendable appendable)
throws java.io.IOException
unit - the unit to format.appendable - the appendable destination.
java.io.IOException - if an error occurs.
public abstract Unit<?> parse(java.lang.CharSequence csq,
java.text.ParsePosition cursor)
throws java.lang.IllegalArgumentException
CharSequence from the
specified position to produce a unit. If there is no unit to parse
Unit.ONE is returned.
csq - 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).
public final java.lang.StringBuffer format(java.lang.Object obj,
java.lang.StringBuffer toAppendTo,
java.text.FieldPosition pos)
format in class java.text.Format
public final Unit<?> parseObject(java.lang.String source,
java.text.ParsePosition pos)
parseObject in class java.text.Format
public final java.lang.StringBuilder format(Unit<?> unit,
java.lang.StringBuilder dest)
format(Unit, Appendable)
except it does not raise an IOException.
unit - the unit to format.dest - the appendable destination.
StringBuilder.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||