This class represents the local neutral format.
Note that the grammar has been left-factored to be suitable for use by a top-down parser generator such as JavaCC
| Lexical Entities: | ||
|---|---|---|
| <sign> | := | "+" | "-" |
| <digit> | := | "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" |
| <superscript_digit> | := | "⁰" | "¹" | "²" | "³" | "⁴" | "⁵" | "⁶" | "⁷" | "⁸" | "⁹" |
| <integer> | := | (<digit>)+ |
| <number> | := | (<sign>)? (<digit>)* (".")? (<digit>)+ (("e" | "E") (<sign>)? (<digit>)+)? |
| <exponent> | := | ( "^" ( <sign> )? <integer> ) | ( "^(" (<sign>)? <integer> ( "/" (<sign>)? <integer> )? ")" ) | ( <superscript_digit> )+ |
| <initial_char> | := | ? Any Unicode character excluding the following: ASCII control & whitespace (\u0000 - \u0020), decimal digits '0'-'9', '(' (\u0028), ')' (\u0029), '*' (\u002A), '+' (\u002B), '-' (\u002D), '.' (\u002E), '/' (\u005C), ':' (\u003A), '^' (\u005E), '²' (\u00B2), '³' (\u00B3), '·' (\u00B7), '¹' (\u00B9), '⁰' (\u2070), '⁴' (\u2074), '⁵' (\u2075), '⁶' (\u2076), '⁷' (\u2077), '⁸' (\u2078), '⁹' (\u2079) ? |
| <unit_identifier> | := | <initial_char> ( <initial_char> | <digit> )* |
| Non-Terminals: | ||
| <unit_expr> | := | <mix_expr> |
| <mix_expr> | := | <add_expr> ( ":" <add_expr> )* |
| <add_expr> | := | ( <number> <sign> )? <mul_expr> ( <sign> <number> )? |
| <mul_expr> | := | <exponent_expr> ( ( ( "*" | "·" ) <exponent_expr> ) | ( "/" <exponent_expr> ) )* |
| <exponent_expr> | := | ( <atomic_expr> ( <exponent> )? ) | (<integer> "^" <atomic_expr>) | ( ( "log" ( <integer> )? ) | "ln" ) "(" <add_expr> ")" ) |
| <atomic_expr> | := | <number> | <unit_identifier> | ( "(" <add_expr> ")" ) |
| Modifier and Type | Field and Description |
|---|---|
| private static final String | BUNDLE_NAME
Name of the resource bundle |
| private static final EBNFUnitFormat | DEFAULT_INSTANCE
Default locale instance. |
| private final transient SymbolMap |
| Access | Constructor and Description |
|---|---|
| pack-priv | |
| private |
| Modifier and Type | Method and Description |
|---|---|
| public void | |
| public Appendable | format(Unit<?>
the unit to format. unit, Appendable the appendable destination. appendable)Implements abstract tech. Implements javax. Formats the specified unit. |
| public static EBNFUnitFormat | |
| public static EBNFUnitFormat | |
| public static EBNFUnitFormat | Returns: a new instance of the default unit format.Similar to |
| protected SymbolMap | Returns: SymbolMap the current symbol mapGet the symbol map used by this instance to map between |
| public void | label(Unit<?>
the unit being labeled. unit, String the new label for this unit. label)Overrides tech. Implements javax. Attaches a system-wide label to the specified |
| public Unit | parse(CharSequence
the csq, ParsePosition CharSequence to parse.the cursor holding the current parsing index. cursor)Implements abstract tech. Implements javax. Parses a portion of the specified |
| protected Unit | parse(CharSequence
the csq, int CharSequence to parse.the current parsing index. index)Implements abstract tech. Parses a portion of the specified |
| public Unit | parse(CharSequence
the csq)CharSequence to parse.Implements javax. Parses the text into an instance of |
| public String |
| BUNDLE_NAME | back to summary |
|---|---|
| private static final String BUNDLE_NAME Name of the resource bundle | |
| DEFAULT_INSTANCE | back to summary |
|---|---|
| private static final EBNFUnitFormat DEFAULT_INSTANCE Default locale instance. If the default locale is changed after the class is initialized, this instance will no longer be used. | |
| symbolMap | back to summary |
|---|---|
| private final transient SymbolMap symbolMap The symbol map used by this instance to map between | |
| EBNFUnitFormat | back to summary |
|---|---|
| pack-priv EBNFUnitFormat() Base constructor. | |
| EBNFUnitFormat | back to summary |
|---|---|
| private EBNFUnitFormat(SymbolMap symbols) Private constructor.
| |
| alias | back to summary |
|---|---|
| public void alias(Unit<?> unit, String alias) Attaches a system-wide alias to this unit. Multiple aliases may be attached to the same unit. Aliases are used during parsing to recognize
different variants of the same unit. For example: | |
| format | back to summary |
|---|---|
| public Appendable format(Unit<?> unit, Appendable appendable) throws IOException Implements abstract tech. Implements javax. Doc from tech. Formats the specified unit.
| |
| getInstance | back to summary |
|---|---|
| public static EBNFUnitFormat getInstance() Returns the instance for the current default locale (non-ascii characters are allowed) | |
| getInstance | back to summary |
|---|---|
| public static EBNFUnitFormat getInstance(SymbolMap symbols) Returns a new instance for the given symbol map. | |
| getNewInstance | back to summary |
|---|---|
| public static EBNFUnitFormat getNewInstance() Similar to
| |
| getSymbols | back to summary |
|---|---|
| protected SymbolMap getSymbols() Get the symbol map used by this instance to map between
| |
| label | back to summary |
|---|---|
| public void label(Unit<?> unit, String label) Overrides tech. Implements javax. Doc from javax. Attaches a system-wide label to the specified
This method overrides the previous unit's label (e.g. label from unit database or unit system) as units may only have one label. Depending on the
UnitFormat implementation is explicitly immutable, similar to e.g. the result of Collections.unmodifiableList(),
then an UnsupportedOperationException may be thrown upon this call.
Since | |
| parse | back to summary |
|---|---|
| public Unit Implements abstract tech. Implements javax. Doc from tech. Parses a portion of the specified
| |
| parse | back to summary |
|---|---|
| protected Unit Implements abstract tech. Doc from tech. Parses a portion of the specified
| |
| parse | back to summary |
|---|---|
| public Unit Implements javax. Doc from javax. Parses the text into an instance of The parse must complete normally and parse the entire text. If the parse completes without reading the entire length of the text, an exception is thrown. If any other problem occurs during parsing, an exception is thrown.
| |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Doc from java. Returns a string representation of the object.
Satisfying this method's contract implies a non- | |