directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r993315 [1/2] - in /directory/shared/trunk: i18n/src/main/java/org/apache/directory/shared/i18n/ i18n/src/main/resources/org/apache/directory/shared/i18n/ ldap-ldif/src/main/java/org/apache/directory/shared/ldap/ldif/ ldap-ldif/src/test/jav...
Date Tue, 07 Sep 2010 10:41:57 GMT
Author: elecharny
Date: Tue Sep  7 10:41:57 2010
New Revision: 993315

URL: http://svn.apache.org/viewvc?rev=993315&view=rev
Log:
Reviewed some files

Modified:
    directory/shared/trunk/i18n/src/main/java/org/apache/directory/shared/i18n/I18n.java
    directory/shared/trunk/i18n/src/main/resources/org/apache/directory/shared/i18n/errors.properties
    directory/shared/trunk/ldap-ldif/src/main/java/org/apache/directory/shared/ldap/ldif/ChangeType.java
    directory/shared/trunk/ldap-ldif/src/main/java/org/apache/directory/shared/ldap/ldif/LdapLdifException.java
    directory/shared/trunk/ldap-ldif/src/main/java/org/apache/directory/shared/ldap/ldif/LdifAttributesReader.java
    directory/shared/trunk/ldap-ldif/src/main/java/org/apache/directory/shared/ldap/ldif/LdifControl.java
    directory/shared/trunk/ldap-ldif/src/main/java/org/apache/directory/shared/ldap/ldif/LdifEntry.java
    directory/shared/trunk/ldap-ldif/src/main/java/org/apache/directory/shared/ldap/ldif/LdifReader.java
    directory/shared/trunk/ldap-ldif/src/main/java/org/apache/directory/shared/ldap/ldif/LdifRevertor.java
    directory/shared/trunk/ldap-ldif/src/main/java/org/apache/directory/shared/ldap/ldif/LdifUtils.java
    directory/shared/trunk/ldap-ldif/src/test/java/org/apache/directory/shared/ldap/ldif/LdifAttributesReaderTest.java

Modified: directory/shared/trunk/i18n/src/main/java/org/apache/directory/shared/i18n/I18n.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/i18n/src/main/java/org/apache/directory/shared/i18n/I18n.java?rev=993315&r1=993314&r2=993315&view=diff
==============================================================================
--- directory/shared/trunk/i18n/src/main/java/org/apache/directory/shared/i18n/I18n.java (original)
+++ directory/shared/trunk/i18n/src/main/java/org/apache/directory/shared/i18n/I18n.java Tue Sep  7 10:41:57 2010
@@ -693,23 +693,23 @@ public enum I18n
     ERR_11013( "ERR_11013" ),
 
     // ldap-schema-manager
-    ERR_12001( "ERR_12001" ),
-    ERR_12002( "ERR_12002" ),
-    ERR_12003( "ERR_12003" ),
-    ERR_12004( "ERR_12004" ),
-    ERR_12005( "ERR_12005" ),
-    ERR_12006( "ERR_12006" ),
-    ERR_12007( "ERR_12007" ),
-    ERR_12008( "ERR_12008" ),
-    ERR_12009( "ERR_12009" ),
-    ERR_12010( "ERR_12010" ),
-    ERR_12011( "ERR_12011" ),
-    ERR_12012( "ERR_12012" ),
-    ERR_12013( "ERR_12013" ),
-    ERR_12014( "ERR_12014" ),
-    ERR_12015( "ERR_12015" ),
-    ERR_12016( "ERR_12016" ),
-    ERR_12017( "ERR_12017" ),
+    ERR_12001_UNKNOWN_CHANGE_TYPE( "ERR_12001_UNKNOWN_CHANGE_TYPE" ),
+    ERR_12002_ENTRY_WITH_TWO_DNS( "ERR_12002_ENTRY_WITH_TWO_DNS" ),
+    ERR_12003_LDIF_ENTRY_WITH_TWO_DNS( "ERR_12003_LDIF_ENTRY_WITH_TWO_DNS" ),
+    ERR_12004_CHANGE_NOT_ALLOWED( "ERR_12004_CHANGE_NOT_ALLOWED" ),
+    ERR_12005_NO_CHANGE( "ERR_12005_NO_CHANGE" ),
+    ERR_12006_EXPECTING_ATTRIBUTE_TYPE( "ERR_12006_EXPECTING_ATTRIBUTE_TYPE" ),
+    ERR_12007_BAD_ATTRIBUTE( "ERR_12007_BAD_ATTRIBUTE" ),
+    ERR_12008_CANNOT_PARSE_LDIF_BUFFER( "ERR_12008_CANNOT_PARSE_LDIF_BUFFER" ),
+    ERR_12009_ERROR_PARSING_LDIF_BUFFER( "ERR_12009_ERROR_PARSING_LDIF_BUFFER" ),
+    ERR_12010_CANNOT_FIND_FILE( "ERR_12010_CANNOT_FIND_FILE" ),
+    ERR_12011_CANNOT_READ_FILE( "ERR_12011_CANNOT_READ_FILE" ),
+    ERR_12012_EMPTY_DN_NOT_ALLOWED( "ERR_12012_EMPTY_DN_NOT_ALLOWED" ),
+    ERR_12013_NO_DN( "ERR_12013_NO_DN" ),
+    ERR_12014_BASE64_DN_EXPECTED( "ERR_12014_BASE64_DN_EXPECTED" ),
+    ERR_12015_INVALID_BASE64_DN( "ERR_12015_INVALID_BASE64_DN" ),
+    ERR_12016_DN_EXPECTED( "ERR_12016_DN_EXPECTED" ),
+    ERR_12017_INVALID_DN( "ERR_12017_INVALID_DN" ),
     ERR_12018( "ERR_12018" ),
     ERR_12019( "ERR_12019" ),
     ERR_12020( "ERR_12020" ),

Modified: directory/shared/trunk/i18n/src/main/resources/org/apache/directory/shared/i18n/errors.properties
URL: http://svn.apache.org/viewvc/directory/shared/trunk/i18n/src/main/resources/org/apache/directory/shared/i18n/errors.properties?rev=993315&r1=993314&r2=993315&view=diff
==============================================================================
--- directory/shared/trunk/i18n/src/main/resources/org/apache/directory/shared/i18n/errors.properties (original)
+++ directory/shared/trunk/i18n/src/main/resources/org/apache/directory/shared/i18n/errors.properties Tue Sep  7 10:41:57 2010
@@ -679,23 +679,23 @@ ERR_11012=Cannot remove {0} for the regi
 ERR_11013=Cannot delete the SchemaObject {0} as it's not associated with a schema
 
 # ldif
-ERR_12001=Unknown change type value {0}
-ERR_12002=An entry must not have two DNs
-ERR_12003=A ldif entry should not have two DNs
-ERR_12004=We cannot have changes when reading a file which already contains entries
-ERR_12005=No changes within entries
-ERR_12006=Expecting an attribute type
-ERR_12007=Bad attribute
-ERR_12008=Cannot parse the ldif buffer : {0}
-ERR_12009=Error while parsing the ldif buffer
-ERR_12010=Cannot find file {0}
-ERR_12011=Cannot read file {0}
-ERR_12012=A ldif entry must have a non empty DN
-ERR_12013=No DN for entry
-ERR_12014=The ldif entry is supposed to have a base 64 encoded DN
-ERR_12015=Invalid base 64 encoded DN
-ERR_12016=A ldif entry must start with a DN
-ERR_12017=The DN {0} is not valid
+ERR_12001_UNKNOWN_CHANGE_TYPE=Unknown change type value {0}
+ERR_12002_ENTRY_WITH_TWO_DNS=An entry must not have two DNs
+ERR_12003_LDIF_ENTRY_WITH_TWO_DNS=A ldif entry should not have two DNs
+ERR_12004_CHANGE_NOT_ALLOWED=We cannot have changes when reading a file which already contains entries
+ERR_12005_NO_CHANGE=No changes within entries
+ERR_12006_EXPECTING_ATTRIBUTE_TYPE=Expecting an attribute type
+ERR_12007_BAD_ATTRIBUTE=Bad attribute
+ERR_12008_CANNOT_PARSE_LDIF_BUFFER=Cannot parse the ldif buffer : {0}
+ERR_12009_ERROR_PARSING_LDIF_BUFFER=Error while parsing the ldif buffer
+ERR_12010_CANNOT_FIND_FILE=Cannot find file {0}
+ERR_12011_CANNOT_READ_FILE=Cannot read file {0}
+ERR_12012_EMPTY_DN_NOT_ALLOWED=A ldif entry must have a non empty DN
+ERR_12013_NO_DN=No DN for entry
+ERR_12014_BASE64_DN_EXPECTED=The ldif entry is supposed to have a base 64 encoded DN
+ERR_12015_INVALID_BASE64_DN=Invalid base 64 encoded DN
+ERR_12016_DN_EXPECTED=A ldif entry must start with a DN
+ERR_12017_INVALID_DN=The DN {0} is not valid
 ERR_12018=File {0} not found
 ERR_12019=Bad URL, file not found
 ERR_12020=File {0} is too big

Modified: directory/shared/trunk/ldap-ldif/src/main/java/org/apache/directory/shared/ldap/ldif/ChangeType.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap-ldif/src/main/java/org/apache/directory/shared/ldap/ldif/ChangeType.java?rev=993315&r1=993314&r2=993315&view=diff
==============================================================================
--- directory/shared/trunk/ldap-ldif/src/main/java/org/apache/directory/shared/ldap/ldif/ChangeType.java (original)
+++ directory/shared/trunk/ldap-ldif/src/main/java/org/apache/directory/shared/ldap/ldif/ChangeType.java Tue Sep  7 10:41:57 2010
@@ -19,6 +19,7 @@
  */
 package org.apache.directory.shared.ldap.ldif;
 
+
 import org.apache.directory.shared.i18n.I18n;
 
 
@@ -29,13 +30,24 @@ import org.apache.directory.shared.i18n.
  */
 public enum ChangeType
 {
-    Add( 0 ),
-    Modify( 1 ),
-    ModDn( 2 ),
-    ModRdn( 3 ),
-    Delete( 4 ),
+    /** The Add changeType */
+    Add(0),
+
+    /** The Modify changeType */
+    Modify(1),
+
+    /** The ModDn changeType */
+    ModDn(2),
+
+    /** The ModRdn changeType */
+    ModRdn(3),
+
+    /** The Delete changeType */
+    Delete(4),
+
+    /** A placeholder when we have no changeType */
     None(-1);
-    
+
     /** Add ordinal value */
     public static final int ADD_ORDINAL = 0;
 
@@ -54,14 +66,14 @@ public enum ChangeType
     /** None ordinal value */
     public static final int NONE_ORDINAL = -1;
 
-    /* the ordinal value for a change type */
+    /** the ordinal value for a change type */
     private final int changeType;
-    
-    
+
+
     /**
      * Creates a new instance of ChangeType.
      *
-     * @param changeType
+     * @param changeType The associated value 
      */
     private ChangeType( int changeType )
     {
@@ -78,25 +90,38 @@ public enum ChangeType
     {
         return changeType;
     }
-    
+
+
+    /**
+     * Get the ChangeType instance from an integer value 
+     *
+     * @param val The value for the ChangeType we are looking for
+     * @return The associated ChangeType instance
+     */
     public static ChangeType getChangeType( int val )
     {
-        switch( val )
+        switch ( val )
         {
-            case -1: return None;
-            
-            case 0: return Add;
-            
-            case 1: return Modify;
-            
-            case 2: return ModDn;
-            
-            case 3: return ModRdn;
-            
-            case 4: return Delete;
-            
+            case -1:
+                return None;
+
+            case 0:
+                return Add;
+
+            case 1:
+                return Modify;
+
+            case 2:
+                return ModDn;
+
+            case 3:
+                return ModRdn;
+
+            case 4:
+                return Delete;
+
             default:
-                throw new IllegalArgumentException( I18n.err( I18n.ERR_12001, val ) );
+                throw new IllegalArgumentException( I18n.err( I18n.ERR_12001_UNKNOWN_CHANGE_TYPE, val ) );
         }
     }
 }

Modified: directory/shared/trunk/ldap-ldif/src/main/java/org/apache/directory/shared/ldap/ldif/LdapLdifException.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap-ldif/src/main/java/org/apache/directory/shared/ldap/ldif/LdapLdifException.java?rev=993315&r1=993314&r2=993315&view=diff
==============================================================================
--- directory/shared/trunk/ldap-ldif/src/main/java/org/apache/directory/shared/ldap/ldif/LdapLdifException.java (original)
+++ directory/shared/trunk/ldap-ldif/src/main/java/org/apache/directory/shared/ldap/ldif/LdapLdifException.java Tue Sep  7 10:41:57 2010
@@ -19,6 +19,7 @@
  */
 package org.apache.directory.shared.ldap.ldif;
 
+
 import org.apache.directory.shared.ldap.exception.LdapException;
 
 
@@ -29,9 +30,10 @@ import org.apache.directory.shared.ldap.
  */
 public class LdapLdifException extends LdapException
 {
-    /** The serial version UUID */
+    /** The serial version UID */
     private static final long serialVersionUID = 1L;
-    
+
+
     /**
      * Creates a new instance of LdapLdifException.
      *

Modified: directory/shared/trunk/ldap-ldif/src/main/java/org/apache/directory/shared/ldap/ldif/LdifAttributesReader.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap-ldif/src/main/java/org/apache/directory/shared/ldap/ldif/LdifAttributesReader.java?rev=993315&r1=993314&r2=993315&view=diff
==============================================================================
--- directory/shared/trunk/ldap-ldif/src/main/java/org/apache/directory/shared/ldap/ldif/LdifAttributesReader.java (original)
+++ directory/shared/trunk/ldap-ldif/src/main/java/org/apache/directory/shared/ldap/ldif/LdifAttributesReader.java Tue Sep  7 10:41:57 2010
@@ -19,12 +19,12 @@
  */
 package org.apache.directory.shared.ldap.ldif;
 
+
 import java.io.BufferedReader;
 import java.io.IOException;
 import java.io.StringReader;
 import java.util.ArrayList;
 
-import javax.naming.NamingException;
 import javax.naming.directory.Attribute;
 import javax.naming.directory.Attributes;
 import javax.naming.directory.BasicAttributes;
@@ -40,6 +40,7 @@ import org.apache.directory.shared.ldap.
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+
 /**
  * <pre>
  *  &lt;ldif-file&gt; ::= &quot;version:&quot; &lt;fill&gt; &lt;number&gt; &lt;seps&gt; &lt;dn-spec&gt; &lt;sep&gt;
@@ -151,13 +152,14 @@ public class LdifAttributesReader extend
     /** A logger */
     private static final Logger LOG = LoggerFactory.getLogger( LdifAttributesReader.class );
 
+
     /**
      * Constructors
      */
     public LdifAttributesReader()
     {
         lines = new ArrayList<String>();
-        position = new Position();
+        position = 0;
         version = DEFAULT_VERSION;
     }
 
@@ -168,7 +170,7 @@ public class LdifAttributesReader extend
      * @param attributes The entry where to store the value
      * @param line The line to parse
      * @param lowerLine The same line, lowercased
-     * @throws NamingException If anything goes wrong
+     * @throws LdapLdifException If anything goes wrong
      */
     private void parseAttribute( Attributes attributes, String line, String lowerLine ) throws LdapLdifException
     {
@@ -179,8 +181,8 @@ public class LdifAttributesReader extend
         // We should *not* have a DN twice
         if ( attributeType.equals( "dn" ) )
         {
-            LOG.error( I18n.err( I18n.ERR_12002 ) );
-            throw new LdapLdifException( I18n.err( I18n.ERR_12003 ) );
+            LOG.error( I18n.err( I18n.ERR_12002_ENTRY_WITH_TWO_DNS ) );
+            throw new LdapLdifException( I18n.err( I18n.ERR_12003_LDIF_ENTRY_WITH_TWO_DNS ) );
         }
 
         Object attributeValue = parseValue( line, colonIndex );
@@ -199,17 +201,17 @@ public class LdifAttributesReader extend
     }
 
 
-
-
     /**
      * Parse an AttributeType/AttributeValue
      *
-     * @param attributes The entry where to store the value
+     * @param schemaManager The SchemaManager
+     * @param entry The entry where to store the value
      * @param line The line to parse
      * @param lowerLine The same line, lowercased
-     * @throws NamingException If anything goes wrong
+     * @throws LdapLdifException If anything goes wrong
      */
-    private void parseEntryAttribute( SchemaManager schemaManager, Entry entry, String line, String lowerLine ) throws LdapLdifException
+    private void parseEntryAttribute( SchemaManager schemaManager, Entry entry, String line, String lowerLine )
+        throws LdapLdifException
     {
         int colonIndex = line.indexOf( ':' );
 
@@ -219,13 +221,15 @@ public class LdifAttributesReader extend
         // We should *not* have a DN twice
         if ( attributeName.equals( "dn" ) )
         {
-            LOG.error( I18n.err( I18n.ERR_12002 ) );
-            throw new LdapLdifException( I18n.err( I18n.ERR_12003 ) );
+            LOG.error( I18n.err( I18n.ERR_12002_ENTRY_WITH_TWO_DNS ) );
+            throw new LdapLdifException( I18n.err( I18n.ERR_12003_LDIF_ENTRY_WITH_TWO_DNS ) );
         }
 
         if ( schemaManager != null )
         {
-            if ( ( attributeType = schemaManager.getAttributeType( attributeName ) ) == null )
+            attributeType = schemaManager.getAttributeType( attributeName );
+
+            if ( attributeType == null )
             {
                 LOG.error( "" );
                 throw new LdapLdifException( "" );
@@ -252,11 +256,11 @@ public class LdifAttributesReader extend
             {
                 if ( attributeValue instanceof String )
                 {
-                    entry.put( attributeName, (String)attributeValue );
+                    entry.put( attributeName, ( String ) attributeValue );
                 }
                 else
                 {
-                    entry.put( attributeName, (byte[])attributeValue );
+                    entry.put( attributeName, ( byte[] ) attributeValue );
                 }
             }
             else
@@ -265,15 +269,16 @@ public class LdifAttributesReader extend
                 {
                     if ( attributeValue instanceof String )
                     {
-                        entry.put( attributeName, attributeType, (String)attributeValue );
+                        entry.put( attributeName, attributeType, ( String ) attributeValue );
                     }
                     else
                     {
-                        entry.put( attributeName, attributeType, (byte[])attributeValue );
+                        entry.put( attributeName, attributeType, ( byte[] ) attributeValue );
                     }
                 }
                 catch ( LdapException le )
                 {
+                    // 
                 }
             }
         }
@@ -281,11 +286,11 @@ public class LdifAttributesReader extend
         {
             if ( attributeValue instanceof String )
             {
-                attribute.add( (String)attributeValue );
+                attribute.add( ( String ) attributeValue );
             }
             else
             {
-                attribute.add( (byte[])attributeValue );
+                attribute.add( ( byte[] ) attributeValue );
             }
         }
     }
@@ -301,6 +306,7 @@ public class LdifAttributesReader extend
      * &lt;distinguishedName&gt; | "dn::" &lt;fill&gt; &lt;base64-distinguishedName&gt;
      * &lt;changerecord&gt; ::= "changetype:" &lt;fill&gt; &lt;change-op&gt;
      *
+     * @param schemaManager The SchemaManager
      * @return The read entry
      * @throws LdapLdifException If the entry can't be read or is invalid
      */
@@ -324,7 +330,7 @@ public class LdifAttributesReader extend
         }
 
         // Now, let's iterate through the other lines
-        for ( String line:lines )
+        for ( String line : lines )
         {
             // Each line could start either with an OID, an attribute type, with
             // "control:" or with "changetype:"
@@ -336,13 +342,13 @@ public class LdifAttributesReader extend
             // 3) The first line after the DN is anything else
             if ( lowerLine.startsWith( "control:" ) )
             {
-                LOG.error( I18n.err( I18n.ERR_12004 ) );
-                throw new LdapLdifException( I18n.err( I18n.ERR_12005 ) );
+                LOG.error( I18n.err( I18n.ERR_12004_CHANGE_NOT_ALLOWED ) );
+                throw new LdapLdifException( I18n.err( I18n.ERR_12005_NO_CHANGE ) );
             }
             else if ( lowerLine.startsWith( "changetype:" ) )
             {
-                LOG.error( I18n.err( I18n.ERR_12004 ) );
-                throw new LdapLdifException( I18n.err( I18n.ERR_12005 ) );
+                LOG.error( I18n.err( I18n.ERR_12004_CHANGE_NOT_ALLOWED ) );
+                throw new LdapLdifException( I18n.err( I18n.ERR_12005_NO_CHANGE ) );
             }
             else if ( line.indexOf( ':' ) > 0 )
             {
@@ -351,8 +357,8 @@ public class LdifAttributesReader extend
             else
             {
                 // Invalid attribute Value
-                LOG.error( I18n.err( I18n.ERR_12006 ) );
-                throw new LdapLdifException( I18n.err( I18n.ERR_12007 ) );
+                LOG.error( I18n.err( I18n.ERR_12006_EXPECTING_ATTRIBUTE_TYPE ) );
+                throw new LdapLdifException( I18n.err( I18n.ERR_12007_BAD_ATTRIBUTE ) );
             }
         }
 
@@ -373,7 +379,7 @@ public class LdifAttributesReader extend
      * &lt;changerecord&gt; ::= "changetype:" &lt;fill&gt; &lt;change-op&gt;
      *
      * @return The read entry
-     * @throws NamingException If the entry can't be read or is invalid
+     * @throws LdapLdifException If the entry can't be read or is invalid
      */
     private Attributes parseAttributes() throws LdapLdifException
     {
@@ -386,7 +392,7 @@ public class LdifAttributesReader extend
         Attributes attributes = new BasicAttributes( true );
 
         // Now, let's iterate through the other lines
-        for ( String line:lines )
+        for ( String line : lines )
         {
             // Each line could start either with an OID, an attribute type, with
             // "control:" or with "changetype:"
@@ -398,13 +404,13 @@ public class LdifAttributesReader extend
             // 3) The first line after the DN is anything else
             if ( lowerLine.startsWith( "control:" ) )
             {
-                LOG.error( I18n.err( I18n.ERR_12004 ) );
-                throw new LdapLdifException( I18n.err( I18n.ERR_12005 ) );
+                LOG.error( I18n.err( I18n.ERR_12004_CHANGE_NOT_ALLOWED ) );
+                throw new LdapLdifException( I18n.err( I18n.ERR_12005_NO_CHANGE ) );
             }
             else if ( lowerLine.startsWith( "changetype:" ) )
             {
-                LOG.error( I18n.err( I18n.ERR_12004 ) );
-                throw new LdapLdifException( I18n.err( I18n.ERR_12005 ) );
+                LOG.error( I18n.err( I18n.ERR_12004_CHANGE_NOT_ALLOWED ) );
+                throw new LdapLdifException( I18n.err( I18n.ERR_12005_NO_CHANGE ) );
             }
             else if ( line.indexOf( ':' ) > 0 )
             {
@@ -413,8 +419,8 @@ public class LdifAttributesReader extend
             else
             {
                 // Invalid attribute Value
-                LOG.error( I18n.err( I18n.ERR_12006 ) );
-                throw new LdapLdifException( I18n.err( I18n.ERR_12007 ) );
+                LOG.error( I18n.err( I18n.ERR_12006_EXPECTING_ATTRIBUTE_TYPE ) );
+                throw new LdapLdifException( I18n.err( I18n.ERR_12007_BAD_ATTRIBUTE ) );
             }
         }
 
@@ -436,7 +442,7 @@ public class LdifAttributesReader extend
     public Attributes parseAttributes( String ldif ) throws LdapLdifException
     {
         lines = new ArrayList<String>();
-        position = new Position();
+        position = 0;
 
         LOG.debug( "Starts parsing ldif buffer" );
 
@@ -456,15 +462,22 @@ public class LdifAttributesReader extend
 
             if ( LOG.isDebugEnabled() )
             {
-                LOG.debug( "Parsed {} entries.", ( attributes == null ? 0 : 1 ) );
+                if ( attributes == null )
+                {
+                    LOG.debug( "Parsed no entry." );
+                }
+                else
+                {
+                    LOG.debug( "Parsed one entry." );
+                }
             }
 
             return attributes;
         }
-        catch (LdapLdifException ne)
+        catch ( LdapLdifException ne )
         {
-            LOG.error( I18n.err( I18n.ERR_12008, ne.getLocalizedMessage() ) );
-            throw new LdapLdifException( I18n.err( I18n.ERR_12009 ) );
+            LOG.error( I18n.err( I18n.ERR_12008_CANNOT_PARSE_LDIF_BUFFER, ne.getLocalizedMessage() ) );
+            throw new LdapLdifException( I18n.err( I18n.ERR_12009_ERROR_PARSING_LDIF_BUFFER ) );
         }
         finally
         {
@@ -492,7 +505,7 @@ public class LdifAttributesReader extend
     public Entry parseEntry( String ldif ) throws LdapLdifException
     {
         lines = new ArrayList<String>();
-        position = new Position();
+        position = 0;
 
         LOG.debug( "Starts parsing ldif buffer" );
 
@@ -508,19 +521,27 @@ public class LdifAttributesReader extend
         {
             readLines();
 
-            Entry entry = parseEntry( (SchemaManager)null );
+            Entry entry = parseEntry( ( SchemaManager ) null );
 
             if ( LOG.isDebugEnabled() )
             {
-                LOG.debug( "Parsed {} entries.", ( entry == null ? 0 : 1 ) );
+                if ( entry == null )
+                {
+                    LOG.debug( "Parsed no entry." );
+                }
+                else
+                {
+                    LOG.debug( "Parsed one entry." );
+                }
+
             }
 
             return entry;
         }
-        catch (LdapLdifException ne)
+        catch ( LdapLdifException ne )
         {
-            LOG.error( I18n.err( I18n.ERR_12008, ne.getLocalizedMessage() ) );
-            throw new LdapLdifException( I18n.err( I18n.ERR_12009 ) );
+            LOG.error( I18n.err( I18n.ERR_12008_CANNOT_PARSE_LDIF_BUFFER, ne.getLocalizedMessage() ) );
+            throw new LdapLdifException( I18n.err( I18n.ERR_12009_ERROR_PARSING_LDIF_BUFFER ) );
         }
         finally
         {
@@ -539,6 +560,7 @@ public class LdifAttributesReader extend
     /**
      * A method which parses a ldif string and returns an Entry.
      *
+     * @param schemaManager The SchemaManager
      * @param ldif The ldif string
      * @return An entry
      * @throws LdapLdifException If something went wrong
@@ -548,7 +570,7 @@ public class LdifAttributesReader extend
     public Entry parseEntry( SchemaManager schemaManager, String ldif ) throws LdapLdifException
     {
         lines = new ArrayList<String>();
-        position = new Position();
+        position = 0;
 
         LOG.debug( "Starts parsing ldif buffer" );
 
@@ -568,15 +590,23 @@ public class LdifAttributesReader extend
 
             if ( LOG.isDebugEnabled() )
             {
-                LOG.debug( "Parsed {} entries.", ( entry == null ? 0 : 1 ) );
+                if ( entry == null )
+                {
+                    LOG.debug( "Parsed no entry." );
+                }
+                else
+                {
+                    LOG.debug( "Parsed one entry." );
+                }
+
             }
 
             return entry;
         }
-        catch (LdapLdifException ne)
+        catch ( LdapLdifException ne )
         {
-            LOG.error( I18n.err( I18n.ERR_12008, ne.getLocalizedMessage() ) );
-            throw new LdapLdifException( I18n.err( I18n.ERR_12009 ) );
+            LOG.error( I18n.err( I18n.ERR_12008_CANNOT_PARSE_LDIF_BUFFER, ne.getLocalizedMessage() ) );
+            throw new LdapLdifException( I18n.err( I18n.ERR_12009_ERROR_PARSING_LDIF_BUFFER ) );
         }
         finally
         {

Modified: directory/shared/trunk/ldap-ldif/src/main/java/org/apache/directory/shared/ldap/ldif/LdifControl.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap-ldif/src/main/java/org/apache/directory/shared/ldap/ldif/LdifControl.java?rev=993315&r1=993314&r2=993315&view=diff
==============================================================================
--- directory/shared/trunk/ldap-ldif/src/main/java/org/apache/directory/shared/ldap/ldif/LdifControl.java (original)
+++ directory/shared/trunk/ldap-ldif/src/main/java/org/apache/directory/shared/ldap/ldif/LdifControl.java Tue Sep  7 10:41:57 2010
@@ -20,9 +20,11 @@
 
 package org.apache.directory.shared.ldap.ldif;
 
+
 import org.apache.directory.shared.ldap.codec.controls.AbstractControl;
 import org.apache.directory.shared.ldap.util.StringTools;
 
+
 /**
  * The LdifControl class stores a control defined for an entry found in a ldif
  * file.
@@ -31,8 +33,10 @@ import org.apache.directory.shared.ldap.
  */
 public class LdifControl extends AbstractControl
 {
+    /** The serial version UID */
     private static final long serialVersionUID = 1L;
 
+
     /**
      * Create a new Control
      * 
@@ -43,6 +47,10 @@ public class LdifControl extends Abstrac
         super( oid );
     }
 
+
+    /**
+     * {@inheritDoc}
+     */
     public String toString()
     {
         return "LdifControl : {" + getOid() + ", " + isCritical() + ", " + StringTools.dumpBytes( getValue() ) + "}";

Modified: directory/shared/trunk/ldap-ldif/src/main/java/org/apache/directory/shared/ldap/ldif/LdifEntry.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap-ldif/src/main/java/org/apache/directory/shared/ldap/ldif/LdifEntry.java?rev=993315&r1=993314&r2=993315&view=diff
==============================================================================
--- directory/shared/trunk/ldap-ldif/src/main/java/org/apache/directory/shared/ldap/ldif/LdifEntry.java (original)
+++ directory/shared/trunk/ldap-ldif/src/main/java/org/apache/directory/shared/ldap/ldif/LdifEntry.java Tue Sep  7 10:41:57 2010
@@ -20,6 +20,7 @@
 
 package org.apache.directory.shared.ldap.ldif;
 
+
 import java.io.Externalizable;
 import java.io.IOException;
 import java.io.ObjectInput;
@@ -32,13 +33,13 @@ import java.util.concurrent.ConcurrentHa
 
 import org.apache.directory.shared.ldap.codec.controls.ControlImpl;
 import org.apache.directory.shared.ldap.entry.DefaultEntry;
-import org.apache.directory.shared.ldap.entry.DefaultModification;
 import org.apache.directory.shared.ldap.entry.DefaultEntryAttribute;
-import org.apache.directory.shared.ldap.entry.StringValue;
+import org.apache.directory.shared.ldap.entry.DefaultModification;
 import org.apache.directory.shared.ldap.entry.Entry;
 import org.apache.directory.shared.ldap.entry.EntryAttribute;
 import org.apache.directory.shared.ldap.entry.Modification;
 import org.apache.directory.shared.ldap.entry.ModificationOperation;
+import org.apache.directory.shared.ldap.entry.StringValue;
 import org.apache.directory.shared.ldap.entry.Value;
 import org.apache.directory.shared.ldap.exception.LdapException;
 import org.apache.directory.shared.ldap.exception.LdapInvalidDnException;
@@ -52,18 +53,21 @@ import org.apache.directory.shared.ldap.
  * A entry to be populated by an ldif parser.
  * 
  * We will have different kind of entries : 
- * - added entries 
- * - deleted entries 
- * - modified entries 
- * - RDN modified entries 
- * - DN modified entries
+ * <ul>
+ * <li>added entries</li>
+ * <li>deleted entries</li>
+ * <li>modified entries</li>
+ * <li>RDN modified entries</li>
+ * <li>DN modified entries</li>
+ * </ul>
  * 
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
 public class LdifEntry implements Cloneable, Externalizable
 {
+    /** The serial version UID */
     private static final long serialVersionUID = 2L;
-    
+
     /** Used in toArray() */
     public static final Modification[] EMPTY_MODS = new Modification[0];
 
@@ -73,6 +77,7 @@ public class LdifEntry implements Clonea
     /** the modification item list */
     private List<Modification> modificationList;
 
+    /** The map containing all the modifications */
     private Map<String, Modification> modificationItems;
 
     /** The new superior */
@@ -87,10 +92,10 @@ public class LdifEntry implements Clonea
     /** the entry */
     private Entry entry;
 
-    
     /** The controls */
     private Map<String, Control> controls;
 
+
     /**
      * Creates a new Entry object.
      */
@@ -99,27 +104,27 @@ public class LdifEntry implements Clonea
         changeType = ChangeType.None; // Default LDIF content
         modificationList = new LinkedList<Modification>();
         modificationItems = new HashMap<String, Modification>();
-        entry = new DefaultEntry( (DN)null );
+        entry = new DefaultEntry( ( DN ) null );
         controls = null;
     }
 
-    
+
     /**
      * Set the Distinguished Name
      * 
-     * @param dn
-     *            The Distinguished Name
+     * @param dn The Distinguished Name
      */
     public void setDn( DN dn )
     {
         entry.setDn( dn );
     }
 
-    
+
     /**
      * Set the Distinguished Name
      * 
      * @param dn The Distinguished Name
+     * throws LdapInvalidDnException If the DN is invalid
      */
     public void setDn( String dn ) throws LdapInvalidDnException
     {
@@ -130,8 +135,7 @@ public class LdifEntry implements Clonea
     /**
      * Set the modification type
      * 
-     * @param changeType
-     *            The change type
+     * @param changeType The change type
      * 
      */
     public void setChangeType( ChangeType changeType )
@@ -139,11 +143,11 @@ public class LdifEntry implements Clonea
         this.changeType = changeType;
     }
 
+
     /**
      * Set the change type
      * 
-     * @param changeType
-     *            The change type
+     * @param changeType The change type
      */
     public void setChangeType( String changeType )
     {
@@ -169,6 +173,7 @@ public class LdifEntry implements Clonea
         }
     }
 
+
     /**
      * Add a modification item (used by modify operations)
      * 
@@ -183,13 +188,16 @@ public class LdifEntry implements Clonea
         }
     }
 
+
     /**
      * Add a modification item (used by modify operations)
      * 
      * @param modOp The operation. One of : 
-     * - ModificationOperation.ADD_ATTRIBUTE
-     * - ModificationOperation.REMOVE_ATTRIBUTE 
-     * - ModificationOperation.REPLACE_ATTRIBUTE
+     * <ul>
+     * <li>ModificationOperation.ADD_ATTRIBUTE</li>
+     * <li>ModificationOperation.REMOVE_ATTRIBUTE</li>
+     * <li>ModificationOperation.REPLACE_ATTRIBUTE</li>
+     * </ul>
      * 
      * @param attr The attribute to be added
      */
@@ -208,9 +216,12 @@ public class LdifEntry implements Clonea
      * Add a modification item
      * 
      * @param modOp The modification operation value. One of : 
-     *  - ModificationOperation.ADD_ATTRIBUTE
-     *  - ModificationOperation.REMOVE_ATTRIBUTE 
-     *  - ModificationOperation.REPLACE_ATTRIBUTE
+     * <ul>
+     * <li>ModificationOperation.ADD_ATTRIBUTE</li>
+     * <li>ModificationOperation.REMOVE_ATTRIBUTE</li>
+     * <li>ModificationOperation.REPLACE_ATTRIBUTE</li>
+     * </ul>
+     * 
      * @param id The attribute's ID
      * @param value The attribute's value
      */
@@ -218,16 +229,16 @@ public class LdifEntry implements Clonea
     {
         if ( changeType == ChangeType.Modify )
         {
-            EntryAttribute attr =  null;
-            
+            EntryAttribute attr = null;
+
             if ( value == null )
             {
-                value = new StringValue( (String)null );
-                attr = new DefaultEntryAttribute( id, (Value<?>)value );
+                value = new StringValue( ( String ) null );
+                attr = new DefaultEntryAttribute( id, ( Value<?> ) value );
             }
             else
             {
-                attr = (EntryAttribute)value;
+                attr = ( EntryAttribute ) value;
             }
 
             Modification item = new DefaultModification( modOp, attr );
@@ -240,37 +251,36 @@ public class LdifEntry implements Clonea
     /**
      * Add an attribute to the entry
      * 
-     * @param attr
-     *            The attribute to be added
+     * @param attr The attribute to be added
+     * @throws LdapException if something went wrong
      */
     public void addAttribute( EntryAttribute attr ) throws LdapException
     {
         entry.put( attr );
     }
 
+
     /**
      * Add an attribute to the entry
      * 
-     * @param id
-     *            The attribute ID
-     * 
-     * @param value
-     *            The attribute value
+     * @param id The attribute ID
      * 
+     * @param value The attribute value
+     * @throws LdapException if something went wrong
      */
     public void addAttribute( String id, Object value ) throws LdapException
     {
         if ( value instanceof String )
         {
-            entry.add( id, (String)value );
+            entry.add( id, ( String ) value );
         }
         else
         {
-            entry.add( id, (byte[])value );
+            entry.add( id, ( byte[] ) value );
         }
     }
-    
-    
+
+
     /**
      * Remove a list of Attributes from the LdifEntry
      *
@@ -289,28 +299,28 @@ public class LdifEntry implements Clonea
         }
     }
 
+
     /**
      * Add an attribute value to an existing attribute
      * 
-     * @param id
-     *            The attribute ID
-     * 
-     * @param value
-     *            The attribute value
+     * @param id The attribute ID
      * 
+     * @param value The attribute value
+     * @throws LdapException if something went wrong
      */
     public void putAttribute( String id, Object value ) throws LdapException
     {
         if ( value instanceof String )
         {
-            entry.add( id, (String)value );
+            entry.add( id, ( String ) value );
         }
         else
         {
-            entry.add( id, (byte[])value );
+            entry.add( id, ( byte[] ) value );
         }
     }
 
+
     /**
      * Get the change type
      * 
@@ -329,6 +339,7 @@ public class LdifEntry implements Clonea
         return changeType;
     }
 
+
     /**
      * @return The list of modification items
      */
@@ -357,6 +368,7 @@ public class LdifEntry implements Clonea
         return entry.getDn();
     }
 
+
     /**
      * @return The number of entry modifications
      */
@@ -365,6 +377,7 @@ public class LdifEntry implements Clonea
         return modificationList.size();
     }
 
+
     /**
      * Returns a attribute given it's id
      * 
@@ -382,6 +395,7 @@ public class LdifEntry implements Clonea
         return entry.get( attributeId );
     }
 
+
     /**
      * Get the entry's entry
      * 
@@ -399,6 +413,7 @@ public class LdifEntry implements Clonea
         }
     }
 
+
     /**
      * @return True, if the old RDN should be deleted.
      */
@@ -407,17 +422,18 @@ public class LdifEntry implements Clonea
         return deleteOldRdn;
     }
 
+
     /**
      * Set the flage deleteOldRdn
      * 
-     * @param deleteOldRdn
-     *            True if the old RDN should be deleted
+     * @param deleteOldRdn True if the old RDN should be deleted
      */
     public void setDeleteOldRdn( boolean deleteOldRdn )
     {
         this.deleteOldRdn = deleteOldRdn;
     }
 
+
     /**
      * @return The new RDN
      */
@@ -426,17 +442,18 @@ public class LdifEntry implements Clonea
         return newRdn;
     }
 
+
     /**
      * Set the new RDN
      * 
-     * @param newRdn
-     *            The new RDN
+     * @param newRdn The new RDN
      */
     public void setNewRdn( String newRdn )
     {
         this.newRdn = newRdn;
     }
 
+
     /**
      * @return The new superior
      */
@@ -445,18 +462,18 @@ public class LdifEntry implements Clonea
         return newSuperior;
     }
 
+
     /**
      * Set the new superior
      * 
-     * @param newSuperior
-     *            The new Superior
+     * @param newSuperior The new Superior
      */
     public void setNewSuperior( String newSuperior )
     {
         this.newSuperior = newSuperior;
     }
 
-    
+
     /**
      * @return True if there is this is a content ldif
      */
@@ -465,7 +482,7 @@ public class LdifEntry implements Clonea
         return changeType == ChangeType.None;
     }
 
-    
+
     /**
      * @return True if there is this is a change ldif
      */
@@ -474,7 +491,7 @@ public class LdifEntry implements Clonea
         return changeType != ChangeType.None;
     }
 
-    
+
     /**
      * @return True if the entry is an ADD entry
      */
@@ -482,7 +499,7 @@ public class LdifEntry implements Clonea
     {
         return changeType == ChangeType.Add;
     }
-    
+
 
     /**
      * @return True if the entry is a DELETE entry
@@ -492,7 +509,7 @@ public class LdifEntry implements Clonea
         return changeType == ChangeType.Delete;
     }
 
-    
+
     /**
      * @return True if the entry is a MODDN entry
      */
@@ -501,7 +518,7 @@ public class LdifEntry implements Clonea
         return changeType == ChangeType.ModDn;
     }
 
-    
+
     /**
      * @return True if the entry is a MODRDN entry
      */
@@ -510,7 +527,7 @@ public class LdifEntry implements Clonea
         return changeType == ChangeType.ModRdn;
     }
 
-    
+
     /**
      * @return True if the entry is a MODIFY entry
      */
@@ -519,7 +536,7 @@ public class LdifEntry implements Clonea
         return changeType == ChangeType.Modify;
     }
 
-    
+
     /**
      * Tells if the current entry is a added one
      *
@@ -529,8 +546,8 @@ public class LdifEntry implements Clonea
     {
         return ( changeType == ChangeType.None ) || ( changeType == ChangeType.Add );
     }
-    
-    
+
+
     /**
      * @return true if the entry has some controls
      */
@@ -538,8 +555,8 @@ public class LdifEntry implements Clonea
     {
         return controls != null;
     }
-    
-    
+
+
     /**
      * @return The set of controls for this entry
      */
@@ -547,9 +564,10 @@ public class LdifEntry implements Clonea
     {
         return controls;
     }
-    
+
 
     /**
+     * @param oid The control's OID
      * @return The associated control, if any
      */
     public Control getControl( String oid )
@@ -558,10 +576,11 @@ public class LdifEntry implements Clonea
         {
             return controls.get( oid );
         }
-        
+
         return null;
     }
 
+
     /**
      * Add a control to the entry
      * 
@@ -573,20 +592,21 @@ public class LdifEntry implements Clonea
         {
             throw new IllegalArgumentException( "The added control must not be null" );
         }
-        
+
         if ( changeType == ChangeType.None )
         {
             changeType = ChangeType.Add;
         }
-        
+
         if ( controls == null )
         {
             controls = new ConcurrentHashMap<String, Control>();
         }
-        
+
         controls.put( control.getOid(), control );
     }
 
+
     /**
      * Clone method
      * @return a clone of the current instance
@@ -594,25 +614,25 @@ public class LdifEntry implements Clonea
      */
     public LdifEntry clone() throws CloneNotSupportedException
     {
-        LdifEntry clone = (LdifEntry) super.clone();
+        LdifEntry clone = ( LdifEntry ) super.clone();
 
         if ( modificationList != null )
         {
-            for ( Modification modif:modificationList )
+            for ( Modification modif : modificationList )
             {
-                Modification modifClone = new DefaultModification( modif.getOperation(), 
-                    (EntryAttribute) modif.getAttribute().clone() );
+                Modification modifClone = new DefaultModification( modif.getOperation(), ( EntryAttribute ) modif
+                    .getAttribute().clone() );
                 clone.modificationList.add( modifClone );
             }
         }
 
         if ( modificationItems != null )
         {
-            for ( String key:modificationItems.keySet() )
+            for ( String key : modificationItems.keySet() )
             {
                 Modification modif = modificationItems.get( key );
-                Modification modifClone = new DefaultModification( modif.getOperation(), 
-                    (EntryAttribute) modif.getAttribute().clone() );
+                Modification modifClone = new DefaultModification( modif.getOperation(), ( EntryAttribute ) modif
+                    .getAttribute().clone() );
                 clone.modificationItems.put( key, modifClone );
             }
 
@@ -626,7 +646,7 @@ public class LdifEntry implements Clonea
         return clone;
     }
 
-    
+
     /**
      * @return a String representing the Entry, as a LDIF 
      */
@@ -641,8 +661,8 @@ public class LdifEntry implements Clonea
             return "";
         }
     }
-    
-    
+
+
     /**
      * @see Object#hashCode()
      * 
@@ -654,59 +674,59 @@ public class LdifEntry implements Clonea
 
         if ( entry != null && entry.getDn() != null )
         {
-            result = result*17 + entry.getDn().hashCode();
+            result = result * 17 + entry.getDn().hashCode();
         }
-        
+
         if ( changeType != null )
         {
-            result = result*17 + changeType.hashCode();
-            
+            result = result * 17 + changeType.hashCode();
+
             // Check each different cases
             switch ( changeType )
             {
-                case Add :
+                case Add:
                     // Checks the attributes
                     if ( entry != null )
                     {
                         result = result * 17 + entry.hashCode();
                     }
-                    
+
                     break;
 
-                case Delete :
+                case Delete:
                     // Nothing to compute
                     break;
-                    
-                case Modify :
+
+                case Modify:
                     if ( modificationList != null )
                     {
                         result = result * 17 + modificationList.hashCode();
-                        
-                        for ( Modification modification:modificationList )
+
+                        for ( Modification modification : modificationList )
                         {
                             result = result * 17 + modification.hashCode();
                         }
                     }
-                    
+
                     break;
-                    
-                case ModDn :
-                case ModRdn :
-                    result = result * 17 + ( deleteOldRdn ? 1 : -1 ); 
-                    
+
+                case ModDn:
+                case ModRdn:
+                    result = result * 17 + ( deleteOldRdn ? 1 : -1 );
+
                     if ( newRdn != null )
                     {
-                        result = result*17 + newRdn.hashCode();
+                        result = result * 17 + newRdn.hashCode();
                     }
-                    
+
                     if ( newSuperior != null )
                     {
-                        result = result*17 + newSuperior.hashCode();
+                        result = result * 17 + newSuperior.hashCode();
                     }
-                    
+
                     break;
-                    
-                default :
+
+                default:
                     break; // do nothing
             }
         }
@@ -721,10 +741,10 @@ public class LdifEntry implements Clonea
 
         return result;
     }
-    
+
+
     /**
-     * @see Object#equals(Object)
-     * @return <code>true</code> if both values are equal
+     * {@inheritDoc}
      */
     public boolean equals( Object o )
     {
@@ -733,57 +753,56 @@ public class LdifEntry implements Clonea
         {
             return true;
         }
-        
+
         if ( o == null )
         {
-           return false;
+            return false;
         }
-        
-        if ( ! (o instanceof LdifEntry ) )
+
+        if ( !( o instanceof LdifEntry ) )
         {
             return false;
         }
-        
-        LdifEntry otherEntry = (LdifEntry)o;
-        
+
+        LdifEntry otherEntry = ( LdifEntry ) o;
+
         // Check the DN
         DN thisDn = entry.getDn();
         DN dnEntry = otherEntry.getDn();
-        
+
         if ( !thisDn.equals( dnEntry ) )
         {
             return false;
         }
 
-        
         // Check the changeType
         if ( changeType != otherEntry.changeType )
         {
             return false;
         }
-        
+
         // Check each different cases
         switch ( changeType )
         {
-            case Add :
+            case Add:
                 // Checks the attributes
                 if ( entry.size() != otherEntry.entry.size() )
                 {
                     return false;
                 }
-                
+
                 if ( !entry.equals( otherEntry.entry ) )
                 {
                     return false;
                 }
-                
+
                 break;
 
-            case Delete :
+            case Delete:
                 // Nothing to do, if the DNs are equals
                 break;
-                
-            case Modify :
+
+            case Modify:
                 // Check the modificationItems list
 
                 // First, deal with special cases
@@ -798,40 +817,40 @@ public class LdifEntry implements Clonea
                         break;
                     }
                 }
-                
+
                 if ( otherEntry.modificationList == null )
                 {
                     return false;
                 }
-                
+
                 if ( modificationList.size() != otherEntry.modificationList.size() )
                 {
                     return false;
                 }
-                
+
                 // Now, compares the contents
                 int i = 0;
-                
-                for ( Modification modification:modificationList )
+
+                for ( Modification modification : modificationList )
                 {
-                    if ( ! modification.equals( otherEntry.modificationList.get( i ) ) )
+                    if ( !modification.equals( otherEntry.modificationList.get( i ) ) )
                     {
                         return false;
                     }
-                    
+
                     i++;
                 }
-                
+
                 break;
-                
-            case ModDn :
-            case ModRdn :
+
+            case ModDn:
+            case ModRdn:
                 // Check the deleteOldRdn flag
                 if ( deleteOldRdn != otherEntry.deleteOldRdn )
                 {
                     return false;
                 }
-                
+
                 // Check the newRdn value
                 try
                 {
@@ -847,14 +866,14 @@ public class LdifEntry implements Clonea
                 {
                     return false;
                 }
-                
+
                 // Check the newSuperior value
                 try
                 {
                     DN thisNewSuperior = new DN( newSuperior );
                     DN entryNewSuperior = new DN( otherEntry.newSuperior );
-                    
-                    if ( ! thisNewSuperior.equals(  entryNewSuperior ) )
+
+                    if ( !thisNewSuperior.equals( entryNewSuperior ) )
                     {
                         return false;
                     }
@@ -863,44 +882,44 @@ public class LdifEntry implements Clonea
                 {
                     return false;
                 }
-                
+
                 break;
-                
-            default :
+
+            default:
                 break; // do nothing
         }
-        
+
         if ( controls != null )
         {
             Map<String, Control> otherControls = otherEntry.controls;
-            
+
             if ( otherControls == null )
             {
                 return false;
             }
-            
+
             if ( controls.size() != otherControls.size() )
             {
                 return false;
             }
-            
+
             for ( String controlOid : controls.keySet() )
             {
                 if ( !otherControls.containsKey( controlOid ) )
                 {
                     return false;
                 }
-                
+
                 Control thisControl = controls.get( controlOid );
                 Control otherControl = otherControls.get( controlOid );
-                
+
                 if ( thisControl == null )
                 {
                     if ( otherControl != null )
                     {
                         return false;
                     }
-                    
+
                     continue;
                 }
                 else
@@ -911,10 +930,10 @@ public class LdifEntry implements Clonea
                     }
                 }
             }
-            
+
             return true;
         }
-        else 
+        else
         {
             return otherEntry.controls == null;
         }
@@ -928,85 +947,88 @@ public class LdifEntry implements Clonea
      * @throws IOException If the stream can't be read
      * @throws ClassNotFoundException If the LdifEntry can't be created 
      */
-    public void readExternal( ObjectInput in ) throws IOException , ClassNotFoundException
+    public void readExternal( ObjectInput in ) throws IOException, ClassNotFoundException
     {
         // Read the changeType
         int type = in.readInt();
         changeType = ChangeType.getChangeType( type );
-        entry = (Entry)in.readObject();
-        
+        entry = ( Entry ) in.readObject();
+
         switch ( changeType )
         {
-            case Add :
+            case Add:
                 // Fallback
-            case Delete :
+            case Delete:
                 // we don't have anything to read, but the control
                 break;
 
-            case ModDn :
+            case ModDn:
                 // Fallback
-            case ModRdn :
+            case ModRdn:
                 deleteOldRdn = in.readBoolean();
-                
+
                 if ( in.readBoolean() )
                 {
                     newRdn = UTFUtils.readUTF( in );
                 }
-                
+
                 if ( in.readBoolean() )
                 {
                     newSuperior = UTFUtils.readUTF( in );
                 }
-                
+
                 break;
-                
-            case Modify :
+
+            case Modify:
                 // Read the modification
                 int nbModifs = in.readInt();
-                
-                
+
                 for ( int i = 0; i < nbModifs; i++ )
                 {
                     int operation = in.readInt();
                     String modStr = UTFUtils.readUTF( in );
-                    DefaultEntryAttribute value = (DefaultEntryAttribute)in.readObject();
-                    
+                    DefaultEntryAttribute value = ( DefaultEntryAttribute ) in.readObject();
+
                     addModificationItem( ModificationOperation.getOperation( operation ), modStr, value );
                 }
-                
+
+                break;
+
+            case None:
+                // Nothing to do 
                 break;
         }
-        
+
         if ( in.available() > 0 )
         {
             // We have at least a control
             int nbControls = in.readInt();
-            
+
             if ( nbControls > 0 )
             {
                 controls = new ConcurrentHashMap<String, Control>( nbControls );
-                
+
                 for ( int i = 0; i < nbControls; i++ )
                 {
                     String controlOid = in.readUTF();
                     boolean isCritical = in.readBoolean();
                     boolean hasValue = in.readBoolean();
-                    Control control = new ControlImpl(controlOid );
+                    Control control = new ControlImpl( controlOid );
                     control.setCritical( isCritical );
-                    
+
                     if ( hasValue )
                     {
                         int valueLength = in.readInt();
                         byte[] value = new byte[valueLength];
-                        
+
                         if ( valueLength > 0 )
                         {
                             in.read( value );
                         }
-                        
+
                         control.setValue( value );
                     }
-                    
+
                     controls.put( controlOid, control );
                 }
             }
@@ -1025,24 +1047,24 @@ public class LdifEntry implements Clonea
     {
         // Write the changeType
         out.writeInt( changeType.getChangeType() );
-        
+
         // Write the entry
         out.writeObject( entry );
-        
+
         // Write the data
         switch ( changeType )
         {
-            case Add :
+            case Add:
                 // Fallback
-            case Delete :
+            case Delete:
                 // we don't have anything to write, but the control
                 break;
 
-            case ModDn :
+            case ModDn:
                 // Fallback
-            case ModRdn :
+            case ModRdn:
                 out.writeBoolean( deleteOldRdn );
-                
+
                 if ( newRdn != null )
                 {
                     out.writeBoolean( true );
@@ -1052,7 +1074,7 @@ public class LdifEntry implements Clonea
                 {
                     out.writeBoolean( false );
                 }
-                
+
                 if ( newSuperior != null )
                 {
                     out.writeBoolean( true );
@@ -1063,39 +1085,43 @@ public class LdifEntry implements Clonea
                     out.writeBoolean( false );
                 }
                 break;
-                
-            case Modify :
+
+            case Modify:
                 // Read the modification
                 out.writeInt( modificationList.size() );
-                
-                for ( Modification modification:modificationList )
+
+                for ( Modification modification : modificationList )
                 {
                     out.writeInt( modification.getOperation().getValue() );
                     UTFUtils.writeUTF( out, modification.getAttribute().getId() );
-                    
+
                     EntryAttribute attribute = modification.getAttribute();
                     out.writeObject( attribute );
                 }
-                
+
+                break;
+
+            case None:
+                // Nothing to do
                 break;
         }
-        
+
         // The controls
         if ( controls != null )
         {
             // Write the control
             out.writeInt( controls.size() );
-            
+
             for ( Control control : controls.values() )
             {
                 UTFUtils.writeUTF( out, control.getOid() );
                 out.writeBoolean( control.isCritical() );
                 out.writeBoolean( control.hasValue() );
-                
+
                 if ( control.hasValue() )
                 {
                     out.writeInt( control.getValue().length );
-                    
+
                     if ( control.getValue().length > 0 )
                     {
                         out.write( control.getValue() );
@@ -1103,7 +1129,7 @@ public class LdifEntry implements Clonea
                 }
             }
         }
-        
+
         // and flush the result
         out.flush();
     }



Mime
View raw message