Package org.apache.ldap.common.filter

Examples of org.apache.ldap.common.filter.BranchNode


        {
            effectiveBase = base;
        }

        // Add the scope node using the eective base to the ilter
        BranchNode root = new BranchNode( AbstractExprNode.AND );
        ExprNode node = new ScopeNode( env, effectiveBase.toString(),
            searchCtls.getSearchScope() );
        root.getChildren().add( node );
        root.getChildren().add( filter );

        // Annotate the node with the optimizer and return search enumeration.
        optimizer.annotate( root );
        return enumerator.enumerate( root );
    }
View Full Code Here


        if ( node.isLeaf() )
        {
            return leafEvaluator.evaluate( node, record );
        }

        BranchNode bnode = ( BranchNode ) node;

        switch( bnode.getOperator() )
        {
        case( BranchNode.OR ):
            Iterator children = bnode.getChildren().iterator();
           
            while ( children.hasNext() )
            {
                ExprNode child = ( ExprNode ) children.next();
               
                if ( evaluate( child, record ) )
                {
                    return true;
                }
            }

            return false;
        case( BranchNode.AND ):
            children = bnode.getChildren().iterator();
            while ( children.hasNext() )
            {
                ExprNode child = ( ExprNode ) children.next();

                if ( ! evaluate( child, record ) )
                {
                    return false;
                }
            }

            return true;
        case( BranchNode.NOT ):
            if ( null != bnode.getChild() )
            {
                return ! evaluate( bnode.getChild(), record );
            }

            throw new NamingException( "Negation has no child: " + node );
        default:
            throw new NamingException( "Unrecognized branch node operator: "
                + bnode.getOperator() );
        }
    }
View Full Code Here

            if( exprNode.isLeaf() )
            {
                return;
            }

            BranchNode branch = ( BranchNode ) exprNode;
            ArrayList exprNodes = branch.getChildren();
            for ( int ii = 0; ii < exprNodes.size(); ii++ )
            {
                ExprNode child = ( ExprNode ) exprNodes.get(ii);
                children.add( new ASTNode( this, child ) );
            }
View Full Code Here

            if( exprNode.isLeaf() )
            {
                return;
            }

            BranchNode branch = ( BranchNode ) exprNode;
            ArrayList exprNodes = branch.getChildren();
            for ( int ii = 0; ii < exprNodes.size(); ii++ )
            {
                ExprNode child = ( ExprNode ) exprNodes.get(ii);
                children.add( new ASTNode( this, child ) );
            }
View Full Code Here

        {
            effectiveBase = base;
        }

        // Add the scope node using the eective base to the ilter
        BranchNode root = new BranchNode( AbstractExprNode.AND );
        ExprNode node = new ScopeNode( env, effectiveBase.toString(),
            searchCtls.getSearchScope() );
        root.getChildren().add( node );
        root.getChildren().add( filter );

        // Annotate the node with the optimizer and return search enumeration.
        optimizer.annotate( root );
        return enumerator.enumerate( root );
    }
View Full Code Here

        // --------------------------------------------------------------------
        //                 H A N D L E   B R A N C H   N O D E S      
        // --------------------------------------------------------------------
        else
        {
            BranchNode bnode = ( BranchNode ) node;

            switch( bnode.getOperator() )
            {
            case( BranchNode.AND ):
                count = getConjunctionScan( bnode );
                break;
            case( BranchNode.NOT ):
View Full Code Here

                throw new IllegalArgumentException( "Unknown leaf assertion" );
            }
        }
        else
        {
            BranchNode branch = ( BranchNode ) node;
           
            switch( branch.getOperator() )
            {
            case( BranchNode.AND ):
                list = enumConj( branch );
                break;
            case( BranchNode.NOT ):
View Full Code Here

        if ( node.isLeaf() )
        {
            return leafEvaluator.evaluate( node, record );
        }

        BranchNode bnode = ( BranchNode ) node;

        switch( bnode.getOperator() )
        {
        case( BranchNode.OR ):
            Iterator children = bnode.getChildren().iterator();
           
            while ( children.hasNext() )
            {
                ExprNode child = ( ExprNode ) children.next();
               
                if ( evaluate( child, record ) )
                {
                    return true;
                }
            }

            return false;
        case( BranchNode.AND ):
            children = bnode.getChildren().iterator();
            while ( children.hasNext() )
            {
                ExprNode child = ( ExprNode ) children.next();

                if ( ! evaluate( child, record ) )
                {
                    return false;
                }
            }

            return true;
        case( BranchNode.NOT ):
            if ( null != bnode.getChild() )
            {
                return ! evaluate( bnode.getChild(), record );
            }

            throw new NamingException( "Negation has no child: " + node );
        default:
            throw new NamingException( "Unrecognized branch node operator: "
                + bnode.getOperator() );
        }
    }
View Full Code Here

         * Go through the set of attributes using each attribute value pair as
         * an attribute value assertion within one big AND filter expression.
         */
        Attribute attr;
        SimpleNode node;
        BranchNode filter = new BranchNode( BranchNode.AND );
        NamingEnumeration list = matchingAttributes.getAll();

        // Loop through each attribute value pair
        while ( list.hasMore() )
        {
            attr = ( Attribute ) list.next();
           
            /*
             * According to JNDI if an attribute in the matchingAttributes
             * list does not have any values then we match for just the presence
             * of the attribute in the entry
             */
            if ( attr.size() == 0 )
            {
                filter.addNode( new PresenceNode( attr.getID() ) );

                continue;
            }
           
            /*
             * With 1 or more value we build a set of simple nodes and add them
             * to the AND node - each attribute value pair is a simple AVA node.
             */
            for ( int ii = 0; ii < attr.size(); ii++ )
            {
                Object val = attr.get( ii );
               
                // Add simpel AVA node if its value is a String
                if ( val instanceof String )
                {
                    node = new SimpleNode( attr.getID(), ( String ) val, SimpleNode.EQUALITY );

                    filter.addNode( node );
                }
            }
        }

        return getNexusProxy().search( target , getEnvironment(), filter, ctls );
View Full Code Here

        filter.accept( visitor );

        // check that after pruning we have valid branch node at the top
        if ( ! filter.isLeaf() )
        {
            BranchNode child = ( BranchNode ) filter;

            // if the remaining filter branch node has no children return an empty enumeration
            if ( child.getChildren().size() == 0 )
            {
                log.warn( "Undefined branchnode filter without child nodes not evaluted at all.  Returning empty enumeration." );
                return new EmptyEnumeration();
            }

            // now for AND & OR nodes with a single child left replace them with their child
            if ( child.getChildren().size() == 1 && child.getOperator() != BranchNode.NOT )
            {
                filter = child.getChild();
            }
        }
        return nextInterceptor.search( base, env, filter, searchCtls );
    }
View Full Code Here

TOP

Related Classes of org.apache.ldap.common.filter.BranchNode

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.