public class EBNFUnitFormat extends AbstractUnitFormat
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 | Method and Description |
|---|---|
Appendable |
format(javax.measure.Unit<?> unit,
Appendable appendable)
Formats the specified unit.
|
static EBNFUnitFormat |
getInstance()
Returns the instance for the current default locale (non-ascii characters are allowed)
|
static EBNFUnitFormat |
getInstance(SymbolMap symbols)
Returns an instance for the given symbol map.
|
protected SymbolMap |
getSymbols()
Get the symbol map used by this instance to map between
Units and Strings, etc... |
javax.measure.Unit<?> |
parse(CharSequence csq) |
protected javax.measure.Unit<?> |
parse(CharSequence csq,
int index)
Parses a portion of the specified
CharSequence from the specified position to produce a unit. |
javax.measure.Unit<? extends javax.measure.Quantity<?>> |
parse(CharSequence csq,
ParsePosition cursor)
Parses a portion of the specified
CharSequence from the specified position to produce a unit. |
String |
toString() |
format, labelpublic static EBNFUnitFormat getInstance()
public static EBNFUnitFormat getInstance(SymbolMap symbols)
protected SymbolMap getSymbols()
Units and Strings, etc...public Appendable format(javax.measure.Unit<?> unit, Appendable appendable) throws IOException
AbstractUnitFormatformat in interface javax.measure.format.UnitFormatformat in class AbstractUnitFormatunit - the unit to format.appendable - the appendable destination.appendable, with formatted text appended.IOException - if an error occurs.public javax.measure.Unit<? extends javax.measure.Quantity<?>> parse(CharSequence csq, ParsePosition cursor) throws javax.measure.format.MeasurementParseException
AbstractUnitFormatCharSequence from the specified position to produce a unit. If there is no unit to parse
AbstractUnit.ONE is returned.parse in interface javax.measure.format.UnitFormatparse in class AbstractUnitFormatcsq - the CharSequence to parse.cursor - the cursor holding the current parsing index.javax.measure.format.MeasurementParseExceptionprotected javax.measure.Unit<?> parse(CharSequence csq, int index) throws IllegalArgumentException
AbstractUnitFormatCharSequence from the specified position to produce a unit. If there is no unit to parse
AbstractUnit.ONE is returned.parse in class AbstractUnitFormatcsq - the CharSequence to parse.index - the current parsing index.IllegalArgumentException - if any problem occurs while parsing the specified character sequence (e.g. illegal syntax).public javax.measure.Unit<?> parse(CharSequence csq) throws javax.measure.format.MeasurementParseException
javax.measure.format.MeasurementParseExceptionCopyright © 2005–2021 Units of Measurement project. All rights reserved.