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

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


     */
    private void addNormalizers( Schema schema, Registries registries ) throws LdapException, IOException
    {
        for ( Entry entry : schemaLoader.loadNormalizers( schema ) )
        {
            Normalizer normalizer = factory.getNormalizer( this, entry, registries, schema.getSchemaName() );

            addSchemaObject( registries, normalizer, schema );
        }
    }
View Full Code Here


        /*
         * We need to iterate through all values and for each value we normalize
         * and use the comparator to determine if a match exists.
         */
        Normalizer normalizer = getNormalizer( attributeType );
        Comparator comparator = getComparator( attributeType );
        Object filterValue = normalizer.normalize( node.getValue() );

        /*
         * Cheaper to not check isGreater in one loop - better to separate
         * out into two loops which you choose to execute based on isGreater
         */
        if ( isGreaterOrLesser == COMPARE_GREATER )
        {
            for ( Value<?> value : attr )
            {
                Object normValue = normalizer.normalize( value );

                // Found a value that is greater than or equal to the ava value
                if ( comparator.compare( normValue, filterValue ) >= 0 )
                {
                    return true;
                }
            }
        }
        else
        {
            for ( Value<?> value : attr )
            {
                Object normValue = normalizer.normalize( value );

                // Found a value that is less than or equal to the ava value
                if ( comparator.compare( normValue, filterValue ) <= 0 )
                {
                    return true;
View Full Code Here

     * @throws org.apache.directory.shared.ldap.model.exception.LdapException if there is a database access failure
     */
    @SuppressWarnings("unchecked")
    private boolean evalEquality( EqualityNode<?> node, Entry entry ) throws LdapException
    {
        Normalizer normalizer = getNormalizer( node.getAttributeType() );
        Comparator comparator = getComparator( node.getAttributeType() );

        // get the attribute associated with the node
        Attribute attr = entry.get( node.getAttribute() );

        // If we do not have the attribute just return false
        if ( null == attr )
        {
            return false;
        }

        // check if Ava value exists in attribute
        AttributeType attributeType = node.getAttributeType();
        Value<?> value = null;
       
        if ( attributeType.getSyntax().isHumanReadable() )
        {
            if ( node.getValue().isHumanReadable() )
            {
                value = node.getValue();
            }
            else
            {
                value = new org.apache.directory.shared.ldap.model.entry.StringValue( node.getValue().getString() );
            }
        }
        else
        {
            value = node.getValue();
        }
       
        if ( attr.contains( value ) )
        {
            return true;
        }

        // get the normalized Ava filter value
        Value<?> filterValue = normalizer.normalize( value );

        // check if the normalized value is present
        if ( attr.contains( filterValue ) )
        {
            return true;
        }

        /*
         * We need to now iterate through all values because we could not get
         * a lookup to work.  For each value we normalize and use the comparator
         * to determine if a match exists.
         */
        for ( Value<?> val : attr )
        {
            Value<?> normValue = normalizer.normalize( val );

            if ( 0 == comparator.compare( normValue.getValue(), filterValue.getValue() ) )
            {
                return true;
            }
View Full Code Here

        /*
         * Get ahold of the normalizer for the attribute and normalize the request
         * assertion value for comparisons with normalized attribute values.  Loop
         * through all values looking for a match.
         */
        Normalizer normalizer = compareContext.getAttributeType().getEquality().getNormalizer();
        Value<?> reqVal = normalizer.normalize( compareContext.getValue() );

        for ( Value<?> value : attr )
        {
            Value<?> attrValObj = normalizer.normalize( value );

            if ( attrValObj.equals( reqVal ) )
            {
                return true;
            }
View Full Code Here

               
                throw new IllegalArgumentException();
            }
        } );
       
        Normalizer normalizer = new Normalizer( "1.1.1" )
        {
            public Value<?> normalize( Value<?> value ) throws LdapException
            {
                if ( value.isHumanReadable() )
                {
View Full Code Here

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

        matchingRule.setLdapComparator( new ByteArrayComparator( "1.2.2" ) );
       
        matchingRule.setNormalizer( new Normalizer( "1.1.1" )
        {
            public Value<?> normalize( Value<?> value ) throws LdapException
            {
                if ( !value.isHumanReadable() )
                {
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 Value<?> normalize( Value<?> value ) throws LdapException
            {
                if ( !value.isHumanReadable() )
                {
View Full Code Here


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


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


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

TOP

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