org.apache.directory.shared.ldap.filter
Class BranchNode

java.lang.Object
  extended by org.apache.directory.shared.ldap.filter.AbstractExprNode
      extended by org.apache.directory.shared.ldap.filter.BranchNode
All Implemented Interfaces:
ExprNode
Direct Known Subclasses:
AndNode, NotNode, OrNode

public class BranchNode
extends AbstractExprNode

Node representing branches within the expression tree corresponding to logical operators within the filter expression.

Version:
$Rev: 683749 $
Author:
Apache Directory Project

Field Summary
protected  java.util.List<ExprNode> children
          child node list for this branch node
 
Fields inherited from class org.apache.directory.shared.ldap.filter.AbstractExprNode
annotations, assertionType
 
Constructor Summary
protected BranchNode(AssertionType assertionType)
          Creates a BranchNode using a logical operator.
protected BranchNode(AssertionType assertionType, ExprNode... childList)
          Creates a BranchNode using a logical operator and a list of children.
protected BranchNode(AssertionType assertionType, java.util.List<ExprNode> childList)
          Creates a BranchNode using a logical operator and a list of children.
 
Method Summary
 java.lang.Object accept(FilterVisitor visitor)
          Element/node accept method for visitor pattern.
 void addNode(ExprNode node)
          Adds a child node to this branch node node
 void addNodeToHead(ExprNode node)
          Adds a child node to this branch node at the head rather than the tail.
 boolean equals(java.lang.Object other)
           
 java.util.List<ExprNode> getChildren()
          Gets the children below this BranchNode.
 ExprNode getFirstChild()
          Convenience method that gets the first child in the children array.
 int hashCode()
          (non-Javadoc)
 boolean isLeaf()
          Tests to see if this node is a leaf or branch node.
 void setChildren(java.util.List<ExprNode> list)
          Sets the list of children under this node.
 
Methods inherited from class org.apache.directory.shared.ldap.filter.AbstractExprNode
get, getAnnotations, getAssertionType, printRefinementToBuffer, set, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

children

protected java.util.List<ExprNode> children
child node list for this branch node

Constructor Detail

BranchNode

protected BranchNode(AssertionType assertionType,
                     java.util.List<ExprNode> childList)
Creates a BranchNode using a logical operator and a list of children.

Parameters:
assertionType - the node's type
childList - the child nodes under this branch node.

BranchNode

protected BranchNode(AssertionType assertionType,
                     ExprNode... childList)
Creates a BranchNode using a logical operator and a list of children.

Parameters:
assertionType - the node's type
childList - the child nodes under this branch node.

BranchNode

protected BranchNode(AssertionType assertionType)
Creates a BranchNode using a logical operator.

Parameters:
assertionType - the node's type
Method Detail

isLeaf

public final boolean isLeaf()
Description copied from class: AbstractExprNode
Tests to see if this node is a leaf or branch node.

Specified by:
isLeaf in interface ExprNode
Specified by:
isLeaf in class AbstractExprNode
Returns:
false all the time.
See Also:
ExprNode.isLeaf()

addNode

public void addNode(ExprNode node)
Adds a child node to this branch node node

Parameters:
node - the child expression to add to this branch node

addNodeToHead

public void addNodeToHead(ExprNode node)
Adds a child node to this branch node at the head rather than the tail.

Parameters:
node - the child expression to add to this branch node

getChildren

public java.util.List<ExprNode> getChildren()
Gets the children below this BranchNode. We purposefully do not clone the array list so that backends can sort the order of children using their own search optimization algorithms. We want backends and other parts of the system to be able to induce side effects on the tree structure.

Returns:
the list of child nodes under this branch node.

setChildren

public void setChildren(java.util.List<ExprNode> list)
Sets the list of children under this node.

Parameters:
list - the list of children to set.

getFirstChild

public ExprNode getFirstChild()
Convenience method that gets the first child in the children array. Its very useful for NOT nodes since they only have one child by avoiding code that looks like: ( ExprNode ) m_children.get( 0 )

Returns:
the first child

accept

public final java.lang.Object accept(FilterVisitor visitor)
Description copied from interface: ExprNode
Element/node accept method for visitor pattern.

Parameters:
visitor - the filter expression tree structure visitor TODO - what is this modified element ?
Returns:
The modified element
See Also:
ExprNode.accept( org.apache.directory.shared.ldap.filter.FilterVisitor)

hashCode

public int hashCode()
(non-Javadoc)

Overrides:
hashCode in class AbstractExprNode
Returns:
the instance's hash code
See Also:
Object.hashCode()

equals

public boolean equals(java.lang.Object other)
Overrides:
equals in class AbstractExprNode
Returns:
true if both objects are equal
See Also:
Object.equals(Object)


Copyright © 2003-2011 Apache Software Foundation. All Rights Reserved.