Package org.apache.directory.shared.ldap.model.filter

Examples of org.apache.directory.shared.ldap.model.filter.SubstringNode


        // SUBSTRING FILTER
        else if ( filter instanceof SubstringNode )
        {
            Element newElement = element.addElement( "substrings" );

            SubstringNode substringFilter = ( SubstringNode ) filter;

            newElement.addAttribute( "name", substringFilter.getAttribute() );

            String initial = substringFilter.getInitial();

            if ( ( initial != null ) && ( !"".equals( initial ) ) )
            {
                newElement.addElement( "initial" ).setText( initial );
            }

            List<String> anyList = substringFilter.getAny();

            for ( int i = 0; i < anyList.size(); i++ )
            {
                newElement.addElement( "any" ).setText( anyList.get( i ) );
            }

            String finalString = substringFilter.getFinal();

            if ( ( finalString != null ) && ( !"".equals( finalString ) ) )
            {
                newElement.addElement( "final" ).setText( finalString );
            }
View Full Code Here


    @Test
    public void testNotCursorWithManualFilter() throws Exception
    {
        NotNode notNode = new NotNode();

        ExprNode exprNode = new SubstringNode( schemaManager.getAttributeType( "cn" ), "J", null );
        Evaluator<? extends ExprNode, Entry, Long> eval = new SubstringEvaluator( (SubstringNode) exprNode, store,
            schemaManager );
        notNode.addNode( exprNode );

        NotCursor<String, Long> cursor = new NotCursor( store, eval ); //cursorBuilder.build( andNode );
View Full Code Here

        Evaluator<? extends ExprNode, Entry, Long> eval;
        Cursor<IndexEntry<?, Entry, Long>> cursor;

        OrNode orNode = new OrNode();

        ExprNode exprNode = new SubstringNode( schemaManager.getAttributeType( "cn" ), "J", null );
        eval = new SubstringEvaluator( ( SubstringNode ) exprNode, store, schemaManager );
        Cursor subStrCursor1 = new SubstringCursor( store, ( SubstringEvaluator ) eval );
        cursors.add( subStrCursor1 );
        evaluators.add( eval );
        orNode.addNode( exprNode );

        //        try
        //        {
        //            new OrCursor( cursors, evaluators );
        //            fail( "should throw IllegalArgumentException" );
        //        }
        //        catch( IllegalArgumentException ie ){ }

        exprNode = new SubstringNode( schemaManager.getAttributeType( "sn" ), "W", null );
        eval = new SubstringEvaluator( ( SubstringNode ) exprNode, store, schemaManager );
        evaluators.add( eval );
        Cursor subStrCursor2 = new SubstringCursor( store, ( SubstringEvaluator ) eval );
        cursors.add( subStrCursor2 );
View Full Code Here


    @Test
    public void testIndexedCnStartsWithJ() throws Exception
    {
        SubstringNode node = new SubstringNode( schemaManager.getAttributeType( "cn" ), "j", null );
        SubstringEvaluator<Long> evaluator = new SubstringEvaluator<Long>( node, store, schemaManager );
        SubstringCursor<Long> cursor = new SubstringCursor<Long>( store, evaluator );

        assertEquals( node, evaluator.getExpression() );
View Full Code Here


    @Test
    public void testIndexedCnStartsWithJim() throws Exception
    {
        SubstringNode node = new SubstringNode( schemaManager.getAttributeType( "cn" ), "jim", null );
        SubstringEvaluator<Long> evaluator = new SubstringEvaluator<Long>( node, store, schemaManager );
        SubstringCursor<Long> cursor = new SubstringCursor<Long>( store, evaluator );

        assertEquals( node, evaluator.getExpression() );
View Full Code Here


    @Test
    public void testIndexedCnEndsWithBean() throws Exception
    {
        SubstringNode node = new SubstringNode( schemaManager.getAttributeType( "cn" ), null, "bean" );
        SubstringEvaluator<Long> evaluator = new SubstringEvaluator<Long>( node, store, schemaManager );
        SubstringCursor<Long> cursor = new SubstringCursor<Long>( store, evaluator );

        assertEquals( node, evaluator.getExpression() );
View Full Code Here


    @Test
    public void testNonIndexedSnStartsWithB() throws Exception
    {
        SubstringNode node = new SubstringNode( schemaManager.getAttributeType( "sn" ), "b", null );
        SubstringEvaluator<Long> evaluator = new SubstringEvaluator<Long>( node, store, schemaManager );
        SubstringCursor<Long> cursor = new SubstringCursor<Long>( store, evaluator );

        assertEquals( node, evaluator.getExpression() );
View Full Code Here


    @Test
    public void testIndexedSnEndsWithEr() throws Exception
    {
        SubstringNode node = new SubstringNode( schemaManager.getAttributeType( "sn" ), null, "er" );
        SubstringEvaluator<Long> evaluator = new SubstringEvaluator<Long>( node, store, schemaManager );
        SubstringCursor<Long> cursor = new SubstringCursor<Long>( store, evaluator );

        assertEquals( node, evaluator.getExpression() );
View Full Code Here


    @Test
    public void testNonIndexedAttributes() throws Exception
    {
        SubstringNode node = new SubstringNode( schemaManager.getAttributeType( "sn" ), "walk", null );
        SubstringEvaluator<Long> evaluator = new SubstringEvaluator<Long>( node, store, schemaManager );
        ForwardIndexEntry<String, Entry, Long> indexEntry = new ForwardIndexEntry<String, Entry, Long>();
        indexEntry.setId( 5L );
        assertTrue( evaluator.evaluate( indexEntry ) );
        indexEntry.setId( 3L );
        indexEntry.setObject( null );
        assertFalse( evaluator.evaluate( indexEntry ) );
        indexEntry.setId( 6L );
        indexEntry.setObject( null );
        assertFalse( evaluator.evaluate( indexEntry ) );

        node = new SubstringNode( schemaManager.getAttributeType( "sn" ), "wa", null );
        evaluator = new SubstringEvaluator<Long>( node, store, schemaManager );
        indexEntry = new ForwardIndexEntry<String, Entry, Long>();
        indexEntry.setId( 5L );
        indexEntry.setObject( store.lookup( 5L ) );
        assertTrue( evaluator.evaluate( indexEntry ) );

        node = new SubstringNode( schemaManager.getAttributeType( "searchGuide" ), "j", null );
        evaluator = new SubstringEvaluator<Long>( node, store, schemaManager );
        indexEntry = new ForwardIndexEntry<String, Entry, Long>();
        indexEntry.setId( 6L );
        indexEntry.setObject( store.lookup( 6L ) );
        assertFalse( evaluator.evaluate( indexEntry ) );

        node = new SubstringNode( schemaManager.getAttributeType( "st" ), "j", null );
        evaluator = new SubstringEvaluator<Long>( node, store, schemaManager );
        indexEntry = new ForwardIndexEntry<String, Entry, Long>();
        indexEntry.setId( 6L );
        indexEntry.setObject( store.lookup( 6L ) );
        assertFalse( evaluator.evaluate( indexEntry ) );

        node = new SubstringNode( schemaManager.getAttributeType( "name" ), "j", null );
        evaluator = new SubstringEvaluator<Long>( node, store, schemaManager );
        indexEntry = new ForwardIndexEntry<String, Entry, Long>();
        indexEntry.setId( 6L );
        indexEntry.setObject( store.lookup( 6L ) );
        assertTrue( evaluator.evaluate( indexEntry ) );

        node = new SubstringNode( schemaManager.getAttributeType( "name" ), "s", null );
        evaluator = new SubstringEvaluator<Long>( node, store, schemaManager );
        indexEntry = new ForwardIndexEntry<String, Entry, Long>();
        indexEntry.setId( 6L );
        indexEntry.setObject( store.lookup( 6L ) );
        assertTrue( evaluator.evaluate( indexEntry ) );
View Full Code Here


    @Test
    public void testEvaluatorIndexed() throws Exception
    {
        SubstringNode node = new SubstringNode( schemaManager.getAttributeType( "cn" ), "jim", null );
        SubstringEvaluator<Long> evaluator = new SubstringEvaluator<Long>( node, store, schemaManager );
        ForwardIndexEntry<String, Entry, Long> indexEntry = new ForwardIndexEntry<String, Entry, Long>();
        indexEntry.setId( 6L );
        assertTrue( evaluator.evaluate( indexEntry ) );
        indexEntry.setId( 3L );
        indexEntry.setObject( null );
        assertFalse( evaluator.evaluate( indexEntry ) );

        node = new SubstringNode( schemaManager.getAttributeType( "cn" ), "j", null );
        evaluator = new SubstringEvaluator<Long>( node, store, schemaManager );
        indexEntry = new ForwardIndexEntry<String, Entry, Long>();
        indexEntry.setId( 6L );
        indexEntry.setObject( store.lookup( 6L ) );
        assertTrue( evaluator.evaluate( indexEntry ) );

        node = new SubstringNode( schemaManager.getAttributeType( "cn" ), "s", null );
        evaluator = new SubstringEvaluator<Long>( node, store, schemaManager );
        indexEntry = new ForwardIndexEntry<String, Entry, Long>();
        indexEntry.setId( 6L );
        indexEntry.setObject( store.lookup( 6L ) );
        assertFalse( evaluator.evaluate( indexEntry ) );
View Full Code Here

TOP

Related Classes of org.apache.directory.shared.ldap.model.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.