Class LocalUnitFormat
java.lang.Object
tech.units.indriya.format.AbstractUnitFormat
tech.units.indriya.format.LocalUnitFormat
- All Implemented Interfaces:
javax.measure.format.UnitFormat
This class represents the local sensitive format.
Here is the grammar for CommonUnits in Extended Backus-Naur Form (EBNF)
Note that the grammar has been left-factored to be suitable for use by a top-down parser generator such as JavaCC
invalid input: '<'table width="90%" * align="center">| ( "^(" (<sign>)? <integer> ( "/" (<sign>)? <integer> )? ")" )
| ( <superscript_digit> )+
| (<integer> "^" <atomic_expr>)
| ( ( "log" ( <integer> )? ) | "ln" ) "(" <add_expr> ")" )
| <unit_identifier>
| ( "(" <add_expr> ")" )
- Since:
- 1.0
- Version:
- 1.0.2, April 30, 2017
- Author:
- Eric Russell, Werner Keil
-
Method Summary
Modifier and TypeMethodDescriptionformat(javax.measure.Unit<?> unit, Appendable appendable) Formats the specified unit.static LocalUnitFormatReturns the instance for the current default locale (non-ascii characters are allowed)static LocalUnitFormatgetInstance(Locale locale) Returns an instance for the given locale.static LocalUnitFormatgetInstance(SymbolMap symbols) Returns an instance for the given symbol map.protected SymbolMapGet the symbol map used by this instance to map betweenUnits andStrings, etc...booleanjavax.measure.Unit<? extends javax.measure.Quantity<?>> parse(CharSequence csq) protected javax.measure.Unit<?> parse(CharSequence csq, int index) Parses a portion of the specifiedCharSequencefrom the specified position to produce a unit.javax.measure.Unit<?> parse(CharSequence csq, ParsePosition cursor) Parses a portion of the specifiedCharSequencefrom the specified position to produce a unit.Methods inherited from class AbstractUnitFormat
format, label
-
Method Details
-
getInstance
Returns the instance for the current default locale (non-ascii characters are allowed) -
getInstance
Returns an instance for the given locale.- Parameters:
locale-
-
getInstance
Returns an instance for the given symbol map. -
getSymbols
Get the symbol map used by this instance to map betweenUnits andStrings, etc...- Specified by:
getSymbolsin classAbstractUnitFormat- Returns:
- SymbolMap the current symbol map
-
format
Description copied from class:AbstractUnitFormatFormats the specified unit.- Specified by:
formatin interfacejavax.measure.format.UnitFormat- Specified by:
formatin classAbstractUnitFormat- Parameters:
unit- the unit to format.appendable- the appendable destination.- Returns:
- The appendable destination passed in as
appendable, with formatted text appended. - Throws:
IOException- if an error occurs.
-
isLocaleSensitive
-
parse
protected javax.measure.Unit<?> parse(CharSequence csq, int index) throws javax.measure.format.ParserException Description copied from class:AbstractUnitFormatParses a portion of the specifiedCharSequencefrom the specified position to produce a unit. If there is no unit to parseAbstractUnit.ONEis returned.- Specified by:
parsein classAbstractUnitFormat- Parameters:
csq- theCharSequenceto parse.index- the current parsing index.- Returns:
- the unit parsed from the specified character sub-sequence.
- Throws:
javax.measure.format.ParserException
-
parse
public javax.measure.Unit<?> parse(CharSequence csq, ParsePosition cursor) throws javax.measure.format.ParserException Description copied from class:AbstractUnitFormatParses a portion of the specifiedCharSequencefrom the specified position to produce a unit. If there is no unit to parseAbstractUnit.ONEis returned.- Specified by:
parsein classAbstractUnitFormat- Parameters:
csq- theCharSequenceto parse.cursor- the cursor holding the current parsing index.- Returns:
- the unit parsed from the specified character sub-sequence.
- Throws:
javax.measure.format.ParserException
-
parse
public javax.measure.Unit<? extends javax.measure.Quantity<?>> parse(CharSequence csq) throws javax.measure.format.ParserException - Throws:
javax.measure.format.ParserException
-