Package javax.measure.spi
Interface FormatService
public interface FormatService
This interface represents the service to obtain instances of
UnitFormat
and QuantityFormat
.- Since:
- 2.0
- Version:
- 2.3, May 20, 2023
- Author:
- Werner Keil
-
Nested Class Summary
Modifier and TypeInterfaceDescriptionstatic enum
The type of format, either aUnitFormat
orQuantityFormat
-
Method Summary
Modifier and TypeMethodDescriptionGets a list with available format names of a given type for this format service.Returns the default quantity format.getQuantityFormat
(String name) Returns the quantity format having the specified name ornull
if none.Returns the default unit format.getUnitFormat
(String name) Returns the unit format having the specified name ornull
if none.getUnitFormat
(String name, String variant) Returns the unit format having the specified name ornull
if none.
-
Method Details
-
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 onLocale.current()
while others may returngetQuantityFormat("Simple")
orgetQuantityFormat("ISO")
.- Returns:
- the default
QuantityFormat
implementation.
-
getQuantityFormat
Returns the quantity format having the specified name ornull
if none. For example (@code getQuantityFormat("Simple")} to return the simpleQuantityFormat
implementation.- Parameters:
name
- the name of the format.- Returns:
- the corresponding quantity format.
-
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 onLocale.current()
while others may returngetUnitFormat("Simple")
orgetUnitFormat("ISO")
.- Returns:
- the default
UnitFormat
implementation.
-
getUnitFormat
Returns the unit format having the specified name ornull
if none. For examplegetUnitFormat("Simple")
to return a simpleUnitFormat
implementation.- Parameters:
name
- the name of the format.- Returns:
- the corresponding unit format.
-
getUnitFormat
Returns the unit format having the specified name ornull
if none. For examplegetUnitFormat("Simple")
to return a simpleUnitFormat
implementation.
The variant is an arbitrary value to allow a variation of aUnitFormat
, for exampleUTF
vs.ASCII
encoding of the simpleUnitFormat
orcase sensitive
vs.case insensitive
UCUM format.If no variant is applicable, the
UnitFormat
matching the name only is returned.- Parameters:
name
- the name of the format.variant
- any arbitrary value used to indicate a variation of aUnitFormat
.- Returns:
- the corresponding unit format.
-
getAvailableFormatNames
Gets a list with available format names of a given type for this format service.- Parameters:
type
- theFormatService.FormatType
- Returns:
- list of available formats, never null.
-