Class ExpressionNode

    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected boolean constant
      Is the node value constant (independent of evaluation context and parameters)?
      protected java.lang.Object constant_value
      The constant value (if any).
      protected java.lang.String expressiontext
      The expression text (if any).
      protected java.lang.String[] imports
      The imports (if any).
      protected java.lang.Class static_type
      The static type (if any).
      protected java.lang.String text
      The token text (if any).
    • Constructor Summary

      Constructors 
      Constructor Description
      ExpressionNode​(jadex.javaparser.javaccimpl.ParserImpl p, int id)
      Create an expression node.
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      void appendText​(java.lang.String text)
      Append to the token text.
      boolean equals​(java.lang.Object o)
      Test if two nodes are equal.
      java.lang.Object getConstantValue()
      Get the constant value.
      java.lang.String getExpressionText()
      Get the full expression text.
      java.util.Set<java.lang.String> getParameters()
      Get the parameters used in the expression.
      java.lang.Class<?> getStaticType()
      Get the static type.
      java.lang.String getText()
      Get the expression text.
      ParameterNode[] getUnboundParameterNodes()
      Get unbound parameter nodes.
      abstract java.lang.Object getValue​(IValueFetcher fetcher)
      Evaluate the expression in the given state with respect to given parameters.
      int hashCode()
      Get the hash code for the node.
      boolean isConstant()
      Get if the node is constant.
      void precompile()
      This method should be overridden to perform all possible checks and precompute all values (e.g.
      void precompileTree()
      Precompile this node and all subnodes.
      void setConstant​(boolean constant)
      Set if the node is constant.
      void setConstantValue​(java.lang.Object constant_value)
      Set the constant value.
      void setExpressionText​(java.lang.String expressiontext)
      Get the full expression text.
      void setStaticType​(java.lang.Class static_type)
      Set the static type.
      void setText​(java.lang.String text)
      Set the token text.
      protected java.lang.String subnodeToString​(int subnode)
      Create a string for a subnode.
      protected void throwEvaluationException​(java.lang.Throwable ex)
      (Re)throw an exception that occured during evaluation and add a useful error message.
      protected void throwParseException​(java.lang.Throwable ex)
      (Re)throw an exception that occured during parsing and add a useful error message.
      java.lang.String toPlainString()
      Create a string representation of this node for dumping in a tree.
      java.lang.String toString()
      Create a string representation of this node for dumping in a tree.
      java.lang.String toString​(java.lang.String prefix)
      Create a string representation of this node for dumping in a tree.
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Field Detail

      • text

        protected java.lang.String text
        The token text (if any).
      • expressiontext

        protected java.lang.String expressiontext
        The expression text (if any).
      • imports

        protected java.lang.String[] imports
        The imports (if any).
      • static_type

        protected java.lang.Class static_type
        The static type (if any).
      • constant

        protected boolean constant
        Is the node value constant (independent of evaluation context and parameters)?
      • constant_value

        protected java.lang.Object constant_value
        The constant value (if any).
    • Constructor Detail

      • ExpressionNode

        public ExpressionNode​(jadex.javaparser.javaccimpl.ParserImpl p,
                              int id)
        Create an expression node.
        Parameters:
        p - The parser.
        id - The id.
    • Method Detail

      • setExpressionText

        public void setExpressionText​(java.lang.String expressiontext)
        Get the full expression text.
        Parameters:
        text - The expression text.
      • getExpressionText

        public java.lang.String getExpressionText()
        Get the full expression text.
        Specified by:
        getExpressionText in interface IParsedExpression
        Returns:
        The expression text.
      • setText

        public void setText​(java.lang.String text)
        Set the token text.
        Parameters:
        text - The token text.
      • appendText

        public void appendText​(java.lang.String text)
        Append to the token text.
        Parameters:
        text - The text to append.
      • setStaticType

        public void setStaticType​(java.lang.Class static_type)
        Set the static type.
        Parameters:
        static_type - The static type.
      • setConstantValue

        public void setConstantValue​(java.lang.Object constant_value)
        Set the constant value.
        Parameters:
        constant_value - The constant value.
      • getConstantValue

        public java.lang.Object getConstantValue()
        Get the constant value. The constant value of a node may be known, when it is independent of the evaluation context, and the child nodes are constant, too.
        Returns:
        The constant value.
      • setConstant

        public void setConstant​(boolean constant)
        Set if the node is constant.
        Parameters:
        constant - The constant.
      • isConstant

        public boolean isConstant()
        Get if the node is constant. The node is constant, when it is independent of the evaluation context, and the child nodes are constant, too.
        Returns:
        The constant flag.
      • toString

        public java.lang.String toString​(java.lang.String prefix)
        Create a string representation of this node for dumping in a tree.
        Overrides:
        toString in class SimpleNode
        Returns:
        A string representation of this node.
      • toPlainString

        public java.lang.String toPlainString()
        Create a string representation of this node for dumping in a tree.
        Specified by:
        toPlainString in interface Node
        Returns:
        A string representation of this node.
      • toString

        public java.lang.String toString()
        Create a string representation of this node for dumping in a tree.
        Overrides:
        toString in class SimpleNode
        Returns:
        A string representation of this node.
      • subnodeToString

        protected java.lang.String subnodeToString​(int subnode)
        Create a string for a subnode. Automatically adds braces if necessary.
        Parameters:
        subnode - The index of the subnode.
        Returns:
        The string for the subnode.
      • getText

        public java.lang.String getText()
        Get the expression text.
        Returns:
        The text.
      • getValue

        public abstract java.lang.Object getValue​(IValueFetcher fetcher)
        Evaluate the expression in the given state with respect to given parameters.
        Specified by:
        getValue in interface IParsedExpression
        Parameters:
        params - The parameters (string, value pairs), if any.
        Returns:
        The value of the term.
      • getStaticType

        public java.lang.Class<?> getStaticType()
        Get the static type. If no information about the return type of an expression is available (e.g. because it depends on the evaluation context), the static type is null.
        Specified by:
        getStaticType in interface IParsedExpression
        Returns:
        The static type.
      • getParameters

        public java.util.Set<java.lang.String> getParameters()
        Get the parameters used in the expression.
        Specified by:
        getParameters in interface IParsedExpression
      • getUnboundParameterNodes

        public ParameterNode[] getUnboundParameterNodes()
        Get unbound parameter nodes.
        Returns:
        The unbound parameter nodes.
      • precompile

        public void precompile()
        This method should be overridden to perform all possible checks and precompute all values (e.g. the static_type), which are independent of the evaluation context and parameters.
      • precompileTree

        public void precompileTree()
        Precompile this node and all subnodes.
      • throwParseException

        protected void throwParseException​(java.lang.Throwable ex)
                                    throws ParseException
        (Re)throw an exception that occured during parsing and add a useful error message.
        Parameters:
        ex - The exception to be rethrown (if any).
        Throws:
        ParseException
      • throwEvaluationException

        protected void throwEvaluationException​(java.lang.Throwable ex)
                                         throws java.lang.RuntimeException
        (Re)throw an exception that occured during evaluation and add a useful error message.
        Parameters:
        ex - The exception to be rethrown (if any).
        Throws:
        java.lang.RuntimeException
      • equals

        public boolean equals​(java.lang.Object o)
        Test if two nodes are equal.
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Get the hash code for the node.
        Overrides:
        hashCode in class java.lang.Object