Package tech.units.indriya.format
Class EBNFHelper
java.lang.Object
tech.units.indriya.format.EBNFHelper
Helper class that handles internals of formatting in
EBNFUnitFormat
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) static final int
Operator precedence for the addition and subtraction operationsprivate static final char
Exponent 1 characterprivate static final char
Exponent 2 character(package private) static final int
Operator precedence for the exponentiation and logarithm operations(package private) static final char
(package private) static final int
Operator precedence for a unit identifier containing no mathematical operations (i.e., consisting exclusively of an identifier and possibly a prefix).(package private) static final int
Operator precedence for the multiplication and division operations -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static void
formatExponent
(javax.measure.Unit<?> unit, int pow, int root, boolean continued, 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, 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
(Appendable buffer, String symbol) private static int
productPrecedenceInternal
(javax.measure.Unit<?> unit, Appendable buffer, SymbolMap symbolMap)
-
Field Details
-
ADDITION_PRECEDENCE
static final int ADDITION_PRECEDENCEOperator precedence for the addition and subtraction operations- See Also:
-
PRODUCT_PRECEDENCE
static final int PRODUCT_PRECEDENCEOperator precedence for the multiplication and division operations- See Also:
-
EXPONENT_PRECEDENCE
static final int EXPONENT_PRECEDENCEOperator precedence for the exponentiation and logarithm operations- See Also:
-
MIDDLE_DOT
static final char MIDDLE_DOT- See Also:
-
EXPONENT_1
private static final char EXPONENT_1Exponent 1 character- See Also:
-
EXPONENT_2
private static final char EXPONENT_2Exponent 2 character- See Also:
-
NOOP_PRECEDENCE
static final int NOOP_PRECEDENCEOperator 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:
-
-
Constructor Details
-
EBNFHelper
EBNFHelper()
-
-
Method Details
-
formatInternal
static int formatInternal(javax.measure.Unit<?> unit, Appendable buffer, SymbolMap symbolMap) throws 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. Seeinvalid reference
ConverterFormat
- 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:
IOException
-
formatExponent
private static void formatExponent(javax.measure.Unit<?> unit, int pow, int root, boolean continued, Appendable buffer, SymbolMap symbolMap) throws 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:
IOException
-
noopPrecedenceInternal
- Throws:
IOException
-
productPrecedenceInternal
private static int productPrecedenceInternal(javax.measure.Unit<?> unit, Appendable buffer, SymbolMap symbolMap) throws IOException - Throws:
IOException
-