}    for( int ii = 0; ii < attribute.size(); ii++ ) { Object value = attribute.get( ii ); if ( "".equals( value ) ) { attribute.remove( ii ); }
    public static void preventStructuralClassRemovalOnModifyRemove( ObjectClassRegistry registry, Name name, int mod,        Attribute attribute, Attribute entryObjectClasses ) throws NamingException    {        if ( mod != DirContext.REMOVE_ATTRIBUTE )        {            return;        }        if ( !"objectclass".equalsIgnoreCase( attribute.getID() ) )        {            return;        }        // whoever issued the modify operation is insane they want to delete        // all the objectClass values in which case we must throw an exception        if ( attribute.size() == 0 )        {            String msg = "Modify operation leaves no structural objectClass for entry " + name;            if ( log.isInfoEnabled() )            {                log.info( msg + ".  Raising LdapSchemaViolationException." );            }            throw new LdapSchemaViolationException( msg, ResultCodeEnum.OBJECTCLASSMODSPROHIBITED );        }        // remove all the objectClass attribute values from a cloned copy and then        // we can analyze what remains in this attribute to make sure a structural        // objectClass is present for the entry        Attribute cloned = ( Attribute ) entryObjectClasses.clone();        for ( int ii = 0; ii < attribute.size(); ii++ )        {            cloned.remove( attribute.get( ii ) );        }        // check resultant set of objectClass values for a structural objectClass        for ( int ii = 0; ii < cloned.size(); ii++ )        {            ObjectClass ocType = registry.lookup( ( String ) cloned.get( ii ) );            if ( ocType.getType() == ObjectClassTypeEnum.STRUCTURAL )            {                return;            }        }        // no structural object classes exist for the entry after the modifications        // to the objectClass attribute so we need to complain about that        String msg = "Modify operation leaves no structural objectClass for entry " + name;        if ( log.isInfoEnabled() )        {            log.info( msg + ".  Raising LdapSchemaViolationException." );        }        throw new LdapSchemaViolationException( msg, ResultCodeEnum.OBJECTCLASSMODSPROHIBITED );    }