org.apache.jackrabbit.core.query
Class NAryQueryNode

java.lang.Object
  extended byorg.apache.jackrabbit.core.query.QueryNode
      extended byorg.apache.jackrabbit.core.query.NAryQueryNode
Direct Known Subclasses:
AndQueryNode, LocationStepQueryNode, NotQueryNode, OrQueryNode, PathQueryNode

public abstract class NAryQueryNode
extends QueryNode

Defines an abstract query node for nodes that have child nodes.


Field Summary
protected  List operands
          The list of operands / children
 
Fields inherited from class org.apache.jackrabbit.core.query.QueryNode
TYPE_AND, TYPE_DEREF, TYPE_EXACT, TYPE_LOCATION, TYPE_NODETYPE, TYPE_NOT, TYPE_OR, TYPE_ORDER, TYPE_PATH, TYPE_RELATION, TYPE_ROOT, TYPE_TEXTSEARCH
 
Constructor Summary
NAryQueryNode(QueryNode parent)
          Creates a new NAryQueryNode with a reference to a parent QueryNode.
NAryQueryNode(QueryNode parent, QueryNode[] operands)
          Creates a new NAryQueryNode with a reference to a parent QueryNode and initial operands.
 
Method Summary
 Object[] acceptOperands(QueryNodeVisitor visitor, Object data)
          Helper class to accept a visitor for all operands of this NAryQueryNode.
 void addOperand(QueryNode operand)
          Adds a new operand (child node) to this query node.
 boolean equals(Object obj)
          Returns true if obj is the same type of QueryNode as this node and is equal to this node.
 int getNumOperands()
          Returns the number of operands.
 QueryNode[] getOperands()
          Returns an array of currently set QueryNode operands of this QueryNode.
 boolean removeOperand(QueryNode operand)
          Removes an operand (child node) from this query node.
 
Methods inherited from class org.apache.jackrabbit.core.query.QueryNode
accept, dump, getParent, getType
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

operands

protected List operands
The list of operands / children

Constructor Detail

NAryQueryNode

public NAryQueryNode(QueryNode parent)
Creates a new NAryQueryNode with a reference to a parent QueryNode.

Parameters:
parent - the parent node.

NAryQueryNode

public NAryQueryNode(QueryNode parent,
                     QueryNode[] operands)
Creates a new NAryQueryNode with a reference to a parent QueryNode and initial operands.

Parameters:
parent - the parent node.
operands - child nodes of this NAryQueryNode.
Method Detail

addOperand

public void addOperand(QueryNode operand)
Adds a new operand (child node) to this query node.

Parameters:
operand - the child QueryNode to add.

removeOperand

public boolean removeOperand(QueryNode operand)
Removes an operand (child node) from this query node.

Parameters:
operand - the child to remove.
Returns:
true if the operand was in the list of child nodes and has been removed; false if this node does not contain operand as a child node.

getOperands

public QueryNode[] getOperands()
Returns an array of currently set QueryNode operands of this QueryNode. Returns an empty array if no operands are set.

Returns:
currently set QueryNode operands.

getNumOperands

public int getNumOperands()
Returns the number of operands.

Returns:
the number of operands.

acceptOperands

public Object[] acceptOperands(QueryNodeVisitor visitor,
                               Object data)
Helper class to accept a visitor for all operands of this NAryQueryNode.

Parameters:
visitor - the visitor to call back.
data - arbitrary data for the visitor.
Returns:
the return values of the visitor.visit() calls.

equals

public boolean equals(Object obj)
Description copied from class: QueryNode
Returns true if obj is the same type of QueryNode as this node and is equal to this node.

Specified by:
equals in class QueryNode
Parameters:
obj - the reference object with which to compare.
Returns:
true if obj is equal to this; false otherwise.


Copyright © 2004-2006 The Apache Software Foundation. All Rights Reserved.