Package org.apache.ldap.common.filter

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


    public NamingEnumeration enumerate( final ExprNode node )
        throws NamingException
    {
        RE regex = null;
        Index idx = null;
        final SubstringNode snode = ( SubstringNode ) node;
        AttributeType type = attributeTypeRegistry.lookup( snode.getAttribute() );
        Normalizer normalizer = type.getSubstr().getNormalizer();

        if ( db.hasUserIndexOn( snode.getAttribute() ) )
        {
            /*
             * Build out regex in this block so we do not do it twice in the
             * evaluator if there is no index on the attribute of the substr ava
             */
            try
            {
                regex = snode.getRegex( normalizer );
            }
            catch ( RESyntaxException e )
            {
                NamingException ne = new NamingException( "SubstringNode '"
                    + node + "' had incorrect syntax" );
                ne.setRootCause( e );
                throw ne;
            }

            /*
             * Get the user index and return an index enumeration using the the
             * compiled regular expression.  Try to constrain even further if
             * an initial term is available in the substring expression.
             */
            idx = db.getUserIndex( snode.getAttribute() );
            if ( null == snode.getInitial() )
            {
                return idx.listIndices( regex );
            }
            else
            {
                return idx.listIndices( regex, snode.getInitial() );
            }
        }
       
        /*
         * From this point on we are dealing with an enumeration over entries
View Full Code Here


     */
    public boolean evaluate( ExprNode node, IndexRecord record )
        throws NamingException
    {
        RE regex = null;
        SubstringNode snode = ( SubstringNode ) node;
        String oid = oidRegistry.getOid( snode.getAttribute() );
        AttributeType type = attributeTypeRegistry.lookup( oid );
        Normalizer normalizer = type.getSubstr().getNormalizer();

        if ( db.hasUserIndexOn( snode.getAttribute() ) )
        {
            Index idx = db.getUserIndex( snode.getAttribute() );
       
            /*
             * Note that this is using the reverse half of the index giving a
             * considerable performance improvement on this kind of operation.
             * Otherwise we would have to scan the entire index if there were
             * no reverse lookups.
             */
       
            NamingEnumeration list = idx.listReverseIndices( record.getEntryId() );

            // compile the regular expression to search for a matching attribute
            try
            {
                regex = snode.getRegex( normalizer );
            }
            catch ( RESyntaxException e )
            {
                NamingException ne = new NamingException( "SubstringNode '"
                    + node + "' had " + "incorrect syntax" );
                ne.setRootCause( e );
                throw ne;
            }

            // cycle through the attribute values testing for a match
            while ( list.hasMore() )
            {
                IndexRecord rec = ( IndexRecord ) list.next();
           
                // once match is found cleanup and return true
                if ( regex.match( ( String ) rec.getIndexKey() ) )
                {
                    list.close();
                    return true;
                }
            }

            // we fell through so a match was not found - assertion was false.
            return false;
        }

        // --------------------------------------------------------------------
        // Index not defined beyond this point
        // --------------------------------------------------------------------
       
        // resusitate the entry if it has not been and set entry in IndexRecord
        if ( null == record.getAttributes() )
        {
            Attributes attrs = db.lookup( record.getEntryId() );
            record.setAttributes( attrs );
        }
       
        // get the attribute
        Attribute attr = record.getAttributes().get( snode.getAttribute() );
       
        // if the attribute does not exist just return false
        if ( null == attr )
        {
            return false;
        }

        // compile the regular expression to search for a matching attribute
        try
        {
            regex = snode.getRegex( normalizer );
        }
        catch ( RESyntaxException e )
        {
            NamingException ne = new NamingException( "SubstringNode '"
                + node + "' had " + "incorrect syntax" );
View Full Code Here

     */
    public boolean evaluate( ExprNode node, IndexRecord record )
        throws NamingException
    {
        RE regex = null;
        SubstringNode snode = ( SubstringNode ) node;
        String oid = oidRegistry.getOid( snode.getAttribute() );
        AttributeType type = attributeTypeRegistry.lookup( oid );
        Normalizer normalizer = type.getSubstr().getNormalizer();

        if ( db.hasUserIndexOn( snode.getAttribute() ) )
        {
            Index idx = db.getUserIndex( snode.getAttribute() );
       
            /*
             * Note that this is using the reverse half of the index giving a
             * considerable performance improvement on this kind of operation.
             * Otherwise we would have to scan the entire index if there were
             * no reverse lookups.
             */
       
            NamingEnumeration list = idx.listReverseIndices( record.getEntryId() );

            // compile the regular expression to search for a matching attribute
            try
            {
                regex = snode.getRegex( normalizer );
            }
            catch ( RESyntaxException e )
            {
                NamingException ne = new NamingException( "SubstringNode '"
                    + node + "' had " + "incorrect syntax" );
                ne.setRootCause( e );
                throw ne;
            }

            // cycle through the attribute values testing for a match
            while ( list.hasMore() )
            {
                IndexRecord rec = ( IndexRecord ) list.next();
           
                // once match is found cleanup and return true
                if ( regex.match( ( String ) rec.getIndexKey() ) )
                {
                    list.close();
                    return true;
                }
            }

            // we fell through so a match was not found - assertion was false.
            return false;
        }

        // --------------------------------------------------------------------
        // Index not defined beyond this point
        // --------------------------------------------------------------------
       
        // resusitate the entry if it has not been and set entry in IndexRecord
        if ( null == record.getAttributes() )
        {
            Attributes attrs = db.lookup( record.getEntryId() );
            record.setAttributes( attrs );
        }
       
        // get the attribute
        Attribute attr = record.getAttributes().get( snode.getAttribute() );
       
        // if the attribute does not exist just return false
        if ( null == attr )
        {
            return false;
        }

        // compile the regular expression to search for a matching attribute
        try
        {
            regex = snode.getRegex( normalizer );
        }
        catch ( RESyntaxException e )
        {
            NamingException ne = new NamingException( "SubstringNode '"
                + node + "' had " + "incorrect syntax" );
View Full Code Here

    public NamingEnumeration enumerate( final ExprNode node )
        throws NamingException
    {
        RE regex = null;
        Index idx = null;
        final SubstringNode snode = ( SubstringNode ) node;
        AttributeType type = attributeTypeRegistry.lookup( snode.getAttribute() );
        Normalizer normalizer = type.getSubstr().getNormalizer();

        if ( db.hasUserIndexOn( snode.getAttribute() ) )
        {
            /*
             * Build out regex in this block so we do not do it twice in the
             * evaluator if there is no index on the attribute of the substr ava
             */
            try
            {
                regex = snode.getRegex( normalizer );
            }
            catch ( RESyntaxException e )
            {
                NamingException ne = new NamingException( "SubstringNode '"
                    + node + "' had incorrect syntax" );
                ne.setRootCause( e );
                throw ne;
            }

            /*
             * Get the user index and return an index enumeration using the the
             * compiled regular expression.  Try to constrain even further if
             * an initial term is available in the substring expression.
             */
            idx = db.getUserIndex( snode.getAttribute() );
            if ( null == snode.getInitial() )
            {
                return idx.listIndices( regex );
            }
            else
            {
                return idx.listIndices( regex, snode.getInitial() );
            }
        }
       
        /*
         * From this point on we are dealing with an enumeration over entries
View Full Code Here

     */
    public boolean evaluate( ExprNode node, String dn, Attributes entry )
        throws NamingException
    {
        RE regex = null;
        SubstringNode snode = ( SubstringNode ) node;
        String oid = oidRegistry.getOid( snode.getAttribute() );
        AttributeType type = attributeTypeRegistry.lookup( oid );
        Normalizer normalizer = type.getSubstr().getNormalizer();

        // get the attribute
        Attribute attr = entry.get( snode.getAttribute() );
       
        // if the attribute does not exist just return false
        if ( null == attr )
        {
            return false;
        }

        // compile the regular expression to search for a matching attribute
        try
        {
            regex = snode.getRegex( normalizer );
        }
        catch ( RESyntaxException e )
        {
            NamingException ne = new NamingException( "SubstringNode '"
                + node + "' had " + "incorrect syntax" );
View Full Code Here

     */
    public boolean evaluate( ExprNode node, IndexRecord record )
        throws NamingException
    {
        RE regex = null;
        SubstringNode snode = ( SubstringNode ) node;
        String oid = oidRegistry.getOid( snode.getAttribute() );
        AttributeType type = attributeTypeRegistry.lookup( oid );
        Normalizer normalizer = type.getSubstr().getNormalizer();

        if ( db.hasUserIndexOn( snode.getAttribute() ) )
        {
            Index idx = db.getUserIndex( snode.getAttribute() );
       
            /*
             * Note that this is using the reverse half of the index giving a
             * considerable performance improvement on this kind of operation.
             * Otherwise we would have to scan the entire index if there were
             * no reverse lookups.
             */
       
            NamingEnumeration list = idx.listReverseIndices( record.getEntryId() );

            // compile the regular expression to search for a matching attribute
            try
            {
                regex = snode.getRegex( normalizer );
            }
            catch ( RESyntaxException e )
            {
                NamingException ne = new NamingException( "SubstringNode '"
                    + node + "' had " + "incorrect syntax" );
                ne.setRootCause( e );
                throw ne;
            }

            // cycle through the attribute values testing for a match
            while ( list.hasMore() )
            {
                IndexRecord rec = ( IndexRecord ) list.next();
           
                // once match is found cleanup and return true
                if ( regex.match( ( String ) rec.getIndexKey() ) )
                {
                    list.close();
                    return true;
                }
            }

            // we fell through so a match was not found - assertion was false.
            return false;
        }

        // --------------------------------------------------------------------
        // Index not defined beyond this point
        // --------------------------------------------------------------------
       
        // resusitate the entry if it has not been and set entry in IndexRecord
        if ( null == record.getAttributes() )
        {
            Attributes attrs = db.lookup( record.getEntryId() );
            record.setAttributes( attrs );
        }
       
        // get the attribute
        Attribute attr = record.getAttributes().get( snode.getAttribute() );
       
        // if the attribute does not exist just return false
        if ( null == attr )
        {
            return false;
        }

        // compile the regular expression to search for a matching attribute
        try
        {
            regex = snode.getRegex( normalizer );
        }
        catch ( RESyntaxException e )
        {
            NamingException ne = new NamingException( "SubstringNode '"
                + node + "' had " + "incorrect syntax" );
View Full Code Here

    public NamingEnumeration enumerate( final ExprNode node )
        throws NamingException
    {
        RE regex = null;
        Index idx = null;
        final SubstringNode snode = ( SubstringNode ) node;
        AttributeType type = attributeTypeRegistry.lookup( snode.getAttribute() );
        Normalizer normalizer = type.getSubstr().getNormalizer();

        if ( db.hasUserIndexOn( snode.getAttribute() ) )
        {
            /*
             * Build out regex in this block so we do not do it twice in the
             * evaluator if there is no index on the attribute of the substr ava
             */
            try
            {
                regex = snode.getRegex( normalizer );
            }
            catch ( RESyntaxException e )
            {
                NamingException ne = new NamingException( "SubstringNode '"
                    + node + "' had incorrect syntax" );
                ne.setRootCause( e );
                throw ne;
            }

            /*
             * Get the user index and return an index enumeration using the the
             * compiled regular expression.  Try to constrain even further if
             * an initial term is available in the substring expression.
             */
            idx = db.getUserIndex( snode.getAttribute() );
            if ( null == snode.getInitial() )
            {
                return idx.listIndices( regex );
            }
            else
            {
                return idx.listIndices( regex, snode.getInitial() );
            }
        }
       
        /*
         * From this point on we are dealing with an enumeration over entries
View Full Code Here

     */
    public boolean evaluate( ExprNode node, IndexRecord record )
        throws NamingException
    {
        RE regex = null;
        SubstringNode snode = ( SubstringNode ) node;
        String oid = oidRegistry.getOid( snode.getAttribute() );
        AttributeType type = attributeTypeRegistry.lookup( oid );
        Normalizer normalizer = type.getSubstr().getNormalizer();

        if ( db.hasUserIndexOn( snode.getAttribute() ) )
        {
            Index idx = db.getUserIndex( snode.getAttribute() );
       
            /*
             * Note that this is using the reverse half of the index giving a
             * considerable performance improvement on this kind of operation.
             * Otherwise we would have to scan the entire index if there were
             * no reverse lookups.
             */
       
            NamingEnumeration list = idx.listReverseIndices( record.getEntryId() );

            // compile the regular expression to search for a matching attribute
            try
            {
                regex = snode.getRegex( normalizer );
            }
            catch ( RESyntaxException e )
            {
                NamingException ne = new NamingException( "SubstringNode '"
                    + node + "' had " + "incorrect syntax" );
                ne.setRootCause( e );
                throw ne;
            }

            // cycle through the attribute values testing for a match
            while ( list.hasMore() )
            {
                IndexRecord rec = ( IndexRecord ) list.next();
           
                // once match is found cleanup and return true
                if ( regex.match( ( String ) rec.getIndexKey() ) )
                {
                    list.close();
                    return true;
                }
            }

            // we fell through so a match was not found - assertion was false.
            return false;
        }

        // --------------------------------------------------------------------
        // Index not defined beyond this point
        // --------------------------------------------------------------------
       
        // resusitate the entry if it has not been and set entry in IndexRecord
        if ( null == record.getAttributes() )
        {
            Attributes attrs = db.lookup( record.getEntryId() );
            record.setAttributes( attrs );
        }
       
        // get the attribute
        Attribute attr = record.getAttributes().get( snode.getAttribute() );
       
        // if the attribute does not exist just return false
        if ( null == attr )
        {
            return false;
        }

        // compile the regular expression to search for a matching attribute
        try
        {
            regex = snode.getRegex( normalizer );
        }
        catch ( RESyntaxException e )
        {
            NamingException ne = new NamingException( "SubstringNode '"
                + node + "' had " + "incorrect syntax" );
View Full Code Here

    public NamingEnumeration enumerate( final ExprNode node )
        throws NamingException
    {
        RE regex = null;
        Index idx = null;
        final SubstringNode snode = ( SubstringNode ) node;
        AttributeType type = attributeTypeRegistry.lookup( snode.getAttribute() );
        Normalizer normalizer = type.getSubstr().getNormalizer();

        if ( db.hasUserIndexOn( snode.getAttribute() ) )
        {
            /*
             * Build out regex in this block so we do not do it twice in the
             * evaluator if there is no index on the attribute of the substr ava
             */
            try
            {
                regex = snode.getRegex( normalizer );
            }
            catch ( RESyntaxException e )
            {
                NamingException ne = new NamingException( "SubstringNode '"
                    + node + "' had incorrect syntax" );
                ne.setRootCause( e );
                throw ne;
            }

            /*
             * Get the user index and return an index enumeration using the the
             * compiled regular expression.  Try to constrain even further if
             * an initial term is available in the substring expression.
             */
            idx = db.getUserIndex( snode.getAttribute() );
            if ( null == snode.getInitial() )
            {
                return idx.listIndices( regex );
            }
            else
            {
                return idx.listIndices( regex, snode.getInitial() );
            }
        }
       
        /*
         * From this point on we are dealing with an enumeration over entries
View Full Code Here

TOP

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

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.