Package tech.units.indriya.format
Class EBNFHelper
- java.lang.Object
-
- tech.units.indriya.format.EBNFHelper
-
class EBNFHelper extends java.lang.Object
Helper class that handles internals of formatting inEBNFUnitFormat
-
-
Field Summary
Fields Modifier and Type Field Description (package private) static int
ADDITION_PRECEDENCE
Operator precedence for the addition and subtraction operationsprivate static char
EXPONENT_1
Exponent 1 characterprivate static char
EXPONENT_2
Exponent 2 character(package private) static int
EXPONENT_PRECEDENCE
Operator precedence for the exponentiation and logarithm operations(package private) static char
MIDDLE_DOT
(package private) static int
NOOP_PRECEDENCE
Operator precedence for a unit identifier containing no mathematical operations (i.e., consisting exclusively of an identifier and possibly a prefix).(package private) static int
PRODUCT_PRECEDENCE
Operator precedence for the multiplication and division operations
-
Constructor Summary
Constructors Constructor Description EBNFHelper()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description private static void
formatExponent(javax.measure.Unit<?> unit, int pow, int root, boolean continued, java.lang.Appendable buffer, SymbolMap symbolMap)
Format the given unit raised to the given fractional power to the givenStringBuffer
.(package private) static int
formatInternal(javax.measure.Unit<?> unit, java.lang.Appendable buffer, SymbolMap symbolMap)
Format the given unit to the given StringBuffer, then return the operator precedence of the outermost operator in the unit expression that was formatted.private static int
noopPrecedenceInternal(java.lang.Appendable buffer, java.lang.String symbol)
private static int
productPrecedenceInternal(javax.measure.Unit<?> unit, java.lang.Appendable buffer, SymbolMap symbolMap)
-
-
-
Field Detail
-
ADDITION_PRECEDENCE
static final int ADDITION_PRECEDENCE
Operator precedence for the addition and subtraction operations- See Also:
- Constant Field Values
-
PRODUCT_PRECEDENCE
static final int PRODUCT_PRECEDENCE
Operator precedence for the multiplication and division operations- See Also:
- Constant Field Values
-
EXPONENT_PRECEDENCE
static final int EXPONENT_PRECEDENCE
Operator precedence for the exponentiation and logarithm operations- See Also:
- Constant Field Values
-
MIDDLE_DOT
static final char MIDDLE_DOT
- See Also:
- Constant Field Values
-
EXPONENT_1
private static final char EXPONENT_1
Exponent 1 character- See Also:
- Constant Field Values
-
EXPONENT_2
private static final char EXPONENT_2
Exponent 2 character- See Also:
- Constant Field Values
-
NOOP_PRECEDENCE
static final int NOOP_PRECEDENCE
Operator precedence for a unit identifier containing no mathematical operations (i.e., consisting exclusively of an identifier and possibly a prefix). Defined to beInteger.MAX_VALUE
so that no operator can have a higher precedence.- See Also:
- Constant Field Values
-
-
Method Detail
-
formatInternal
static int formatInternal(javax.measure.Unit<?> unit, java.lang.Appendable buffer, SymbolMap symbolMap) throws java.io.IOException
Format the given unit to the given StringBuffer, then return the operator precedence of the outermost operator in the unit expression that was formatted. SeeConverterFormat
for the constants that define the various precedence values.- Parameters:
unit
- the unit to be formattedbuffer
- theStringBuffer
to be written to- Returns:
- the operator precedence of the outermost operator in the unit expression that was output
- Throws:
java.io.IOException
-
formatExponent
private static void formatExponent(javax.measure.Unit<?> unit, int pow, int root, boolean continued, java.lang.Appendable buffer, SymbolMap symbolMap) throws java.io.IOException
Format the given unit raised to the given fractional power to the givenStringBuffer
.- Parameters:
unit
- Unit the unit to be formattedpow
- int the numerator of the fractional powerroot
- int the denominator of the fractional powercontinued
- booleantrue
if the converter expression should begin with an operator, otherwisefalse
. This will always be true unless the unit being modified is equal to Unit.ONE.buffer
- StringBuffer the buffer to append to. No assumptions should be made about its content.- Throws:
java.io.IOException
-
noopPrecedenceInternal
private static int noopPrecedenceInternal(java.lang.Appendable buffer, java.lang.String symbol) throws java.io.IOException
- Throws:
java.io.IOException
-
productPrecedenceInternal
private static int productPrecedenceInternal(javax.measure.Unit<?> unit, java.lang.Appendable buffer, SymbolMap symbolMap) throws java.io.IOException
- Throws:
java.io.IOException
-
-