Class Node

  • Direct Known Subclasses:
    NodeBinding, NodeOperation, NodeValue, NodeVariable

    public abstract class Node
    extends java.lang.Object
    The Node class is a base class for all kinds of classes describing nodes in an expression tree. It includes declarations and implementations of methods common for all node kinds.
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  Node.Kind
      The Node.Kind enumeration specifies the kind of an expression tree node.
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected Node​(Node node)
      Constructor for making copies.
      protected Node​(Node.Kind kind)
      Creates a node of the specified kind.
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      abstract Node deepCopy()
      Creates a deep copy of the current objects.
      Node deepestCopy()
      Creates a deep copy of the current object referencing user data.
      abstract DataType getDataType()
      Returns an object that describes the type of the value referred by the node.
      DataTypeId getDataTypeId()
      Returns a data type identifier describing the type of the value referred by the node.
      Node.Kind getKind()
      Returns the identifier that specifies the kind of the node.
      java.lang.Object getUserData()
      Returns user data.
      boolean isType​(DataType type)
      Checks whether the stored value has the specified type (types are compared on the DataType level).
      boolean isType​(DataType... types)
      Checks whether the expression has one of the specified types (types are compared on the DataType level).
      boolean isType​(DataTypeId typeId)
      Checks whether the expression has the specified type (types are compared on the DataTypeId level).
      boolean isType​(DataTypeId... typeIds)
      Checks whether the expression has one of the specified types (types are compared on the DataTypeId level).
      void setUserData​(java.lang.Object obj)
      Associates a user data object with the current node
      • Methods inherited from class java.lang.Object

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

      • Node

        protected Node​(Node.Kind kind)
        Creates a node of the specified kind.
        Parameters:
        kind - Node kind identifier.
        Throws:
        java.lang.IllegalArgumentException - if the parameter equals null.
      • Node

        protected Node​(Node node)
        Constructor for making copies. The fields are copied by reference because the kind field is immutable and the userData field is of an unknown type (there is no way to know how to clone it).
        Parameters:
        node - Node object to be copied.
        Throws:
        java.lang.IllegalArgumentException - if the parameter equals null.
    • Method Detail

      • deepestCopy

        public Node deepestCopy()
        Creates a deep copy of the current object referencing user data. All aggregated objects that are not readonly must be cloned.
        Returns:
        Full copy of the current node object.
      • deepCopy

        public abstract Node deepCopy()
        Creates a deep copy of the current objects. All aggregated objects that are not readonly must be cloned. This excludes user data as its type is unknown.
        Returns:
        Full copy of the current node object.
      • getKind

        public final Node.Kind getKind()
        Returns the identifier that specifies the kind of the node.
        Returns:
        A node kind identifier.
      • getDataType

        public abstract DataType getDataType()
        Returns an object that describes the type of the value referred by the node.
        Returns:
        A data type object.
      • getDataTypeId

        public final DataTypeId getDataTypeId()
        Returns a data type identifier describing the type of the value referred by the node.
        Returns:
        Data type identifier.
      • isType

        public final boolean isType​(DataTypeId typeId)
        Checks whether the expression has the specified type (types are compared on the DataTypeId level).
        Parameters:
        typeId - DataTypeId object the data type is to be compared to.
        Returns:
        true if the expression type matches the type specified by the typeId argument or false otherwise.
      • isType

        public final boolean isType​(DataTypeId... typeIds)
        Checks whether the expression has one of the specified types (types are compared on the DataTypeId level).
        Parameters:
        typeIds - List of type identifiers (DataTypeId objects) the expression type is to be compared to.
        Returns:
        true if the expression type matches one of the type identifiers specified by the typeIds argument or false otherwise.
        Throws:
        java.lang.IllegalArgumentException - if the type identifier collection is empty.
      • isType

        public final boolean isType​(DataType type)
        Checks whether the stored value has the specified type (types are compared on the DataType level).
        Parameters:
        type - DataType object the data type is to be compared to.
        Returns:
        true if the expression type matches the type specified by the type argument or false otherwise.
      • isType

        public final boolean isType​(DataType... types)
        Checks whether the expression has one of the specified types (types are compared on the DataType level).
        Parameters:
        types - List of types (DataType objects) the expression type is to be compared to.
        Returns:
        true if the expression type matches one of the types specified by the types argument or false otherwise.
        Throws:
        java.lang.IllegalArgumentException - if the type collection is empty.
      • setUserData

        public final void setUserData​(java.lang.Object obj)
        Associates a user data object with the current node
        Parameters:
        obj - User data object.
      • getUserData

        public final java.lang.Object getUserData()
        Returns user data.
        Returns:
        User data object.