You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@directory.apache.org by Emmanuel Lecharny <el...@gmail.com> on 2007/02/03 11:56:27 UTC

Re: svn commit: r502850 - in /directory/apacheds/trunk: core/src/main/java/org/apache/directory/server/core/schema/ schema-bootstrap/src/main/schema/

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

Re: svn commit: r502850 - in /directory/apacheds/trunk: core/src/main/java/org/apache/directory/server/core/schema/ schema-bootstrap/src/main/schema/

Posted by Alex Karasulu <ak...@apache.org>.
Emmanuel Lecharny wrote:
> 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 :
> 

...

> 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 ;)

Np I will do that where ever I can.  I did not know the Java 5 for loop 
also worked for arrays.  Doh!

Alex