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

java.lang.Object
  extended byorg.apache.directory.shared.ldap.filter.AbstractExprNode
      extended byorg.apache.directory.shared.ldap.filter.BranchNode
All Implemented Interfaces:
ExprNode

public class BranchNode
extends AbstractExprNode

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

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

Field Summary
 
Fields inherited from class org.apache.directory.shared.ldap.filter.AbstractExprNode
AND, APPROXIMATE, ASSERTION, EQUALITY, EXTENSIBLE, GREATEREQ, LESSEQ, NOT, OR, PRESENCE, SCOPE, SUBSTRING
 
Constructor Summary
BranchNode(int an_operator)
          Creates a BranchNode using a logical operator.
BranchNode(int an_operator, java.util.ArrayList a_childList)
          Creates a BranchNode using a logical operator and a list of children.
 
Method Summary
 void accept(FilterVisitor a_visitor)
          Element/node accept method for visitor pattern.
 void addNode(ExprNode a_node)
          Adds a child node to this branch node if it allows it.
 void addNodeToHead(ExprNode a_node)
          Adds a child node to this branch node if it allows it at the head rather than the tail.
 boolean equals(java.lang.Object other)
           
 ExprNode getChild()
          Convenience method that gets the first child in the children array.
 java.util.ArrayList getChildren()
          Gets the children below this BranchNode.
 int getOperator()
          Gets the operator for this branch node.
static java.lang.String getOperatorString(int a_operator)
          Gets a human readable representation for the operators: AND for '&', OR for '|' and NOT for '!'.
 boolean isConjunction()
          Tests whether or not this node is a conjunction (a AND'ed branch).
 boolean isDisjunction()
          Tests whether or not this node is a disjunction (a OR'ed branch).
 boolean isLeaf()
          Tests to see if this node is a leaf or branch node.
 boolean isNegation()
          Tests whether or not this node is a negation (a NOT'ed branch).
 java.lang.StringBuffer printToBuffer(java.lang.StringBuffer a_buf)
          Recursively prints the String representation of this node and all its descendents to a buffer.
 java.lang.String toString()
          Gets the recursive prefix string represent of the filter from this node down.
 
Methods inherited from class org.apache.directory.shared.ldap.filter.AbstractExprNode
get, getAnnotations, getAssertionType, getOperationString, set
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

BranchNode

public BranchNode(int an_operator,
                  java.util.ArrayList a_childList)
Creates a BranchNode using a logical operator and a list of children.

Parameters:
an_operator - the logical operator to use for this branch node.
a_childList - the child nodes under this branch node.

BranchNode

public BranchNode(int an_operator)
Creates a BranchNode using a logical operator.

Parameters:
an_operator - the logical operator to use for this branch node.
Method Detail

addNode

public void addNode(ExprNode a_node)
Adds a child node to this branch node if it allows it. Some branch nodes like the negation node does not allow more than one child. An attempt to add more than one node to a negation branch node will result in an IllegalStateException.

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

addNodeToHead

public void addNodeToHead(ExprNode a_node)
Adds a child node to this branch node if it allows it at the head rather than the tail. Some branch nodes like the negation node does not allow more than one child. An attempt to add more than one node to a negation branch node will result in an IllegalStateException.

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

isLeaf

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

Returns:
false all the time.
See Also:
ExprNode.isLeaf()

getChildren

public java.util.ArrayList 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.

getChild

public ExprNode getChild()
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

getOperator

public int getOperator()
Gets the operator for this branch node.

Returns:
the operator constant.

isDisjunction

public boolean isDisjunction()
Tests whether or not this node is a disjunction (a OR'ed branch).

Returns:
true if the operation is a OR, false otherwise.

isConjunction

public boolean isConjunction()
Tests whether or not this node is a conjunction (a AND'ed branch).

Returns:
true if the operation is a AND, false otherwise.

isNegation

public final boolean isNegation()
Tests whether or not this node is a negation (a NOT'ed branch).

Returns:
true if the operation is a NOT, false otherwise.

printToBuffer

public java.lang.StringBuffer printToBuffer(java.lang.StringBuffer a_buf)
Recursively prints the String representation of this node and all its descendents to a buffer.

Parameters:
a_buf - the buffer to append to.
See Also:
ExprNode.printToBuffer(java.lang.StringBuffer)

getOperatorString

public static java.lang.String getOperatorString(int a_operator)
Gets a human readable representation for the operators: AND for '&', OR for '|' and NOT for '!'.

Parameters:
a_operator - the operator constant.
Returns:
one of the strings AND, OR, or NOT.

toString

public java.lang.String toString()
Gets the recursive prefix string represent of the filter from this node down.

See Also:
Object.toString()

accept

public void accept(FilterVisitor a_visitor)
Description copied from interface: ExprNode
Element/node accept method for visitor pattern.

Parameters:
a_visitor - the filter expression tree structure visitor
See Also:
ExprNode.accept( org.apache.directory.shared.ldap.filter.FilterVisitor)

equals

public boolean equals(java.lang.Object other)
Overrides:
equals in class AbstractExprNode


Copyright © 2003-2006 . All Rights Reserved.