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

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


                            System.arraycopy( wrappedValue, 0, normalizedValue, 0, wrappedLength );
                        }
                    }
                    else
                    {
                        Normalizer normalizer = equality.getNormalizer();

                        if ( normalizer != null )
                        {
                            normalizedValue = normalizer.normalize( this ).getBytes();
                        }
                        else
                        {
                            if ( wrappedLength >= 0 )
                            {
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

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

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

        MatchingRule equality = attributeType.getEquality();

        if ( equality != null )
        {
            // If we have an Equality MR, we *must* have a normalizer
            Normalizer normalizer = equality.getNormalizer();

            if ( normalizer != null )
            {
                if ( wrappedValue != null )
                {
                    boolean isHR = attributeType.getSyntax().isHumanReadable();

                    if ( isHR != isHumanReadable() )
                    {
                        String message = "The '" + attributeType.getName() + "' AttributeType and values must " +
                            "both be String or binary";
                        LOG.error( message );
                        throw new LdapInvalidAttributeValueException( ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX, message );
                    }

                    try
                    {
                        if ( isHumanReadable() )
                        {
                            normalizedValue = ( T ) normalizer.normalize( ( String ) wrappedValue );
                        }
                        else
                        {
                            normalizedValue = ( T ) normalizer.normalize( new BinaryValue( ( byte[] ) wrappedValue ) )
                                .getNormReference();
                        }
                    }
                    catch ( LdapException ne )
                    {
View Full Code Here

public class DeepTrimNormalizerTest
{
    @Test
    public void testDeepTrimNormalizerNull() throws LdapException
    {
        Normalizer normalizer = new DeepTrimNormalizer( "1.1.1" );
        assertEquals( "", normalizer.normalize( ( String ) null ) );
    }
View Full Code Here


    @Test
    public void testDeepTrimNormalizerEmpty() throws LdapException
    {
        Normalizer normalizer = new DeepTrimNormalizer( "1.1.1" );
        assertEquals( "", normalizer.normalize( "" ) );
    }
View Full Code Here


    @Test
    public void testDeepTrimNormalizerOneSpace() throws LdapException
    {
        Normalizer normalizer = new DeepTrimNormalizer( "1.1.1" );
        assertEquals( " ", normalizer.normalize( " " ) );
    }
View Full Code Here


    @Test
    public void testDeepTrimNormalizerTwoSpaces() throws LdapException
    {
        Normalizer normalizer = new DeepTrimNormalizer( "1.1.1" );
        assertEquals( " ", normalizer.normalize( "  " ) );
    }
View Full Code Here


    @Test
    public void testDeepTrimNormalizerNSpaces() throws LdapException
    {
        Normalizer normalizer = new DeepTrimNormalizer( "1.1.1" );
        assertEquals( " ", normalizer.normalize( "      " ) );
    }
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.