Class ExpNode

java.lang.Object
com.j_spaces.jdbc.parser.ExpNode
All Implemented Interfaces:
SmartExternalizable, Externalizable, Serializable, Cloneable
Direct Known Subclasses:
AbstractInNode, AndNode, ContainsNode, EqualNode, GTENode, GTNode, IsNullNode, LikeNode, LTENode, LTNode, NotEqualNode, NotLikeNode, OrNode, RelationNode, RLikeNode, ValueNode

public abstract class ExpNode extends Object implements Cloneable, SmartExternalizable
This is the main expression node. it holds to children, left and right, and has a few abstract method that all subclasses must implement.
Author:
Michael Mitrani, 2Train4
See Also:
  • Field Details

  • Constructor Details

    • ExpNode

      public ExpNode()
      Empty constructor.
    • ExpNode

      public ExpNode(ExpNode leftChild, ExpNode rightChild)
      Parameters:
      leftChild - The left child
      rightChild - The right child
  • Method Details

    • setLeftChild

      public void setLeftChild(ExpNode leftChild)
      Set the left child.
    • setRightChild

      public void setRightChild(ExpNode rightChild)
      Set the right child.
    • getLeftChild

      public ExpNode getLeftChild()
      Returns:
      The left child
    • getRightChild

      public ExpNode getRightChild()
      Returns:
      The right child
    • forEachChild

      public void forEachChild(java.util.function.Consumer<ExpNode> consumer)
      Applies the consumer on each non-null child.
    • traverse

      public void traverse(java.util.function.Consumer<ExpNode> consumer)
      Applies the consumer on this node and its children recursively
    • traverseReverse

      public void traverseReverse(java.util.function.Consumer<ExpNode> consumer)
      Applies the consumer on this node and its children recursively in reverse (children before parent)
    • reverse

      public Collection<ExpNode> reverse()
      Generates a reverse tree/stack ensuring each node's children are popped before the node.
    • prepareValues

      public void prepareValues(Object[] values) throws SQLException
      PreparedNodes will set their values through this methods. this one just calls the prepareValues on the children
      Throws:
      SQLException
    • prepareTemplateValues

      public String prepareTemplateValues(TreeMap values, String colName) throws SQLException
      PreparedNodes will set their values through this methods. this one just calls the prepareValues on the children. This method will be used only for SQLTemplate.
      Throws:
      SQLException
    • isValidCompare

      public abstract boolean isValidCompare(Object ob1, Object ob2)
      Operator nodes implement this method to return whether two objects satisfy the given condition.
      Returns:
      true if the two given objects satisfy the condition
    • isJoined

      public boolean isJoined()
      is there somewhere in the tree a join condition.
    • newInstance

      public abstract ExpNode newInstance()
      Prototype method - Create new instance of the class
    • clone

      public Object clone()
      Override the clone method.
      Overrides:
      clone in class Object
    • accept

      public abstract void accept(QueryTemplateBuilder builder) throws SQLException
      Accept the query builder Default implementation returns null - no QueryTemplatePacket is defined
      Throws:
      SQLException
    • accept

      public void accept(IQueryExecutor executor, ISpaceProxy space, Transaction txn, int readModifier, int max) throws SQLException
      Accept the query executor
      Throws:
      SQLException
    • getTemplate

      public QueryTemplatePacket getTemplate()
    • setTemplate

      public void setTemplate(QueryTemplatePacket template)
    • toString

      public String toString(String op)
      Returns:
      op string
    • createIndex

      public EntriesCursor createIndex(QueryTableData queryTableData, IQueryResultSet<IEntryPacket> tableEntries)
    • createJoinIndex

      public boolean createJoinIndex(QueryTableData tableData)
      Returns:
      true if created join index
    • isInnerQuery

      public boolean isInnerQuery()
      Gets whether this node has a child which is an inner query node
    • isContainsItemNode

      public boolean isContainsItemNode()
    • isContainsItemsRootNode

      public boolean isContainsItemsRootNode()
    • validateInnerQueryResult

      public void validateInnerQueryResult() throws SQLException
      Validates inner query result size (this method is only called after executing the inner query) Default validation only permits a single result from inner query.
      Throws:
      SQLException
    • writeExternal

      public void writeExternal(ObjectOutput out) throws IOException
      Specified by:
      writeExternal in interface Externalizable
      Throws:
      IOException
    • readExternal

      public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
      Specified by:
      readExternal in interface Externalizable
      Throws:
      IOException
      ClassNotFoundException