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

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


    }


    /* No protection */static AttributeType getBytesAttributeType()
    {
        MutableAttributeType attributeType = new MutableAttributeType( "1.2" );
        LdapSyntax syntax = new LdapSyntax( "1.2.1", "", false );

        syntax.setSyntaxChecker( new SyntaxChecker( "1.2.1" )
        {
            public static final long serialVersionUID = 1L;


            public boolean isValidSyntax( Object value )
            {
                return ( value == null ) || ( ( ( byte[] ) value ).length < 5 );
            }
        } );

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

        matchingRule.setLdapComparator( new ByteArrayComparator( "1.2.2" ) );

        matchingRule.setNormalizer( new Normalizer( "1.1.1" )
        {
            public static final long serialVersionUID = 1L;


            public Value<?> normalize( Value<?> value ) throws LdapException
            {
                if ( !value.isHumanReadable() )
                {
                    byte[] val = value.getBytes();

                    // each byte will be changed to be > 0, and spaces will be trimmed
                    byte[] newVal = new byte[val.length];

                    int i = 0;

                    for ( byte b : val )
                    {
                        newVal[i++] = ( byte ) ( b & 0x007F );
                    }

                    return new BinaryValue( Strings.trim( newVal ) );
                }

                throw new IllegalStateException( I18n.err( I18n.ERR_04475 ) );
            }


            public String normalize( String value ) throws LdapException
            {
                throw new IllegalStateException( I18n.err( I18n.ERR_04475 ) );
            }
        } );

        attributeType.setEquality( matchingRule );
        attributeType.setSyntax( syntax );

        return attributeType;
    }
View Full Code Here


            {
                throw new IllegalStateException( "expected byte[] to normalize" );
            }
        } );

        at = new MutableAttributeType( "1.1.3.1" );
        at.setEquality( mr );
        at.setOrdering( mr );
        at.setSubstring( mr );
        at.setSyntax( s );
    }
View Full Code Here

                    }
                }
                // ATTRIBUTE TYPE
                else if ( selectedElement instanceof AttributeTypeWrapper )
                {
                    MutableAttributeType attributeType = ( MutableAttributeType ) ( ( AttributeTypeWrapper ) selectedElement )
                        .getAttributeType();

                    RenameAttributeTypeDialog dialog = new RenameAttributeTypeDialog( attributeType.getNames() );
                    if ( dialog.open() == RenameAttributeTypeDialog.OK )
                    {
                        MutableAttributeType modifiedAttributeType = PluginUtils.getClone( attributeType );
                        modifiedAttributeType.setNames( dialog.getAliases() );
                        Activator.getDefault().getSchemaHandler()
                            .modifyAttributeType( attributeType, modifiedAttributeType );
                    }
                }
                // OBJECT CLASS
View Full Code Here

     * @return
     *      a clone of the given attribute type
     */
    public static MutableAttributeType getClone( AttributeType at )
    {
        MutableAttributeType clone = new MutableAttributeType( at.getOid() );
        clone.setNames( at.getNames() );
        clone.setSchemaName( at.getSchemaName() );
        clone.setDescription( at.getDescription() );
        clone.setSuperiorOid( at.getSuperiorOid() );
        clone.setUsage( at.getUsage() );
        clone.setSyntaxOid( at.getSyntaxOid() );
        clone.setSyntaxLength( at.getSyntaxLength() );
        clone.setObsolete( at.isObsolete() );
        clone.setSingleValued( at.isSingleValued() );
        clone.setCollective( at.isCollective() );
        clone.setUserModifiable( at.isUserModifiable() );
        clone.setEqualityOid( at.getEqualityOid() );
        clone.setOrderingOid( at.getOrderingOid() );
        clone.setSubstringOid( at.getSubstringOid() );

        return clone;
    }
View Full Code Here

TOP

Related Classes of org.apache.directory.api.ldap.model.schema.MutableAttributeType

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.