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

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


                    continue;
                }
                AttributeType attributeType = schemaManager.lookupAttributeTypeRegistry( oid );

                // Check that the attributeType has an EQUALITY matchingRule
                MatchingRule mr = attributeType.getEquality();

                if ( mr != null )
                {
                    ( ( JdbmIndex ) index ).init( schemaManager, schemaManager.lookupAttributeTypeRegistry( oid ),
                        workingDirectory );
View Full Code Here


        else
        {
            idx = null;
            type = schemaManager.lookupAttributeTypeRegistry( node.getAttribute() );

            MatchingRule mr = type.getEquality();

            if ( mr == null )
            {
                throw new IllegalStateException( I18n.err( I18n.ERR_709, node ) );
            }

            normalizer = mr.getNormalizer();
            ldapComparator = mr.getLdapComparator();
        }
    }
View Full Code Here

     * @return a matchingRule or null if one cannot be found for the attributeType
     * @throws NamingException if resolution of schema entities fail
     */
    private MatchingRule getMatchingRule() throws NamingException
    {
        MatchingRule mr = attributeType.getEquality();

        if ( mr == null )
        {
            mr = attributeType.getOrdering();
        }
View Full Code Here

     * @return a normalizer associated with the attributeType or null if one cannot be found
     * @throws NamingException if resolution of schema entities fail
     */
    private Normalizer getNormalizer() throws NamingException
    {
        MatchingRule mr = getMatchingRule();

        if ( mr == null )
        {
            return null;
        }

        return mr.getNormalizer();
    }
View Full Code Here

     * @return a comparator associated with the attributeType or null if one cannot be found
     * @throws NamingException if resolution of schema entities fail
     */
    private LdapComparator<? super Object> getLdapComparator() throws NamingException
    {
        MatchingRule mr = getMatchingRule();

        if ( mr == null )
        {
            return null;
        }

        return mr.getLdapComparator();
    }
View Full Code Here

        this.schemaManager = schemaManager;

        String oid = schemaManager.getAttributeTypeRegistry().getOidByName( node.getAttribute() );
        type = schemaManager.lookupAttributeTypeRegistry( oid );

        MatchingRule rule = type.getSubstring();

        if ( rule == null )
        {
            rule = type.getEquality();
        }

        if ( rule != null )
        {
            normalizer = rule.getNormalizer();
        }
        else
        {
            normalizer = new NoOpNormalizer( type.getSyntaxOid() );
        }
View Full Code Here

    void initialize( AttributeType attributeType ) throws Exception
    {
        this.attributeType = attributeType;

        MatchingRule mr = attributeType.getEquality();

        if ( mr == null )
        {
            mr = attributeType.getOrdering();
        }

        if ( mr == null )
        {
            mr = attributeType.getSubstring();
        }

        normalizer = mr.getNormalizer();

        if ( normalizer == null )
        {
            throw new Exception( I18n.err( I18n.ERR_212, attributeType ) );
        }

        LdapComparator<K> comp = ( LdapComparator<K> ) mr.getLdapComparator();

        /*
         * The forward key/value map stores attribute values to master table
         * primary keys.  A value for an attribute can occur several times in
         * different entries so the forward map can have more than one value.
View Full Code Here

     * @return a comparator associated with the attributeType or null if one cannot be found
     * @throws NamingException if resolution of schema entities fail
     */
    private LdapComparator<?> getLdapComparator() throws NamingException
    {
        MatchingRule mr = getMatchingRule();

        if ( mr == null )
        {
            return null;
        }

        return mr.getLdapComparator();
    }
View Full Code Here

        }
    }

    public static MatchingRule matchingRuleFactory( String oid )
    {
        MatchingRule matchingRule = new MatchingRule( oid );
       
        return matchingRule;
    }
View Full Code Here

                }
                return true;
            }
        } );
       
        MatchingRule matchingRule = new MatchingRule( "1.1.2.1" );
        matchingRule.setSyntax( syntax );


        matchingRule.setLdapComparator( new LdapComparator<String>( matchingRule.getOid() )
        {
            private static final long serialVersionUID = 0L;

            public int compare( String o1, String o2 )
            {
                return ( o1 == null ?
                    ( o2 == null ? 0 : -1 ) :
                    ( o2 == null ? 1 : o1.compareTo( o2 ) ) );
            }

            int getValue( String val )
            {
                if ( val.equals( "LOW" ) )
                {
                    return 0;
                }
                else if ( val.equals( "MEDIUM" ) )
                {
                    return 1;
                }
                else if ( val.equals( "HIGH" ) )
                {
                    return 2;
                }
               
                throw new IllegalArgumentException( I18n.err( I18n.ERR_472 ) );
            }
        } );
       
        Normalizer normalizer = new Normalizer( "1.1.1" )
        {
            private static final long serialVersionUID = 0L;

            public Value<?> normalize( Value<?> value ) throws NamingException
            {
                if ( !value.isBinary() )
                {
                    return new ClientStringValue( value.getString().toLowerCase() );
                }

                throw new IllegalStateException( I18n.err( I18n.ERR_473 ) );
            }
           
           
            public String normalize( String value ) throws NamingException
            {
                return value.toLowerCase();
            }
        };
       
        matchingRule.setNormalizer( normalizer );
       
        attributeType.setEquality( matchingRule );
        attributeType.setSyntax( syntax );
       
        return attributeType;
View Full Code Here

TOP

Related Classes of org.apache.directory.shared.ldap.schema.MatchingRule

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.