Serializable
, Cloneable
public class NumberDelimiterQuantityFormat extends AbstractQuantityFormat
Modifier and Type | Class | Description |
---|---|---|
static class |
NumberDelimiterQuantityFormat.Builder |
A fluent Builder to easily create new instances of
NumberDelimiterQuantityFormat . |
Format.Field
DEFAULT_DELIMITER
Modifier and Type | Method | Description |
---|---|---|
static NumberDelimiterQuantityFormat.Builder |
builder() |
Returns a new instance of
NumberDelimiterQuantityFormat.Builder . |
Appendable |
format(javax.measure.Quantity<?> quantity,
Appendable dest) |
Formats the specified quantity into an
Appendable . |
protected StringBuffer |
formatCompound(CompoundQuantity<?> comp,
StringBuffer dest) |
Convenience method equivalent to
#format(CompoundQuantity, Appendable) except it does not raise an IOException. |
static NumberDelimiterQuantityFormat |
getInstance() |
Returns the default format.
|
static NumberDelimiterQuantityFormat |
getInstance(NumberFormat numberFormat,
javax.measure.format.UnitFormat unitFormat) |
Returns the quantity format using the specified number format and unit format (the number and unit are separated by one space).
|
static NumberDelimiterQuantityFormat |
getInstance(FormatBehavior style) |
Returns an instance of
NumberDelimiterQuantityFormat with a particular FormatBehavior , either locale-sensitive or locale-neutral. |
boolean |
isLocaleSensitive() |
|
javax.measure.Quantity<?> |
parse(CharSequence csq) |
Parses a portion of the specified
CharSequence from the specified position to produce an object. |
protected javax.measure.Quantity<?> |
parse(CharSequence csq,
int index) |
Parses a portion of the specified
CharSequence from the specified position to produce an object. |
javax.measure.Quantity<?> |
parse(CharSequence csq,
ParsePosition cursor) |
Parses a portion of the specified
CharSequence from the specified position to produce an object. |
CompoundQuantity<?> |
parseCompound(CharSequence csq) |
|
protected CompoundQuantity<?> |
parseCompound(CharSequence csq,
int index) |
|
CompoundQuantity<?> |
parseCompound(CharSequence csq,
ParsePosition cursor) |
|
String |
toString() |
format, format, format, parseObject
clone, format, formatToCharacterIterator, parseObject
public static NumberDelimiterQuantityFormat getInstance(FormatBehavior style)
NumberDelimiterQuantityFormat
with a particular FormatBehavior
, either locale-sensitive or locale-neutral.
For example: NumberDelimiterQuantityFormat.getInstance(LOCALE_NEUTRAL))
returnsnew NumberDelimiterQuantityFormat.Builder()
.setNumberFormat(NumberFormat.getInstance(Locale.ROOT)).setUnitFormat(SimpleUnitFormat.getInstance()).build();
style
- the format behavior to apply.NumberDelimiterQuantityFormat.getInstance(NumberFormat.getInstance(), UnitFormat.getInstance())
public static final NumberDelimiterQuantityFormat.Builder builder()
NumberDelimiterQuantityFormat.Builder
.NumberDelimiterQuantityFormat.Builder
.public static NumberDelimiterQuantityFormat getInstance()
public static NumberDelimiterQuantityFormat getInstance(NumberFormat numberFormat, javax.measure.format.UnitFormat unitFormat)
numberFormat
- the number format.unitFormat
- the unit format.public Appendable format(javax.measure.Quantity<?> quantity, Appendable dest) throws IOException
AbstractQuantityFormat
Appendable
.format
in class AbstractQuantityFormat
quantity
- the quantity to format.dest
- the appendable destination.Appendable
.IOException
- if an I/O exception occurs.public javax.measure.Quantity<?> parse(CharSequence csq, ParsePosition cursor) throws IllegalArgumentException, javax.measure.format.MeasurementParseException
AbstractQuantityFormat
CharSequence
from the specified position to produce an object. If parsing succeeds, then the
index of the cursor
argument is updated to the index after the last character used.parse
in class AbstractQuantityFormat
csq
- 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).javax.measure.format.MeasurementParseException
protected javax.measure.Quantity<?> parse(CharSequence csq, int index) throws IllegalArgumentException, javax.measure.format.MeasurementParseException
AbstractQuantityFormat
CharSequence
from the specified position to produce an object. If parsing succeeds, then the
index of the cursor
argument is updated to the index after the last character used.parse
in class AbstractQuantityFormat
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).javax.measure.format.MeasurementParseException
public javax.measure.Quantity<?> parse(CharSequence csq) throws IllegalArgumentException, javax.measure.format.MeasurementParseException
AbstractQuantityFormat
CharSequence
from the specified position to produce an object. If parsing succeeds, then the
index of the cursor
argument is updated to the index after the last character used.parse
in class AbstractQuantityFormat
csq
- the CharSequence
to parse.IllegalArgumentException
- if any problem occurs while parsing the specified character sequence (e.g. illegal syntax).javax.measure.format.MeasurementParseException
public boolean isLocaleSensitive()
protected StringBuffer formatCompound(CompoundQuantity<?> comp, StringBuffer dest)
AbstractQuantityFormat
#format(CompoundQuantity, Appendable)
except it does not raise an IOException.formatCompound
in class AbstractQuantityFormat
comp
- the composite quantity to format.dest
- the appendable destination.StringBuilder
.public CompoundQuantity<?> parseCompound(CharSequence csq, ParsePosition cursor) throws IllegalArgumentException, javax.measure.format.MeasurementParseException
IllegalArgumentException
javax.measure.format.MeasurementParseException
protected CompoundQuantity<?> parseCompound(CharSequence csq, int index) throws IllegalArgumentException, javax.measure.format.MeasurementParseException
IllegalArgumentException
javax.measure.format.MeasurementParseException
public CompoundQuantity<?> parseCompound(CharSequence csq) throws IllegalArgumentException, javax.measure.format.MeasurementParseException
IllegalArgumentException
javax.measure.format.MeasurementParseException
Copyright © 2005–2020 Units of Measurement project. All rights reserved.