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

Examples of org.apache.directory.api.ldap.model.schema.Normalizer



    @Test
    public void testInsignifiantNumericCharsSpaces() throws LdapException
    {
        Normalizer normalizer = new NumericNormalizer();
        assertEquals( "1", normalizer.normalize( " 1" ) );
        assertEquals( "1", normalizer.normalize( "1 " ) );
        assertEquals( "1", normalizer.normalize( " 1 " ) );
        assertEquals( "11", normalizer.normalize( "1 1" ) );
        assertEquals( "11", normalizer.normalize( " 1 1" ) );
        assertEquals( "11", normalizer.normalize( "1 1 " ) );
        assertEquals( "11", normalizer.normalize( "1  1" ) );
        assertEquals( "11", normalizer.normalize( " 1   1 " ) );
        assertEquals( "123456789", normalizer.normalize( "  123   456   789  " ) );
    }
View Full Code Here


        s.setSyntaxChecker( new OctetStringSyntaxChecker() );
        mr = EntryUtils.matchingRuleFactory( "1.1.2.1" );
        mr.setSyntax( s );

        mr.setLdapComparator( new ByteArrayComparator( "1.1.1" ) );
        mr.setNormalizer( new Normalizer( "1.1.1" )
        {
            public static final long serialVersionUID = 1L;


            public Value<?> normalize( Value<?> value ) throws LdapException
View Full Code Here

                    ( o2 == null ? 0 : -1 ) :
                    ( o2 == null ? 1 : o1.compareTo( o2 ) ) );
            }
        } );

        Normalizer normalizer = new Normalizer( "1.1.1" )
        {
            public static final long serialVersionUID = 1L;


            public Value<?> normalize( Value<?> value ) throws LdapException
View Full Code Here

        MutableMatchingRule matchingRule = new MutableMatchingRule( "1.2.2" );
        matchingRule.setSyntax( syntax );

        matchingRule.setLdapComparator( new ByteArrayComparator( "1.2.2" ) );

        matchingRule.setNormalizer( new Normalizer( "1.1.1" )
        {
            public static final long serialVersionUID = 1L;


            public Value<?> normalize( Value<?> value ) throws LdapException
View Full Code Here

            ldapSchemaException.setSourceObject( matchingRule );
            errors.add( ldapSchemaException );
        }

        // Process the Normalizer
        Normalizer normalizer = matchingRule.getNormalizer();

        if ( normalizer == null )
        {
            // Ok, no normalizer, this is an error
            Throwable error = new LdapSchemaViolationException( ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX, I18n.err(
View Full Code Here

        sb.setSyntaxChecker( new OctetStringSyntaxChecker() );
        mrb = new EntryUtils.MR( "1.1.2.1" );
        mrb.setSyntax( sb );

        mrb.setLdapComparator( new ByteArrayComparator( "1.1.1" ) );
        mrb.setNormalizer( new Normalizer( "1.1.1" )
        {
            public static final long serialVersionUID = 1L;


            public Value<?> normalize( Value<?> value ) throws LdapException
View Full Code Here

        s.setSyntaxChecker( new OctetStringSyntaxChecker() );
        mr = EntryUtils.matchingRuleFactory( "1.1.2.1" );
        mr.setSyntax( s );

        mr.setLdapComparator( new ByteArrayComparator( "1.1.1" ) );
        mr.setNormalizer( new Normalizer( "1.1.1" )
        {
            public static final long serialVersionUID = 1L;


            public Value<?> normalize( Value<?> value ) throws LdapException
View Full Code Here

                    {
                        // No matching rule : compare the raw values
                        return getNormReference().equals( other.getNormReference() );
                    }

                    Normalizer normalizer = equality.getNormalizer();

                    StringValue otherValue = ( StringValue ) normalizer.normalize( other );

                    if ( comparator == null )
                    {
                        return getNormReference().equals( otherValue.getNormReference() );
                    }
                    else
                    {
                        return comparator.compare( getNormReference(), otherValue.getNormReference() ) == 0;
                    }
                }
                catch ( LdapException ne )
                {
                    return false;
                }
            }
        }
        else
        {
            // No : check for the other value
            if ( other.attributeType != null )
            {
                // We only have one AT : we will assume that both values are for the
                // same AT.
                // The values may be both null
                if ( isNull() )
                {
                    return other.isNull();
                }

                try
                {
                    Comparator<String> comparator = other.getLdapComparator();

                    // Compare normalized values. We have to normalized the other value,
                    // as it has no AT
                    MatchingRule equality = other.getAttributeType().getEquality();

                    if ( equality == null )
                    {
                        // No matching rule : compare the raw values
                        return getNormReference().equals( other.getNormReference() );
                    }

                    Normalizer normalizer = equality.getNormalizer();

                    StringValue thisValue = ( StringValue ) normalizer.normalize( this );

                    if ( comparator == null )
                    {
                        return thisValue.getNormReference().equals( other.getNormReference() );
                    }
View Full Code Here

                    {
                        normalizedValue = wrappedValue;
                    }
                    else
                    {
                        Normalizer normalizer = equality.getNormalizer();

                        if ( normalizer != null )
                        {
                            normalizedValue = normalizer.normalize( wrappedValue );
                        }
                        else
                        {
                            normalizedValue = wrappedValue;
                        }
View Full Code Here

                    {
                        // No matching rule : compare the raw values
                        return Arrays.equals( getNormReference(), other.getNormReference() );
                    }

                    Normalizer normalizer = equality.getNormalizer();

                    BinaryValue otherValue = ( BinaryValue ) normalizer.normalize( other );

                    if ( comparator == null )
                    {
                        return Arrays.equals( getNormReference(), otherValue.getNormReference() );
                    }
                    else
                    {
                        return comparator.compare( getNormReference(), otherValue.getNormReference() ) == 0;
                    }
                }
                catch ( LdapException ne )
                {
                    return false;
                }
            }
        }
        else
        {
            // No : check for the other value
            if ( other.attributeType != null )
            {
                // We only have one AT : we will assume that both values are for the
                // same AT.
                // The values may be both null
                if ( isNull() )
                {
                    return other.isNull();
                }

                try
                {
                    Comparator<byte[]> comparator = other.getLdapComparator();

                    // Compare normalized values. We have to normalized the other value,
                    // as it has no AT
                    MatchingRule equality = other.getAttributeType().getEquality();

                    if ( equality == null )
                    {
                        // No matching rule : compare the raw values
                        return Arrays.equals( getNormReference(), other.getNormReference() );
                    }

                    Normalizer normalizer = equality.getNormalizer();

                    BinaryValue thisValue = ( BinaryValue ) normalizer.normalize( this );

                    if ( comparator == null )
                    {
                        return Arrays.equals( thisValue.getNormReference(), other.getNormReference() );
                    }
View Full Code Here

TOP

Related Classes of org.apache.directory.api.ldap.model.schema.Normalizer

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.