public class SimpleUnitFormat extends Object
This class provides a simple interface for formatting and parsing units.
| Modifier and Type | Method and Description |
|---|---|
StringBuffer |
format(Object obj,
StringBuffer toAppendTo) |
String |
format(javax.measure.Unit<?> unit)
Formats an object to produce a string.
|
Appendable |
format(javax.measure.Unit<?> unit,
Appendable appendable)
Formats the specified unit.
|
static javax.measure.format.UnitFormat |
getInstance()
Returns the default instance for formatting
|
boolean |
isLocaleSensitive() |
void |
label(javax.measure.Unit<?> unit,
String label) |
javax.measure.Unit<?> |
parse(CharSequence csq)
Parses the specified character sequence to produce a unit (convenience
method).
|
protected javax.measure.Unit<?> |
parse(CharSequence csq,
int index) |
javax.measure.Unit<?> |
parse(CharSequence csq,
ParsePosition pos)
Parses the specified character sequence to produce a unit (convenience method).
|
javax.measure.Unit<?> |
parseObject(String source) |
public static javax.measure.format.UnitFormat getInstance()
public 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.public boolean isLocaleSensitive()
protected javax.measure.Unit<?> parse(CharSequence csq, int index) throws javax.measure.format.MeasurementParseException
javax.measure.format.MeasurementParseExceptionpublic final javax.measure.Unit<?> parse(CharSequence csq, ParsePosition pos) throws javax.measure.format.MeasurementParseException
csq - the CharSequence to parse.javax.measure.format.MeasurementParseException - if any problem occurs while parsing the specified character sequence (e.g. illegal syntax).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 final javax.measure.Unit<?> parse(CharSequence csq) throws IllegalArgumentException
parse in interface javax.measure.format.UnitFormatcsq - the CharSequence to parse.IllegalArgumentException - if any problem occurs while parsing the specified character
sequence (e.g. illegal syntax).public final StringBuffer format(Object obj, StringBuffer toAppendTo)
public final javax.measure.Unit<?> parseObject(String source)
Copyright © 2005–2024 Units of Measurement project. All rights reserved.