Package org.apache.sis.measure
Enum UnitFormat.Style
- All Implemented Interfaces:
Serializable
,Comparable<UnitFormat.Style>
,java.lang.constant.Constable
- Enclosing class:
- UnitFormat
Identify whether unit formatting uses ASCII symbols, Unicode symbols or full localized names.
For example, the
Units.CUBIC_METRE
units can be formatted in the following ways:
- As a symbol using Unicode characters: m³
- As a symbol restricted to the ASCII characters set: m3
- As a long name:
- in English: cubic metre
- in French: mètre cube
- Since:
- 0.8
- Version:
- 0.8
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>>
-
Enum Constant Summary
Enum Constants -
Field Summary
FieldsModifier and TypeFieldDescription(package private) static final char
Other symbols not in theUnitFormat.Style
enumeration because common to all.(package private) final char
Symbols to use for unit multiplications or divisions.(package private) static final char
Other symbols not in theUnitFormat.Style
enumeration because common to all.(package private) static final char
Other symbols not in theUnitFormat.Style
enumeration because common to all.(package private) final char
Symbols to use for unit multiplications or divisions.(package private) static final char
Other symbols not in theUnitFormat.Style
enumeration because common to all. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivate
Style
(char multiply, char divide) Creates a new style using the given symbols. -
Method Summary
Modifier and TypeMethodDescription(package private) void
appendPower
(Appendable toAppendTo, int power) Appends an integer power.(package private) void
appendPower
(Appendable toAppendTo, Fraction power) Appends a rational power.(package private) Appendable
appendSymbol
(Appendable toAppendTo, String value) Appends a string that may contains Unicode characters.static UnitFormat.Style
Returns the enum constant of this type with the specified name.static UnitFormat.Style[]
values()
Returns an array containing the constants of this enum type, in the order they are declared.
-
Enum Constant Details
-
SYMBOL
Format unit symbols using Unicode characters. Units formatted in this style use superscript digits for exponents (as in “m³”), the dot operator (“⋅”) for multiplications, specialized characters when they exist (e.g. U+212A “K” for Kelvin sign), etc.This is the default style of
UnitFormat
.- See Also:
-
Unit.getSymbol()
-
UCUM
Format unit symbols using a syntax close to the Unified Code for Units of Measure (UCUM) one. The character set is restricted to ASCII. The multiplication operator is the period (“.”).Modification to UCUM syntax rules
UCUM does not allow floating point numbers in unit terms, so the use of period as an operator should not be ambiguous. However, Apache SIS relaxes this restriction in order to support the scale factors commonly found in angular units (e.g. π/180). The meaning of a period in a string is resolved with two SIS-specific rules:- Unit symbols shall not begin or end with a decimal digit or a superscript.
- A period between two decimal digits is interpreted as a decimal separator.
- See Also:
-
NAME
Format unit symbols as localized long names if known, or Unicode symbols otherwise.- See Also:
-
Unit.getName()
-
-
Field Details
-
EXPONENT_OR_MULTIPLY
static final char EXPONENT_OR_MULTIPLYOther symbols not in theUnitFormat.Style
enumeration because common to all.- See Also:
-
EXPONENT
static final char EXPONENTOther symbols not in theUnitFormat.Style
enumeration because common to all.- See Also:
-
OPEN
static final char OPENOther symbols not in theUnitFormat.Style
enumeration because common to all.- See Also:
-
CLOSE
static final char CLOSEOther symbols not in theUnitFormat.Style
enumeration because common to all.- See Also:
-
multiply
final char multiplySymbols to use for unit multiplications or divisions. -
divide
final char divideSymbols to use for unit multiplications or divisions.
-
-
Constructor Details
-
Style
private Style(char multiply, char divide) Creates a new style using the given symbols.
-
-
Method Details
-
values
Returns an array containing the constants of this enum type, in the order they are declared.- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)- Parameters:
name
- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException
- if this enum type has no constant with the specified nameNullPointerException
- if the argument is null
-
appendSymbol
Appends a string that may contains Unicode characters. The enumeration is responsible for converting the Unicode characters into ASCII ones if needed.- Throws:
IOException
-
appendPower
Appends an integer power. The power may be added as an exponent if allowed by the format style.- Throws:
IOException
-
appendPower
Appends a rational power.- Throws:
IOException
-