Class EBNFHelper


  • class EBNFHelper
    extends java.lang.Object
    Helper class that handles internals of formatting in EBNFUnitFormat
    • Field Summary

      Fields 
      Modifier and Type Field Description
      (package private) static int ADDITION_PRECEDENCE
      Operator precedence for the addition and subtraction operations
      private static char EXPONENT_1
      Exponent 1 character
      private 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 given StringBuffer.
      (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)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 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
      • 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 be Integer.MAX_VALUE so that no operator can have a higher precedence.
        See Also:
        Constant Field Values
    • Constructor Detail

      • EBNFHelper

        EBNFHelper()
    • 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. See ConverterFormat for the constants that define the various precedence values.
        Parameters:
        unit - the unit to be formatted
        buffer - the StringBuffer 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 given StringBuffer.
        Parameters:
        unit - Unit the unit to be formatted
        pow - int the numerator of the fractional power
        root - int the denominator of the fractional power
        continued - boolean true if the converter expression should begin with an operator, otherwise false. 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