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
Nested ClassesModifier and TypeInterfaceDescriptionstatic enumThe type of format, either aUnitFormatorQuantityFormat -
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 ornullif none.Returns the default unit format.getUnitFormat(String name) Returns the unit format having the specified name ornullif none.getUnitFormat(String name, String variant) Returns the unit format having the specified name ornullif 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
QuantityFormatimplementation.
-
getQuantityFormat
Returns the quantity format having the specified name ornullif none. For example (@code getQuantityFormat("Simple")} to return the simpleQuantityFormatimplementation.- 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
UnitFormatimplementation.
-
getUnitFormat
Returns the unit format having the specified name ornullif none. For examplegetUnitFormat("Simple")to return a simpleUnitFormatimplementation.- Parameters:
name- the name of the format.- Returns:
- the corresponding unit format.
-
getUnitFormat
Returns the unit format having the specified name ornullif none. For examplegetUnitFormat("Simple")to return a simpleUnitFormatimplementation.
The variant is an arbitrary value to allow a variation of aUnitFormat, for exampleUTFvs.ASCIIencoding of the simpleUnitFormatorcase sensitivevs.case insensitiveUCUM format.If no variant is applicable, the
UnitFormatmatching 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.
-