Top Description Fields Constructors Methods
tech.units.indriya.format

public Class DefaultFormatService

extends Object
implements FormatService, IntPrioritySupplier
Class Inheritance
All Implemented Interfaces
tech.uom.lib.common.function.IntPrioritySupplier, javax.measure.spi.FormatService
Static Imports
tech.units.indriya.format.FormatBehavior.LOCALE_SENSITIVE

Default format service.
Author
Werner Keil
Since
2.0
Version
2.3, November 26, 2020

Field Summary

Modifier and TypeField and Description
private static final String
private static final String
private static final String
private static final String
private static final NumberDelimiterQuantityFormat
EBNF_QUANTITY_FORMAT

Holds the default format instance (EBNFUnitFormat).

private static final String
private static final int
private final Map<String, String>
private final Map<String, QuantityFormat>
private static final String
private final Map<String, String>
private final Map<String, UnitFormat>

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public Set<String>
getAvailableFormatNames(FormatService.FormatType type)

Implements javax.measure.spi.FormatService.getAvailableFormatNames.

Gets a list with available format names of a given type for this format service.

public int
public QuantityFormat
getQuantityFormat(String
the name of the format.
key
)

Implements javax.measure.spi.FormatService.getQuantityFormat.

Returns the quantity format having the specified name or null if none.

public QuantityFormat
getQuantityFormat()

Implements javax.measure.spi.FormatService.getQuantityFormat.

Returns the default quantity format.

public UnitFormat
getUnitFormat(String
the name of the format.
key
)

Implements javax.measure.spi.FormatService.getUnitFormat.

Returns the unit format having the specified name or null if none.

public UnitFormat
getUnitFormat()

Implements javax.measure.spi.FormatService.getUnitFormat.

Returns the default unit format.

public UnitFormat
getUnitFormat(String
the name of the format.
name
,
String
any arbitrary value used to indicate a variation of a UnitFormat.
variant
)

Implements javax.measure.spi.FormatService.getUnitFormat.

Returns the unit format having the specified name or null if none.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

ASCII_UNIT_FORMAT_NAMEback to summary
private static final String ASCII_UNIT_FORMAT_NAME
DEFAULT_QUANTITY_FORMAT_NAMEback to summary
private static final String DEFAULT_QUANTITY_FORMAT_NAME
DEFAULT_UNIT_FORMAT_NAMEback to summary
private static final String DEFAULT_UNIT_FORMAT_NAME
EBNF_KEYback to summary
private static final String EBNF_KEY
EBNF_QUANTITY_FORMATback to summary
private static final NumberDelimiterQuantityFormat EBNF_QUANTITY_FORMAT

Holds the default format instance (EBNFUnitFormat).

LOCAL_KEYback to summary
private static final String LOCAL_KEY
PRIOback to summary
private static final int PRIO
quantityFormatAliasesback to summary
private final Map<String, String> quantityFormatAliases
quantityFormatsback to summary
private final Map<String, QuantityFormat> quantityFormats
SIMPLE_KEYback to summary
private static final String SIMPLE_KEY
unitFormatAliasesback to summary
private final Map<String, String> unitFormatAliases
unitFormatsback to summary
private final Map<String, UnitFormat> unitFormats

Constructor Detail

DefaultFormatServiceback to summary
public DefaultFormatService()

Method Detail

getAvailableFormatNamesback to summary
public Set<String> getAvailableFormatNames(FormatService.FormatType type)

Implements javax.measure.spi.FormatService.getAvailableFormatNames.

Doc from javax.measure.spi.FormatService.getAvailableFormatNames.

Gets a list with available format names of a given type for this format service.

Parameters
type:FormatService.FormatType

the FormatType

Returns:Set<String>

list of available formats, never null.

Annotations
@Override
getPriorityback to summary
public int getPriority()

Implements tech.uom.lib.common.function.IntPrioritySupplier.getPriority.

Doc from tech.uom.lib.common.function.IntPrioritySupplier.getPriority.

Gets a priority value.

Returns:int

a priority value

Annotations
@Override
getQuantityFormatback to summary
public QuantityFormat getQuantityFormat(String key)

Implements javax.measure.spi.FormatService.getQuantityFormat.

Doc from javax.measure.spi.FormatService.getQuantityFormat.

Returns the quantity format having the specified name or null if none. For example (@code getQuantityFormat("Simple")} to return the simple QuantityFormat implementation.

Parameters
key:String

the name of the format.

Returns:QuantityFormat

the corresponding quantity format.

Annotations
@Override
getQuantityFormatback to summary
public QuantityFormat getQuantityFormat()

Implements javax.measure.spi.FormatService.getQuantityFormat.

Doc from javax.measure.spi.FormatService.getQuantityFormat.

Returns the default quantity format. It is up to implementations what to consider a suitable default. For some (locale-sensitive) implementations it may be a quantity format based on Locale.current() while others may return getQuantityFormat("Simple") or getQuantityFormat("ISO").

Returns:QuantityFormat

the default QuantityFormat implementation.

Annotations
@Override
getUnitFormatback to summary
public UnitFormat getUnitFormat(String key)

Implements javax.measure.spi.FormatService.getUnitFormat.

Doc from javax.measure.spi.FormatService.getUnitFormat.

Returns the unit format having the specified name or null if none. For example getUnitFormat("Simple") to return a simple UnitFormat implementation.

Parameters
key:String

the name of the format.

Returns:UnitFormat

the corresponding unit format.

Annotations
@Override
getUnitFormatback to summary
public UnitFormat getUnitFormat()

Implements javax.measure.spi.FormatService.getUnitFormat.

Doc from javax.measure.spi.FormatService.getUnitFormat.

Returns the default unit format. It is up to implementations what to consider a suitable default. For some (locale-sensitive) implementations it may be a unit format based on Locale.current() while others may return getUnitFormat("Simple") or getUnitFormat("ISO").

Returns:UnitFormat

the default UnitFormat implementation.

Annotations
@Override
getUnitFormatback to summary
public UnitFormat getUnitFormat(String name, String variant)

Implements javax.measure.spi.FormatService.getUnitFormat.

Doc from javax.measure.spi.FormatService.getUnitFormat.

Returns the unit format having the specified name or null if none. For example getUnitFormat("Simple") to return a simple UnitFormat implementation.
The variant is an arbitrary value to allow a variation of a UnitFormat, for example UTF vs. ASCII encoding of the simple UnitFormat or case sensitive vs. case insensitive UCUM format.

If no variant is applicable, the UnitFormat matching the name only is returned.

Parameters
name:String

the name of the format.

variant:String

any arbitrary value used to indicate a variation of a UnitFormat.

Returns:UnitFormat

the corresponding unit format.

Annotations
@Override