Class CalcSymbol


  • public final class CalcSymbol
    extends java.lang.Object
    Class CalcSymbol defines objects which are the typed-values used by the CalcParser (FormCalc scripting engine).

    Each CalcSymbol have but two properties: a type, and depending on the type, a value. and a storage type. Some types of CalcSymbols have extra values.

    This is the implementation of the fundamental class of objects manipulated by FormCalc parser and interpreter. Objects of this class populate both the data symbol table, and the builtin symbol table, the runtime stack, and constitute the operands of some instructions, as well as the final result of every FormCalc parser/interpreter operation.

    @author Paul Imerson, Mike P. Tardif

    • Constructor Detail

      • CalcSymbol

        public CalcSymbol()
        Instantiates a CalcSymbol of type TypeNull.
      • CalcSymbol

        public CalcSymbol​(int nVal)
        Instantiates a CalcSymbol of type TypeDouble.
        Parameters:
        nVal - the numeric value of the CalcSymbol.
      • CalcSymbol

        public CalcSymbol​(double dVal)
        Instantiates a CalcSymbol of type TypeDouble if the value of the given double is finite, and of type TypeError if the value of the given double is not finite.
        Parameters:
        dVal - the double value of the CalcSymbol.
      • CalcSymbol

        public CalcSymbol​(java.lang.String sVal,
                          boolean bIsError,
                          int nErrorLine,
                          int nErrorResId)
        Instantiates a CalcSymbol of type TypeString if the given boolean isError is false, and a CalcSymbol of type * TypeError is the given boolean is true.
        Parameters:
        sVal - the string value of the CalcSymbol if the given boolean isError is false, and the error value of the CalcSymbol if the given boolean is true.
        bIsError - a boolean indicating if the instantiated CalcSymbol is to be of type TypeError, or of type TypeString. The defaults is for the CalcSymbol to be of type TypeString.
        nErrorLine - if bIsError is true, this contains the associated line number in the context of syntax errors (not run-time errors). if the value of the given boolean is false, and an error-valued CalcSymbol if the value of the given boolean is true.
        nErrorResId - - if bIsError is TRUE, this contains the associated resource ID of the error.
      • CalcSymbol

        public CalcSymbol​(java.lang.String sVal)
        Instantiates a CalcSymbol of type TypeString.
        Parameters:
        sVal - the string value of the CalcSymbol.
      • CalcSymbol

        public CalcSymbol​(java.lang.reflect.Method func)
        Instantiates a CalcSymbol of type TypeBuiltin.
        Parameters:
        func - the builtin function.
      • CalcSymbol

        public CalcSymbol​(Obj oObj,
                          java.lang.String sName)
        Instantiates a CalcSymbol of type TypeReference.
        Parameters:
        oObj - the object handle.
        sName - optionally, the object name.
      • CalcSymbol

        public CalcSymbol​(CalcSymbol oSym)
        Instantiates a CalcSymbol as a copy of the given CalcSymbol.
        Parameters:
        oSym - the CalcSymbol to copy.
    • Method Detail

      • equals

        public boolean equals​(java.lang.Object object)
        Compares the given CalcSymbol for equality.
        Overrides:
        equals in class java.lang.Object
        Parameters:
        object - the CalcSymbol being compared with.
        Returns:
        boolean true if equal, and false otherwise.
      • hashCode

        public int hashCode()
        Returns a hash code value for the object.
        Overrides:
        hashCode in class java.lang.Object
      • getName

        public java.lang.String getName()
        Gets this object's name.
        Returns:
        the object's name.
      • getType

        public int getType()
        Gets this object's type.
        Returns:
        the object's type.
      • getObjValue

        public Obj getObjValue()
        Gets this TypeReference's object handle.
        Returns:
        the object's object handle.
      • getIdxValue

        public int getIdxValue()
        Gets this TypeParameter's stack index.
        Returns:
        the object's stack index.
      • getStringValue

        public java.lang.String getStringValue()
        Gets this TypeString's string value. This method presumes the CalcSymbol if of type TypeString. Otherwise, the result is indeterminate.
        Returns:
        the object's string value.
      • getNumericValue

        public double getNumericValue()
        Gets this TypeDouble's numeric value. This method presumes the CalcSymbol if of type TypeDouble. Otherwise, the result is indeterminate.
        Returns:
        the object's numeric value.
      • getErrorValue

        public java.lang.String getErrorValue​(IntegerHolder oErrorLine,
                                              IntegerHolder oErrorCode)
        Gets this TypeError's error value. This method presumes the CalcSymbol if of type TypeError. Otherwise, the result is indeterminate.
        Parameters:
        oErrorLine - if non-null, populated with the line number of the error, in the context of syntax errors (not run-time errors).
        oErrorCode - - if non-NULL, populated with the error code of the error, in the context of syntax errors (not run-time errors).
        Returns:
        the object's error value.