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

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


        }

        Schema oldSchema = getSchema( oriChildName );
        Schema newSchema = getSchema( newParentName );
       
        Normalizer normalizer = factory.getNormalizer( entry, targetRegistries );
       
        if ( ! oldSchema.isDisabled() )
        {
            normalizerRegistry.unregister( oid );
        }
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( attrId );
        Comparator comparator = getComparator( attrId );
        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 ( 0 >= comparator.compare( normValue, filterValue ) )
                {
                    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 ( 0 <= comparator.compare( normValue, filterValue ) )
                {
                    return true;
View Full Code Here

     * @throws javax.naming.NamingException if there is a database access failure
     */
    @SuppressWarnings("unchecked")
    private boolean evalEquality( EqualityNode<?> node, ServerEntry entry ) throws NamingException
    {
        Normalizer normalizer = getNormalizer( node.getAttribute() );
        Comparator comparator = getComparator( node.getAttribute() );

        // get the attribute associated with the node
        EntryAttribute 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 at = attributeTypeRegistry.lookup( node.getAttribute() );
        Value<?> value = null;
       
        if ( at.getSyntax().isHumanReadable() )
        {
            if ( node.getValue().isBinary() )
            {
                value = new ClientStringValue( node.getValue().getString() );
            }
            else
            {
                value = node.getValue();
            }
        }
        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.get(), filterValue.get() ) )
            {
                return true;
            }
View Full Code Here

        if ( matchingRule == null )
        {
            matchingRule = type.getEquality();
        }
       
        Normalizer normalizer = matchingRule.getNormalizer();
       

        // get the attribute
        EntryAttribute attr = entry.get( snode.getAttribute() );

        // if the attribute does not exist just return false
        if ( null == attr )
        {
            return false;
        }

        // compile the regular expression to search for a matching attribute
        try
        {
            regex = snode.getRegex( normalizer );
        }
        catch ( PatternSyntaxException pse )
        {
            NamingException ne = new NamingException( "SubstringNode '" + node + "' had " + "incorrect syntax" );
            ne.setRootCause( pse );
            throw ne;
        }

        /*
         * Cycle through the attribute values testing normalized version
         * obtained from using the substring matching rule's normalizer.
         * The test uses the comparator obtained from the appropriate
         * substring matching rule.
         */

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

            // Once match is found cleanup and return true

            if ( regex.matcher( normValue ).matches() )
            {
View Full Code Here

            return;
        }
       
        if ( wrapped != null )
        {
            Normalizer normalizer = getNormalizer();
   
            if ( normalizer == null )
            {
                normalizedValue = wrapped;
                normalized = false;
                same = true;
            }
            else
            {
                normalizedValue = normalizer.normalize( this ).getBytes();
                normalized = true;
                same = Arrays.equals( wrapped, normalizedValue );
            }
        }
        else
View Full Code Here

               
                throw new IllegalArgumentException( "Not a valid value" );
            }
        };
       
        mr.normalizer = new Normalizer()
        {
            // The serial UID
            private static final long serialVersionUID = 1L;

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

                    ( o2 == null ? 0 : -1 ) :
                    ( o2 == null ? 1 : ByteArrayComparator.INSTANCE.compare( o1, o2 ) ) );
            }
        };
       
        mr.normalizer = new Normalizer()
        {
            // The serial UID
            private static final long serialVersionUID = 1L;
           
            public Value<?> normalize( Value<?> value ) throws NamingException
View Full Code Here

        if ( normalized )
        {
            return;
        }
       
        Normalizer normalizer = getNormalizer();

        if ( normalizer == null )
        {
            normalizedValue = wrapped;
        }
        else
        {
            normalizedValue = ( String ) normalizer.normalize( wrapped );
        }

        normalized = true;
    }
View Full Code Here

        s = new TestServerEntryUtils.S( "1.1.1.1", false );
        s.setSyntaxChecker( new AcceptAllSyntaxChecker( "1.1.1.1" ) );
        mr = new TestServerEntryUtils.MR( "1.1.2.1" );
        mr.syntax = s;
        mr.comparator = new ByteArrayComparator();
        mr.normalizer = new Normalizer()
        {
            private static final long serialVersionUID = 1L;
           
            public Value<?> normalize( Value<?> value ) throws NamingException
            {
View Full Code Here

   
    private Normalizer getNormalizer( String className, EntryAttribute bytecode, Registries targetRegistries )
        throws NamingException
    {
        Class<?> clazz = null;
        Normalizer normalizer = null;
       
        try
        {
            if ( bytecode == null )
            {
View Full Code Here

TOP

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