com.ibm.tivoli.maximo.report.expr

Class ExprParser

  • java.lang.Object
    • com.ibm.tivoli.maximo.report.expr.ExprParser


  • public class ExprParser
    extends java.lang.Object
    An Expression Parser parses an expression, such as 'FIELDA+DateDiff(Now(), Later())+10' into a Parse Tree of Nodes that can be navigated and validated. Parsers are NOT THREAD SAFE so a new parser must be created for parsing instance. The purpose of the Exprssion Parser is NOT to validate expression, but rather to provide a tokenized parse tree of the elements that make up the expression. Other tasks can later validate parsed elements if they want, looking for specific element types, etc. Using a parser is a simple as using.
     Node root = ExprParser.parse("fielda * 12 + fieldb");
     
    Once you have root Node, you can the iterator over the nodes, or create a "Visitor" and have a visitor visit each node in the expression.
    • Constructor Summary

      Constructors 
      Constructor and Description
      ExprParser() 
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      void addChild(Node parent, Node child) 
      static Node parse(java.lang.String expression)
      Given an expression, return a parse tree of the expression.
      static Node parse(java.lang.String expression, ExprParser.ParserHelper parserHelper)
      Given an expression, return a parse tree of the expression.
      static Node parse(java.lang.String expression, com.ibm.icu.util.ULocale locale)
      Given an expression, return a parse tree of the expression.
      static Node parse(java.lang.String expression, com.ibm.icu.util.ULocale locale, ExprParser.ParserHelper parserHelper)
      Given an expression, return a parse tree of the expression.
      Node parseExpression(java.lang.String str, com.ibm.icu.util.ULocale locale, ExprParser.ParserHelper helper)
      Parses an expression using a given decimal separator.
      • Methods inherited from class java.lang.Object

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

      • ExprParser

        public ExprParser()
    • Method Detail

      • parseExpression

        public Node parseExpression(java.lang.String str,
                                    com.ibm.icu.util.ULocale locale,
                                    ExprParser.ParserHelper helper)
                             throws MXException
        Parses an expression using a given decimal separator. Because expressions can contain literal numbers we need to know what a numeric decimal separator looks like so that we can effectively parse out number literals as number types.
        Parameters:
        str -
        decimalSeparator -
        Returns:
        Throws:
        MXException
      • addChild

        public void addChild(Node parent,
                             Node child)
      • parse

        public static Node parse(java.lang.String expression)
                          throws MXException
        Given an expression, return a parse tree of the expression. Will assume a "." as the decimal separator
        Parameters:
        expression -
        Returns:
        Throws:
        MXException
      • parse

        public static Node parse(java.lang.String expression,
                                 com.ibm.icu.util.ULocale locale)
                          throws MXException
        Given an expression, return a parse tree of the expression. Will use the decimal separator for the given locale
        Parameters:
        expression -
        Returns:
        Throws:
        MXException
      • parse

        public static Node parse(java.lang.String expression,
                                 com.ibm.icu.util.ULocale locale,
                                 ExprParser.ParserHelper parserHelper)
                          throws MXException
        Given an expression, return a parse tree of the expression. Will use the decimal separator for the given locale
        Parameters:
        expression -
        Returns:
        Throws:
        MXException
      • parse

        public static Node parse(java.lang.String expression,
                                 ExprParser.ParserHelper parserHelper)
                          throws MXException
        Given an expression, return a parse tree of the expression. Will assume a "." as the decimal separator
        Parameters:
        expression -
        Returns:
        Throws:
        MXException