Class Util


  • public class Util
    extends java.lang.Object
    Various utility methods for the iterpreter.
    Author:
    Tobias Downer
    • Constructor Summary

      Constructors 
      Constructor Description
      Util()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.String asNonQuotedRef​(Token token)
      Returns the Token as a non quoted reference.
      static java.lang.String expressionListToString​(Expression[] list)
      Returns an array of Expression objects as a comma deliminated string.
      static Expression normalize​(Expression exp)
      Normalizes the Expression by removing all NOT operators and altering the expression as appropriate.
      static TObject parseNumberToken​(Token token, boolean negative)
      Parses a NUMBER_LITERAL Token with a sign boolean.
      static FunctionDef resolveFunctionName​(java.lang.String name, Expression[] exp_list)
      Returns a Function object that represents the name and expression list (of parameters) of a function.
      static TObject toArrayParamObject​(Expression[] arr)
      Converts an expression array to an array type that can be added to an expression.
      static java.lang.Object toParamObject​(Token token, boolean upper_identifiers)
      Converts a Token which is either a STRING_LITERAL, NUMBER_LITERAL or IDENTIFIER into a Java Object.
      static TObject zeroNumber()
      Returns numeric 0
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • Util

        public Util()
    • Method Detail

      • asNonQuotedRef

        public static java.lang.String asNonQuotedRef​(Token token)
        Returns the Token as a non quoted reference. For example, a QUOTED_VARIABLE token will have the first and last '"' character removed. A QUOTED_DELIMINATED_REF will have " removed in each deliminated section. For example, '"re1"."re2"."a"' becomes 're1.re2.a" and '"re1.re2.a"' becomes 're1.re2.a'.
      • toParamObject

        public static java.lang.Object toParamObject​(Token token,
                                                     boolean upper_identifiers)
        Converts a Token which is either a STRING_LITERAL, NUMBER_LITERAL or IDENTIFIER into a Java Object. If 'upper_identifiers' is true then all identifiers are made upper case before being returned (eg. if the object returns is a Variable object).
      • zeroNumber

        public static TObject zeroNumber()
        Returns numeric 0
      • parseNumberToken

        public static TObject parseNumberToken​(Token token,
                                               boolean negative)
        Parses a NUMBER_LITERAL Token with a sign boolean.
      • toArrayParamObject

        public static TObject toArrayParamObject​(Expression[] arr)
        Converts an expression array to an array type that can be added to an expression.
      • expressionListToString

        public static java.lang.String expressionListToString​(Expression[] list)
        Returns an array of Expression objects as a comma deliminated string.
      • normalize

        public static Expression normalize​(Expression exp)
        Normalizes the Expression by removing all NOT operators and altering the expression as appropriate. For example, the expression; not ((a + b) = c and c = 5) would be normalized to; (a + b) <> c or c <> 5
      • resolveFunctionName

        public static FunctionDef resolveFunctionName​(java.lang.String name,
                                                      Expression[] exp_list)
        Returns a Function object that represents the name and expression list (of parameters) of a function. Throws an exception if the function doesn't exist.