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

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


        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


                    ( o2 == null ? 0 : -1 ) :
                    ( o2 == null ? 1 : o1.compareTo( o2 ) ) );
            }
        } );
       
        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

               
                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

            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

        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 )
                    {
                        String message = I18n.err( I18n.ERR_04447_CANNOT_NORMALIZE_VALUE, ne.getLocalizedMessage() );
View Full Code Here

    private Normalizer classLoadNormalizer( SchemaManager schemaManager, String oid, String className,
        Attribute byteCode ) throws Exception
    {
        // Try to class load the normalizer
        Class<?> clazz = null;
        Normalizer normalizer = null;
        String byteCodeStr = StringConstants.EMPTY;

        if ( byteCode == null )
        {
            clazz = Class.forName( className );
        }
        else
        {
            classLoader.setAttribute( byteCode );
            clazz = classLoader.loadClass( className );
            byteCodeStr = new String( Base64.encode( byteCode.getBytes() ) );
        }

        // Create the normalizer instance
        normalizer = ( Normalizer ) clazz.newInstance();

        // Update the common fields
        normalizer.setBytecode( byteCodeStr );
        normalizer.setFqcn( className );

        // Inject the new OID, as the loaded normalizer might have its own
        normalizer.setOid( oid );

        // Inject the SchemaManager for the normalizer who needs it
        normalizer.setSchemaManager( schemaManager );

        return normalizer;
    }
View Full Code Here

        // get the byteCode
        Attribute byteCode = getByteCode( normalizerDescription, SchemaConstants.NORMALIZER );

        // Class load the normalizer
        Normalizer normalizer = classLoadNormalizer( schemaManager, oid, fqcn, byteCode );

        // Update the common fields
        setSchemaObjectProperties( normalizer, normalizerDescription, schema );

        return normalizer;
View Full Code Here

        Attribute byteCode = entry.get( MetaSchemaConstants.M_BYTECODE_AT );

        try
        {
            // Class load the Normalizer
            Normalizer normalizer = classLoadNormalizer( schemaManager, oid, className, byteCode );
   
            // Update the common fields
            setSchemaObjectProperties( normalizer, entry, schema );
   
            // return the resulting Normalizer
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.