Package org.apache.directory.api.ldap.model.name

Examples of org.apache.directory.api.ldap.model.name.Ava


        Iterator<Ava> iterator = rdn.iterator();

        while ( iterator.hasNext() )
        {
            Ava ava = iterator.next();

            // First, get the AT name, or OID
            String normAT = ava.getNormType();
            AttributeType at = schemaManager.lookupAttributeTypeRegistry( normAT );

            String atName = at.getName();

            // Now, get the normalized value
            String normValue = ava.getNormValue().getString();

            fileName.append( atName ).append( "=" ).append( normValue );

            if ( iterator.hasNext() )
            {
View Full Code Here


            // below we only process multi-valued rdns
            StringBuffer buf = new StringBuffer();

            for ( Iterator<Ava> atavs = rdn.iterator(); atavs.hasNext(); /**/)
            {
                Ava atav = atavs.next();
                String type = schemaManager.lookupAttributeTypeRegistry( rdn.getNormType() ).getName();
                buf.append( type ).append( '=' ).append( atav.getNormValue() );

                if ( atavs.hasNext() )
                {
                    buf.append( '+' );
                }
View Full Code Here

        StringBuffer sb = new StringBuffer();

        Iterator<Ava> it = rdn.iterator();
        while ( it.hasNext() )
        {
            Ava ava = it.next();
            sb.append( getOidString( ava, schema ) );
            if ( it.hasNext() )
            {
                sb.append( '+' );
            }
View Full Code Here

            // below we only process multi-valued rdns
            StringBuffer buf = new StringBuffer();

            for ( Iterator<Ava> atavs = rdn.iterator(); atavs.hasNext(); /**/)
            {
                Ava atav = atavs.next();
                String type = schemaManager.lookupAttributeTypeRegistry( rdn.getNormType() ).getName();
                buf.append( type ).append( '=' ).append( atav.getNormValue() );

                if ( atavs.hasNext() )
                {
                    buf.append( '+' );
                }
View Full Code Here

    public void testTrimAtavs() throws LdapException
    {
        // antlr parser: string value with trailing spaces
        Dn dn1 = new Dn( " cn = Amos\\,Tori , ou=system " );
        assertEquals( " cn = Amos\\,Tori ", dn1.getRdn().getName() );
        Ava atav1 = dn1.getRdn().getAva();
        assertEquals( "cn", atav1.getType() );
        assertEquals( "Amos,Tori", atav1.getValue().getString() );

        // antlr parser: hexstring with trailing spaces
        Dn dn3 = new Dn( " cn = #414243 , ou=system " );
        assertEquals( " cn = #414243 ", dn3.getRdn().getName() );
        Ava atav3 = dn3.getRdn().getAva();
        assertEquals( "cn", atav3.getType() );
        assertEquals( "ABC", atav3.getValue().getString() );
        assertTrue( Arrays.equals( Strings.getBytesUtf8( "ABC" ), atav3.getNormValue().getBytes() ) );

        // antlr parser:
        Dn dn4 = new Dn( " cn = \\41\\42\\43 , ou=system " );
        assertEquals( " cn = \\41\\42\\43 ", dn4.getRdn().getName() );
        Ava atav4 = dn4.getRdn().getAva();
        assertEquals( "cn", atav4.getType() );
        assertEquals( "ABC", atav4.getValue().getString() );
        assertEquals( "ABC", atav4.getNormValue().getString() );

        // antlr parser: quotestring with trailing spaces
        Dn dn5 = new Dn( " cn = \"ABC\" , ou=system " );
        assertEquals( " cn = \"ABC\" ", dn5.getRdn().getName() );
        Ava atav5 = dn5.getRdn().getAva();
        assertEquals( "cn", atav5.getType() );
        assertEquals( "\"ABC\"", atav5.getValue().getString() );
        assertEquals( "ABC", atav5.getNormValue().getString() );

        // fast parser: string value with trailing spaces
        Dn dn2 = new Dn( " cn = Amos Tori , ou=system " );
        assertEquals( " cn = Amos Tori ", dn2.getRdn().getName() );
        Ava atav2 = dn2.getRdn().getAva();
        assertEquals( "cn", atav2.getType() );
        assertEquals( "Amos Tori", atav2.getValue().getString() );
    }
View Full Code Here

        assertEquals( "2.5.4.11=example", rdn.getNormName() );
        assertEquals( "ou", rdn.getType() );
        assertEquals( "Example", rdn.getValue().getString() );
        assertEquals( "  ou  =  Example ", rdn.getName() );

        Ava atav = rdn.getAva();

        assertEquals( "2.5.4.11=example", atav.getNormName() );
        assertEquals( "2.5.4.11", atav.getNormType() );
        assertEquals( "example", atav.getNormValue().getValue() );

        assertEquals( "ou", atav.getType() );
        assertEquals( "Example", atav.getValue().getValue() );

        assertEquals( "  ou  =  Example ", atav.getName() );
    }
View Full Code Here

        assertEquals( "ou", rdn.getType() );
        assertEquals( "Example", rdn.getValue().getString() );
        assertEquals( "  ou  =  Example + cn = TEST ", rdn.getName() );

        // The first ATAV
        Ava atav = rdn.getAva();

        assertEquals( "2.5.4.11=example", atav.getNormName() );
        assertEquals( "2.5.4.11", atav.getNormType() );
        assertEquals( "example", atav.getNormValue().getValue() );

        assertEquals( "ou", atav.getType() );
        assertEquals( "Example", atav.getValue().getValue() );

        assertEquals( "  ou  =  Example ", atav.getName() );

        assertEquals( 2, rdn.size() );

        // The second ATAV
        for ( Ava ava : rdn )
View Full Code Here

        assertEquals( "2.5.4.11=ex\\+mple", rdn.getNormName() );
        assertEquals( "ou", rdn.getType() );
        assertEquals( "Ex+mple", rdn.getValue().getString() );
        assertEquals( "  ou  =  Ex\\+mple ", rdn.getName() );

        Ava atav = rdn.getAva();

        assertEquals( "2.5.4.11=ex\\+mple", atav.getNormName() );
        assertEquals( "2.5.4.11", atav.getNormType() );
        assertEquals( "ex+mple", atav.getNormValue().getValue() );

        assertEquals( "ou", atav.getType() );
        assertEquals( "Ex+mple", atav.getValue().getValue() );

        assertEquals( "  ou  =  Ex\\+mple ", atav.getName() );
    }
View Full Code Here

        assertEquals( "Ex+mple", rdn.getValue().getString() );
        assertEquals( "Ex+mple", rdn.getNormValue().getString() );

        // The first ATAV
        Ava atav = rdn.getAva();

        assertEquals( "  OU  =  Ex\\+mple ", atav.getName() );
        assertEquals( "ou=Ex\\+mple", atav.getNormName() );

        assertEquals( "ou", atav.getNormType() );
        assertEquals( "OU", atav.getType() );

        assertEquals( "Ex+mple", atav.getValue().getValue() );
        assertEquals( "Ex+mple", atav.getNormValue().getValue() );

        assertEquals( 2, rdn.size() );

        // The second ATAV
        for ( Ava ava : rdn )
        {
            if ( "Ex+mple".equals( ava.getNormValue().getValue() ) )
            {
                // Skip the first one
                continue;
            }

            assertEquals( " cn = T\\+ST\\  ", ava.getName() );
            assertEquals( "cn=T\\+ST\\ ", ava.getNormName() );

            assertEquals( "cn", ava.getType() );
            assertEquals( "cn", ava.getNormType() );

            assertEquals( "T+ST", ava.getValue().getValue() );
            assertEquals( "T+ST ", ava.getNormValue().getValue() );
        }

        // ------------------------------------------------------------------
        // Now normalize the Dn
        dn.apply( schemaManager );

        assertEquals( "  OU  =  Ex\\+mple + cn = T\\+ST\\  ,  ou  =  COM ", dn.getName() );
        assertEquals( "2.5.4.11=ex\\+mple+2.5.4.3=t\\+st,2.5.4.11=com", dn.getNormName() );

        // Check the first Rdn
        rdn = dn.getRdn();
        assertEquals( "  OU  =  Ex\\+mple + cn = T\\+ST\\  ", rdn.getName() );
        assertEquals( "2.5.4.11=ex\\+mple+2.5.4.3=t\\+st", rdn.getNormName() );

        assertEquals( "OU", rdn.getType() );
        assertEquals( "2.5.4.11", rdn.getNormType() );

        assertEquals( "Ex+mple", rdn.getValue().getString() );
        assertEquals( "ex+mple", rdn.getNormValue().getString() );

        // The first ATAV
        atav = rdn.getAva();

        assertEquals( "  OU  =  Ex\\+mple ", atav.getName() );
        assertEquals( "2.5.4.11=ex\\+mple", atav.getNormName() );

        assertEquals( "2.5.4.11", atav.getNormType() );
        assertEquals( "OU", atav.getType() );

        assertEquals( "Ex+mple", atav.getValue().getValue() );
        assertEquals( "ex+mple", atav.getNormValue().getValue() );

        assertEquals( 2, rdn.size() );

        // The second ATAV
        for ( Ava ava : rdn )
View Full Code Here

     * Test serialization of a simple ATAV
     */
    @Test
    public void testStringAtavSerialization() throws LdapException, IOException, ClassNotFoundException
    {
        Ava atav = new Ava( schemaManager, "CN", "Test" );

        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        ObjectOutputStream out = new ObjectOutputStream( baos );

        atav.writeExternal( out );

        ObjectInputStream in = null;

        byte[] data = baos.toByteArray();
        in = new ObjectInputStream( new ByteArrayInputStream( data ) );

        Ava atav2 = new Ava( schemaManager );
        atav2.readExternal( in );

        assertEquals( atav, atav2 );
    }
View Full Code Here

TOP

Related Classes of org.apache.directory.api.ldap.model.name.Ava

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.