Package javax.measure.spi
Interface FormatService
-
public interface FormatService
This interface represents the service to obtain instances ofUnitFormatandQuantityFormat.- Since:
- 2.0
- Version:
- 2.3, May 20, 2023
- Author:
- Werner Keil
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static classFormatService.FormatTypeThe type of format, either aUnitFormatorQuantityFormat
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description java.util.Set<java.lang.String>getAvailableFormatNames(FormatService.FormatType type)Gets a list with available format names of a given type for this format service.QuantityFormatgetQuantityFormat()Returns the default quantity format.QuantityFormatgetQuantityFormat(java.lang.String name)Returns the quantity format having the specified name ornullif none.UnitFormatgetUnitFormat()Returns the default unit format.UnitFormatgetUnitFormat(java.lang.String name)Returns the unit format having the specified name ornullif none.UnitFormatgetUnitFormat(java.lang.String name, java.lang.String variant)Returns the unit format having the specified name ornullif none.
-
-
-
Method Detail
-
getQuantityFormat
QuantityFormat 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
QuantityFormat getQuantityFormat(java.lang.String name)
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
UnitFormat 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
UnitFormat getUnitFormat(java.lang.String name)
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
UnitFormat getUnitFormat(java.lang.String name, java.lang.String variant)
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
java.util.Set<java.lang.String> getAvailableFormatNames(FormatService.FormatType type)
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.
-
-