public class UnitServices extends ServiceProvider implements SystemOfUnitsService, UnitFormatService
Units pre-defined constants and UnitFormat
directly since they are designed specifically for SIS needs).
This class is provided for allowing other applications to discover Apache SIS implementation of JSR-363
without direct dependency. A UnitServices instance can be obtained by call to ServiceProvider.current().Defined in the sis-utility module
| Constructor and Description |
|---|
UnitServices()
Creates a new service provider.
|
| Modifier and Type | Method and Description |
|---|---|
Set<String> |
getAvailableFormatNames()
Returns a list of available format names.
|
Collection<SystemOfUnits> |
getAvailableSystemsOfUnits()
Returns the list of all available systems of units.
|
<Q extends Quantity<Q>> |
getQuantityFactory(Class<Q> type)
Return a factory for the given
Quantity type. |
SystemOfUnits |
getSystemOfUnits()
Returns the default system of units used by Apache SIS.
|
SystemOfUnits |
getSystemOfUnits(String name)
Returns the system of units having the specified name, or
null if none. |
SystemOfUnitsService |
getSystemOfUnitsService()
Returns the service to obtain a
SystemOfUnits instances. |
UnitFormat |
getUnitFormat()
Returns an unit format instance for human-readable unit symbols in the default locale.
|
UnitFormat |
getUnitFormat(String name)
Returns the unit format for the given name.
|
UnitFormatService |
getUnitFormatService()
Returns the service to obtain a
UnitFormat instances. |
available, current, getPriority, setCurrentpublic UnitServices()
UnitServices should not be instantiated
directly unless the caller wants specifically the Apache SIS implementation.
For obtaining the default implementation, use ServiceProvider.current() instead.public SystemOfUnits getSystemOfUnits()
Units class.getSystemOfUnits in interface SystemOfUnitsServicepublic SystemOfUnits getSystemOfUnits(String name)
null if none.
The argument can be any name in the following table:
| Name | Examples |
|---|---|
| SI | m, km, m³, s, m∕s, K, °C, hPa, rad, µrad |
| SI + accepted | s, min, h, m∕s, km∕h, °, ′, ″, ha |
| Imperial | in, ft, mi (statute mile) |
| SI + other | m, m∕s, km∕h, ft, mi, M (nautical mile) |
getSystemOfUnits in interface SystemOfUnitsServicename - the name of the desired system of units.null if none.public Collection<SystemOfUnits> getAvailableSystemsOfUnits()
getAvailableSystemsOfUnits in interface SystemOfUnitsServicepublic SystemOfUnitsService getSystemOfUnitsService()
SystemOfUnits instances.
The default implementation returns this since this UnitServices class
implements directly all relevant interfaces. The methods related to system of units are:
getSystemOfUnitsService in class ServiceProviderSystemOfUnits, or null if none.public UnitFormat getUnitFormat()
UnitFormat.Style.SYMBOL.
This style requires support for Unicode characters;
for example square metres are formatted as “m²”, not “m2”.getUnitFormat in interface UnitFormatServiceUnitFormat instance for unit symbols.public UnitFormat getUnitFormat(String name)
UnitFormat.Style enumeration.
The argument can be any name in the following table:
| Name | Examples |
|---|---|
| SYMBOL | km, m³, m∕s, N⋅m, K, °C, hPa, rad, µrad |
| UCUM | km, m3, m/s, N.m |
| NAME | kilometre, cubic metre, metres per second |
"NAME" format is locale-sensitive. The format locale can be modified by a call
to UnitFormat.setLocale(Locale) on the returned object.getUnitFormat in interface UnitFormatServicename - the name of the desired format.null if none.public Set<String> getAvailableFormatNames()
UnitFormat.Style enumeration.getAvailableFormatNames in interface UnitFormatServicepublic UnitFormatService getUnitFormatService()
UnitFormat instances.
The default implementation returns this since this UnitServices class
implements directly all relevant interfaces. The methods related to unit formats are:
getUnitFormatService in class ServiceProviderUnitFormat, or null if none.public <Q extends Quantity<Q>> QuantityFactory<Q> getQuantityFactory(Class<Q> type)
Quantity type. In the particular case of Apache SIS implementation,
Quantities.create(double, Unit) provides a more direct way to instantiate quantities.getQuantityFactory in class ServiceProviderQ - compile-time value of the type argument.type - type of the desired the quantity.Quantity instances, or null if none.Quantities.create(double, Unit)Copyright © 2010–2017 The Apache Software Foundation. All rights reserved.