/** * Handle attribute presence check (eg: <tt>(attr1=*)</tt>) */ private boolean presenceMatch(Attributes attributes, PresenceNode presenceElement) { return attributes.get(presenceElement.getAttribute()) != null; }
/** * @see java.lang.Object#toString() * @return A string representing the AndNode */ public String toString() { StringBuilder buf = new StringBuilder(); buf.append( '(' ).append( getAttribute() ).append( "=*" ); buf.append( super.toString() ); buf.append( ')' ); return buf.toString(); } }
/** * Gets the number of entries that would be returned by a presence node * assertion. Leverages the existance system index for scan counts. * * @param node the presence node * @return the number of entries matched for the presence of an attribute * @throws NamingException if errors result */ private BigInteger getPresenceScan( PresenceNode node ) throws NamingException { if ( db.hasUserIndexOn( node.getAttribute() ) ) { Index idx = db.getExistanceIndex(); int count = idx.count( node.getAttribute() ); return BigInteger.valueOf( count ); } return MAX; }
/** * Returns an enumeration over candidates that satisfy a presence attribute * value assertion. * * @param node the presence AVA node * @return an enumeration over the index records matching the AVA * @throws NamingException if there is a failure while accessing the db */ private NamingEnumeration enumPresence( final PresenceNode node ) throws NamingException { if ( db.hasUserIndexOn( node.getAttribute() ) ) { Index idx = db.getExistanceIndex(); return idx.listIndices( node.getAttribute() ); } return nonIndexedScan( node ); }
private static FilterExpression buildExpression(ExprNode node) { if (node instanceof AndNode) { return new AndExpression(buildExpressions(((AndNode)node).getChildren())); } else if (node instanceof OrNode) { return new OrExpression(buildExpressions(((OrNode)node).getChildren())); } else if (node instanceof NotNode) { return new NotExpression(buildExpression(((NotNode)node).getFirstChild())); } else if (node instanceof EqualityNode) { EqualityNode equalityNode = (EqualityNode)node; return new EqualityExpression(equalityNode.getAttribute(), equalityNode.getValue().toString()); } else if (node instanceof PresenceNode) { return new PresenceExpression(((PresenceNode)node).getAttribute()); } else { throw new UnsupportedOperationException("Node type " + node.getClass().getSimpleName() + " not supported"); } }
private static FilterExpression buildExpression(ExprNode node) { if (node instanceof AndNode) { return new AndExpression(buildExpressions(((AndNode)node).getChildren())); } else if (node instanceof OrNode) { return new OrExpression(buildExpressions(((OrNode)node).getChildren())); } else if (node instanceof NotNode) { return new NotExpression(buildExpression(((NotNode)node).getFirstChild())); } else if (node instanceof EqualityNode) { EqualityNode equalityNode = (EqualityNode)node; return new EqualityExpression(equalityNode.getAttribute(), equalityNode.getValue().toString()); } else if (node instanceof PresenceNode) { return new PresenceExpression(((PresenceNode)node).getAttribute()); } else { throw new UnsupportedOperationException("Node type " + node.getClass().getSimpleName() + " not supported"); } }
private static FilterExpression buildExpression(ExprNode node) { if (node instanceof AndNode) { return new AndExpression(buildExpressions(((AndNode)node).getChildren())); } else if (node instanceof OrNode) { return new OrExpression(buildExpressions(((OrNode)node).getChildren())); } else if (node instanceof NotNode) { return new NotExpression(buildExpression(((NotNode)node).getFirstChild())); } else if (node instanceof EqualityNode) { EqualityNode equalityNode = (EqualityNode)node; return new EqualityExpression(equalityNode.getAttribute(), equalityNode.getValue().toString()); } else if (node instanceof PresenceNode) { return new PresenceExpression(((PresenceNode)node).getAttribute()); } else { throw new UnsupportedOperationException("Node type " + node.getClass().getSimpleName() + " not supported"); } }
/** * @see Evaluator#evaluate(ExprNode, String, Attributes) */ public boolean evaluate( ExprNode node, String dn, Attributes entry ) throws NamingException { if ( node instanceof ScopeNode ) { return scopeEvaluator.evaluate( node, dn, entry ); } switch ( ( ( LeafNode ) node ).getAssertionType() ) { case ( LeafNode.APPROXIMATE ): return evalEquality( ( SimpleNode ) node, entry ); case ( LeafNode.EQUALITY ): return evalEquality( ( SimpleNode ) node, entry ); case ( LeafNode.EXTENSIBLE ): throw new NotImplementedException(); case ( LeafNode.GREATEREQ ): return evalGreater( ( SimpleNode ) node, entry, true ); case ( LeafNode.LESSEQ ): return evalGreater( ( SimpleNode ) node, entry, false ); case ( LeafNode.PRESENCE ): String attrId = ( ( PresenceNode ) node ).getAttribute(); return evalPresence( attrId, entry ); case ( LeafNode.SUBSTRING ): return substringEvaluator.evaluate( node, dn, entry ); default: throw new NamingException( "Unrecognized leaf node type: " + ( ( LeafNode ) node ).getAssertionType() ); } }
/** * @see org.apache.directory.server.core.partition.impl.btree.Evaluator#evaluate(ExprNode, IndexRecord) */ public boolean evaluate( ExprNode node, IndexRecord record ) throws NamingException { if ( node instanceof ScopeNode ) { return scopeEvaluator.evaluate( node, record ); } switch ( ( ( LeafNode ) node ).getAssertionType() ) { case ( LeafNode.APPROXIMATE ): return evalEquality( ( SimpleNode ) node, record ); case ( LeafNode.EQUALITY ): return evalEquality( ( SimpleNode ) node, record ); case ( LeafNode.EXTENSIBLE ): throw new NotImplementedException(); case ( LeafNode.GREATEREQ ): return evalGreater( ( SimpleNode ) node, record, true ); case ( LeafNode.LESSEQ ): return evalGreater( ( SimpleNode ) node, record, false ); case ( LeafNode.PRESENCE ): String attrId = ( ( PresenceNode ) node ).getAttribute(); return evalPresence( attrId, record ); case ( LeafNode.SUBSTRING ): return substringEvaluator.evaluate( node, record ); default: throw new NamingException( "Unrecognized leaf node type: " + ( ( LeafNode ) node ).getAssertionType() ); } }
pnode.setAttribute( registry.getOid( pnode.getAttribute() ) ); log.error( "Failed to normalize filter node attribute: " + pnode.getAttribute(), e ); RuntimeException rte = new RuntimeException( e.getMessage() ); rte.initCause( e );
boolean isSearchAll = ( ( PresenceNode ) filter ).getAttribute().equalsIgnoreCase( "2.5.4.0" );
if ( node.getAttribute().equalsIgnoreCase( "2.5.4.0" ) )
((PresentFilter)filter).setAttributeDescription( ((PresenceNode)exprNode).getAttribute() );