directory-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Emmanuel Lecharny <elecha...@gmail.com>
Subject Re: svn commit: r502850 - in /directory/apacheds/trunk: core/src/main/java/org/apache/directory/server/core/schema/ schema-bootstrap/src/main/schema/
Date Sat, 03 Feb 2007 10:56:27 GMT
Alex,

you know that I don't like double i in "for ( int ii=0; ...)", so you 
will make me more than happy if you can use Java 5 cosntruct :

     public void modifySchemaSubentry( LdapDN name, ModificationItemImpl[] mods, Attributes
subentry, 
         Attributes targetSubentry ) throws NamingException
     {
        for ( ModificationItemImpl mod:mods )
        {
            switch ( mod.getModificationOp() )
            {
                case( DirContext.ADD_ATTRIBUTE ):
                    break;
                case( DirContext.REMOVE_ATTRIBUTE ):
                    break;
                case( DirContext.REPLACE_ATTRIBUTE ):
                    break;
                default:
                    throw new IllegalStateException( "Undefined modify operation: " + mod.getModificationOp()
);
            }
        }
    }

instead of :

     public void modifySchemaSubentry( LdapDN name, ModificationItemImpl[] mods, Attributes
subentry, 
         Attributes targetSubentry ) throws NamingException
     {
        for ( int ii = 0; ii < mods.length; ii++ )
        {
            switch ( mods[ii].getModificationOp() )
            {
                case( DirContext.ADD_ATTRIBUTE ):
                    break;
                case( DirContext.REMOVE_ATTRIBUTE ):
                    break;
                case( DirContext.REPLACE_ATTRIBUTE ):
                    break;
                default:
                    throw new IllegalStateException( "Undefined modify operation: " + mods[ii].getModificationOp()
);
            }
        }
     }


Of course, if it's not possible, like in the loop :

>    private void initHandlerMaps() throws NamingException
>    {
>        AttributeTypeRegistry atReg = globalRegistries.getAttributeTypeRegistry();
>        for ( int ii = 0; ii < opAttrs.length; ii++ )
>        {
>            AttributeType at = atReg.lookup( opAttrs[ii] );
>            opAttr2handlerMap.put( at.getOid(), schemaObjectHandlers[ii] );
>        }
>  
>
I would just swallow the ii :)

Ok, to be frank, it's just a matter of using Java 5 construct when it's 
possible, not a religious war about double ii ;)

Emmanuel

Mime
View raw message