/** * Handle conjunction, disjunction and negation nodes and recursively call the generic matcher on children. * * @return the boolean value of the evaluation of the sub expression */ private boolean branchMatch(Attributes attributes, BranchNode branchElement) { if (branchElement.isConjunction()) { for (ExprNode child : branchElement.getChildren()) { if (!recursiveMatch(attributes, child)) { return false; } } return true; } else if (branchElement.isDisjunction()) { for (ExprNode child : branchElement.getChildren()) { if (recursiveMatch(attributes, child)) { return true; } } return false; } else if (branchElement.isNegation()) { return !recursiveMatch(attributes, branchElement.getChild()); } else { throw new DirectoryException("unsupported branching filter element type: " + branchElement.toString()); } }
/** * Parse AND, OR and NOT nodes : * * and = '&' filterlist * or = '|' filterlist * not = '!' filter * filterlist = 1*filter * * @return */ private static ExprNode parseBranchNode( ExprNode node, String filter, Position pos ) throws ParseException { BranchNode bNode = ( BranchNode ) node; // We must have at least one filter ExprNode child = parseFilterInternal( filter, pos ); // Add the child to the node children bNode.addNode( child ); // Now, iterate recusively though all the remaining filters, if any while ( ( child = parseFilterInternal( filter, pos ) ) != null ) { // Add the child to the node children bNode.addNode( child ); } return node; }
/** * Clone the Node */ @Override public ExprNode clone() { return super.clone(); }
switch ( bnode.getOperator() ) Iterator children = bnode.getChildren().iterator(); children = bnode.getChildren().iterator(); while ( children.hasNext() ) if ( null != bnode.getChild() ) return !evaluate( bnode.getChild(), dn, entry ); throw new NamingException( "Unrecognized branch node operator: " + bnode.getOperator() );
List<ExprNode> otherChildren = otherExprNode.getChildren();
if ( bnode.isNegation() ) bnode.getChildren().remove( e.getUndefinedFilterNode() ); if ( bnode.getOperator() == BranchNode.AND ) if ( bnode.getChildren().size() < 2 ) filter = bnode.getChild(); if ( child.getChildren().size() == 0 || child.get( "undefined" ) == Boolean.TRUE ) if ( child.getChildren().size() == 1 && child.getOperator() != BranchNode.NOT ) filter = child.getChild(); BranchNode bnode = new BranchNode( BranchNode.OR ); bnode.getChildren().add( filter ); filter = bnode; bnode.getChildren().add( newLeaf );
if ( child.getChildren().size() == 0 ) if ( child.getChildren().size() == 1 && child.getOperator() != BranchNode.NOT ) filter = child.getChild(); BranchNode and = new BranchNode( BranchNode.AND ); and.addNode( scope ); and.addNode( filter ); filter = and;
for ( int ii = 0; ii < bnode.getChildren().size(); ii++ ) ExprNode child = ( ExprNode ) bnode.getChildren().get( ii ); if ( child.isLeaf() ) bnode.getChildren().remove( child ); if ( bnode.getOperator() != BranchNode.AND ) bnode.set( "undefined", Boolean.TRUE ); bnode.set( "undefined", Boolean.FALSE ); bnode.getChildren().remove( ii ); if ( bnode.getOperator() != BranchNode.AND ) bnode.set( "undefined", Boolean.TRUE ); bnode.set( "undefined", Boolean.FALSE ); for ( int ii = 0; ii < bnode.getChildren().size(); ii++ ) ExprNode unknown = ( ExprNode ) bnode.getChildren().get( ii ); if ( !unknown.isLeaf() ) if ( child.getChildren().size() == 0 || child.get( "undefined" ) == Boolean.TRUE ) bnode.getChildren().remove( child );
final List children = bnode.getChildren(); final int limit = children.size(); for ( int ii = 0; ii < limit; ii++ ) BranchNode orNode = new BranchNode( BranchNode.OR ); orNode.getChildren().add( leaf ); children.set( ii, orNode ); + leaf.getAssertionType() ); orNode.addNode( newLeaf );
BranchNode root = new BranchNode( AbstractExprNode.AND ); ExprNode node = new ScopeNode( env, effectiveBase.toString(), searchCtls.getSearchScope() ); root.getChildren().add( node ); root.getChildren().add( filter );
BranchNode filter = new BranchNode( BranchNode.OR ); filter.addNode( new SimpleNode( OC_ATTR, GROUPOFNAMES_OC, SimpleNode.EQUALITY ) ); filter.addNode( new SimpleNode( OC_ATTR, GROUPOFUNIQUENAMES_OC, SimpleNode.EQUALITY ) );
/** * Gets the recursive prefix string represent of the filter from this node * down. * * @see java.lang.Object#toString() * @return A string representing the AndNode */ public String toString() { StringBuilder buf = new StringBuilder(); buf.append( "(!" ); buf.append( super.toString() ); buf.append( getFirstChild() ); buf.append( ')' ); return buf.toString(); } }
public boolean assertCandidate( IndexRecord rec ) throws NamingException { // NOTICE THE ! HERE // The candidate is valid if it does not pass assertion. A // candidate that passes assertion is therefore invalid. return !evaluator.evaluate( node.getChild(), rec ); } };
/** * Creates an enumeration over a disjunction expression branch node. * * @param node the disjunction expression branch node */ private NamingEnumeration enumDisj( BranchNode node ) throws NamingException { ArrayList children = node.getChildren(); NamingEnumeration[] childEnumerations = new NamingEnumeration[children.size()]; // Recursively create NamingEnumerations for each child expression node for ( int ii = 0; ii < childEnumerations.length; ii++ ) { childEnumerations[ii] = enumerate( ( ExprNode ) children.get( ii ) ); } return new DisjunctionEnumeration( childEnumerations ); }
switch ( bnode.getOperator() ) Iterator children = bnode.getChildren().iterator(); children = bnode.getChildren().iterator(); while ( children.hasNext() ) if ( null != bnode.getChild() ) return !evaluate( bnode.getChild(), record ); throw new NamingException( "Unrecognized branch node operator: " + bnode.getOperator() );
BranchNode filter = new BranchNode( BranchNode.AND ); NamingEnumeration list = matchingAttributes.getAll(); filter.addNode( new PresenceNode( attr.getID() ) ); continue; filter.addNode( node );
/** * Gets the recursive prefix string represent of the filter from this node * down. * * @see java.lang.Object#toString() * @return A string representing the AndNode */ public String toString() { StringBuffer buf = new StringBuffer(); buf.append( "(&" ); buf.append( super.toString() ); for ( ExprNode child:getChildren() ) { buf.append( child ); } buf.append( ')' ); return buf.toString(); }
if ( bnode.getChildren().size() == 0 ) if ( bnode.getChildren().size() == 1 ) ( ( ExprNode ) bnode.getChildren().get( 0 ) ).set( "count", MAX ); return; final int limit = bnode.getChildren().size(); for ( int ii = 0; ii < limit; ii++ ) ExprNode child = ( ExprNode ) bnode.getChildren().get( ii ); if ( child.isLeaf() )
switch ( bnode.getOperator() ) Iterator children = bnode.getChildren().iterator(); children = bnode.getChildren().iterator(); while ( children.hasNext() ) if ( null != bnode.getChild() ) return !evaluate( bnode.getChild(), objectClasses ); throw new IllegalArgumentException( "Unrecognized branch node operator: " + bnode.getOperator() );