directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r657688 - in /directory: apacheds/trunk/core-entry/src/main/java/org/apache/directory/server/core/entry/ shared/trunk/ldap/src/main/antlr/ shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/ldif/ shared/trunk/ldap/src/main/jav...
Date Sun, 18 May 2008 23:01:12 GMT
Author: elecharny
Date: Sun May 18 16:01:12 2008
New Revision: 657688

URL: http://svn.apache.org/viewvc?rev=657688&view=rev
Log:
o Added missing Javadoc
o Fixed some warnings

Modified:
    directory/apacheds/trunk/core-entry/src/main/java/org/apache/directory/server/core/entry/ServerEntrySerializer.java
    directory/shared/trunk/ldap/src/main/antlr/openldap.g
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/ldif/LdifEntry.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/ldif/LdifReader.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/name/LdapDN.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/name/LdapDNSerializer.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/name/Rdn.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/name/RdnParser.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/name/RdnSerializer.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/parser/OpenLdapSchemaParser.java

Modified: directory/apacheds/trunk/core-entry/src/main/java/org/apache/directory/server/core/entry/ServerEntrySerializer.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-entry/src/main/java/org/apache/directory/server/core/entry/ServerEntrySerializer.java?rev=657688&r1=657687&r2=657688&view=diff
==============================================================================
--- directory/apacheds/trunk/core-entry/src/main/java/org/apache/directory/server/core/entry/ServerEntrySerializer.java
(original)
+++ directory/apacheds/trunk/core-entry/src/main/java/org/apache/directory/server/core/entry/ServerEntrySerializer.java
Sun May 18 16:01:12 2008
@@ -373,11 +373,6 @@
 
             return serverEntry;
         }
-        catch ( ClassNotFoundException cnfe )
-        {
-            // TODO Handle this exception
-            return null;
-        }
         catch ( NamingException ne )
         {
             // TODO Handle this exception

Modified: directory/shared/trunk/ldap/src/main/antlr/openldap.g
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/antlr/openldap.g?rev=657688&r1=657687&r2=657688&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/antlr/openldap.g (original)
+++ directory/shared/trunk/ldap/src/main/antlr/openldap.g Sun May 18 16:01:12 2008
@@ -117,7 +117,7 @@
 {
     public static final String[] EMPTY = new String[0];
 
-    private List attributeTypes = new ArrayList();
+    private List<AttributeTypeLiteral> attributeTypes = new ArrayList<AttributeTypeLiteral>();
     private List objectClasses = new ArrayList();
     private ParserMonitor monitor = null;
 
@@ -126,7 +126,9 @@
     // Public Methods
     // ------------------------------------------------------------------------
 
-
+    /**
+     * Clear the ObjectClass and AttributeType lists
+     */
     public void clear()
     {
         attributeTypes.clear();
@@ -134,7 +136,11 @@
     }
 
 
-    public List getAttributeTypes()
+    /**
+     * Return the list of parsed AttributeTypes
+     * @return The parsed AttributeTypeLiteral
+     */
+    public List<AttributeTypeLiteral> getAttributeTypes()
     {
         return Collections.unmodifiableList( attributeTypes );
     }
@@ -495,7 +501,7 @@
 names [AttributeTypeLiteral type]
 {
     matchedProduction( "names(AttributeTypeLiteral)" ) ;
-    ArrayList list = new ArrayList();
+    List<String> list = new ArrayList<String>();
 }
     :
         "NAME"

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/ldif/LdifEntry.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/ldif/LdifEntry.java?rev=657688&r1=657687&r2=657688&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/ldif/LdifEntry.java
(original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/ldif/LdifEntry.java
Sun May 18 16:01:12 2008
@@ -32,6 +32,7 @@
 import javax.naming.directory.Attribute;
 import javax.naming.directory.Attributes;
 import javax.naming.directory.DirContext;
+import javax.naming.directory.ModificationItem;
 import javax.naming.ldap.Control;
 
 import org.apache.directory.shared.ldap.message.AttributeImpl;
@@ -530,6 +531,12 @@
                   attrs.hasMoreElements(); 
                   attribute = attrs.nextElement())
             {
+                if ( attribute == null )
+                {
+                    sb.append( "        Null attribute\n" );
+                    continue;
+                }
+                
                 sb.append( "        ").append( attribute.getID() ).append( ":\n" );
                 Object value = null;
                 
@@ -673,6 +680,82 @@
     
     
     /**
+     * @see Object#hashCode()
+     * 
+     * @return the instance's hash code
+     */
+    public int hashCode()
+    {
+        int result = 37;
+
+        if ( dn != null )
+        {
+            result = result*17 + dn.hashCode();
+        }
+        
+        if ( changeType != null )
+        {
+            result = result*17 + changeType.hashCode();
+            
+            // Check each different cases
+            switch ( changeType )
+            {
+                case Add :
+                    // Checks the attributes
+                    if ( attributes != null )
+                    {
+                        result = result * 17 + attributes.hashCode();
+                    }
+                    
+                    break;
+
+                case Delete :
+                    // Nothing to compute
+                    break;
+                    
+                case Modify :
+                    if ( modificationList != null )
+                    {
+                        result = result * 17 + modificationList.hashCode();
+                        
+                        for ( ModificationItem modification:modificationList )
+                        {
+                            result = result * 17 + modification.hashCode();
+                        }
+                    }
+                    
+                    break;
+                    
+                case ModDn :
+                case ModRdn :
+                    result = result * 17 + ( deleteOldRdn ? 1 : -1 ); 
+                    
+                    if ( newRdn != null )
+                    {
+                        result = result*17 + newRdn.hashCode();
+                    }
+                    
+                    if ( newSuperior != null )
+                    {
+                        result = result*17 + newSuperior.hashCode();
+                    }
+                    
+                    break;
+                    
+                default :
+                    break; // do nothing
+            }
+        }
+
+        if ( control != null )
+        {
+            result = result * 17 + control.hashCode();
+        }
+
+        return result;
+    }
+    
+    /**
      * @see Object#equals(Object)
      * @return <code>true</code> if both values are equal
      */
@@ -686,7 +769,7 @@
         
         if ( o == null )
         {
-            return false;
+           return false;
         }
         
         if ( ! (o instanceof LdifEntry ) )

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/ldif/LdifReader.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/ldif/LdifReader.java?rev=657688&r1=657687&r2=657688&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/ldif/LdifReader.java
(original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/ldif/LdifReader.java
Sun May 18 16:01:12 2008
@@ -218,7 +218,7 @@
     protected int version;
 
     /** Type of element read */
-    protected static final int ENTRY = 0;
+    protected static final int LDIF_ENTRY = 0;
 
     protected static final int CHANGE = 1;
 
@@ -1322,7 +1322,7 @@
                 }
 
                 parseAttributeValue( entry, line, lowerLine );
-                type = ENTRY;
+                type = LDIF_ENTRY;
             }
             else
             {
@@ -1332,7 +1332,7 @@
             }
         }
 
-        if ( type == ENTRY )
+        if ( type == LDIF_ENTRY )
         {
             LOG.debug( "Read an entry : {}", entry );
         }

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/name/LdapDN.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/name/LdapDN.java?rev=657688&r1=657687&r2=657688&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/name/LdapDN.java
(original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/name/LdapDN.java
Sun May 18 16:01:12 2008
@@ -76,10 +76,10 @@
     private static final long serialVersionUID = 1L;
 
     /** Value returned by the compareTo method if values are not equals */
-    public static final int NOT_EQUALS = -1;
+    public static final int NOT_EQUAL = -1;
 
     /** Value returned by the compareTo method if values are equals */
-    public static final int EQUALS = 0;
+    public static final int EQUAL = 0;
 
     /** A flag used to tell if the DN has been normalized */
     private boolean normalized;
@@ -1423,7 +1423,7 @@
                 }
             }
 
-            return EQUALS;
+            return EQUAL;
         }
         else
         {

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/name/LdapDNSerializer.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/name/LdapDNSerializer.java?rev=657688&r1=657687&r2=657688&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/name/LdapDNSerializer.java
(original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/name/LdapDNSerializer.java
Sun May 18 16:01:12 2008
@@ -50,6 +50,10 @@
      * 
      * for each rdn :
      * <li>call the RDN write method</li>
+     * 
+     * @param dn The DN to serialize
+     * @param out the stream in which the DN will be serialized
+     * @throws IOException If we can't write in this stream
      */
     public static void serialize( LdapDN dn, ObjectOutput out ) throws IOException
     {
@@ -104,8 +108,12 @@
      * We read back the data to create a new LdapDN. The structure 
      * read is exposed in the {@link LdapDNSerializer#serialize(LdapDN, ObjectOutput)} 
      * method<p>
+     * 
+     * @param in The input stream from which the DN is read
+     * @return a deserialized DN
+     * @throws IOException If the stream can't be read
      */
-    public static LdapDN deserialize( ObjectInput in ) throws IOException, ClassNotFoundException
+    public static LdapDN deserialize( ObjectInput in ) throws IOException
     {
         // Read the UPName
         String upName = in.readUTF();

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/name/Rdn.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/name/Rdn.java?rev=657688&r1=657687&r2=657688&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/name/Rdn.java
(original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/name/Rdn.java
Sun May 18 16:01:12 2008
@@ -180,7 +180,7 @@
    public static final int INFERIOR = -1;
 
    /** Constant used in comparisons */
-   public static final int EQUALS = 0;
+   public static final int EQUAL = 0;
 
 
    /**
@@ -743,7 +743,7 @@
            switch ( nbAtavs )
            {
                case 0:
-                   return EQUALS;
+                   return EQUAL;
 
                case 1:
                    return atav.compareTo( rdn.atav );
@@ -770,7 +770,7 @@
 
                                for ( AttributeTypeAndValue atavParam:atavParamList )
                                {
-                                   if ( atavLocal.compareTo( atavParam ) == EQUALS )
+                                   if ( atavLocal.compareTo( atavParam ) == EQUAL )
                                    {
                                        found = true;
                                        break;
@@ -792,7 +792,7 @@
                        }
                    }
 
-                   return EQUALS;
+                   return EQUAL;
            }
        }
        else
@@ -973,7 +973,7 @@
            return false;
        }
 
-       return compareTo( rdn ) == EQUALS;
+       return compareTo( rdn ) == EQUAL;
    }
 
 

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/name/RdnParser.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/name/RdnParser.java?rev=657688&r1=657687&r2=657688&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/name/RdnParser.java
(original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/name/RdnParser.java
Sun May 18 16:01:12 2008
@@ -747,11 +747,18 @@
      *
      * @param bytes The byte buffer to parse
      * @param pos The current position in the byte buffer
+     * @param rdn The rdn to generate
      * @return The new position in the byte buffer, or PARSING_ERROR if the rule
      *         does not apply to the byte buffer
+     * @throws InvalidNameException If the NameComponent is invalid
      */
     private static int parseNameComponents( byte[] bytes, Position pos, Rdn rdn ) throws
InvalidNameException
     {
+        if ( rdn == null )
+        {
+            throw new InvalidNameException( "The RDN should not be null" );
+        }
+        
         int newStart = 0;
         String type = null;
         Object value = null;
@@ -821,6 +828,7 @@
      *
      * @param bytes The byte buffer to parse
      * @param pos The current position in the byte buffer
+     * @param isFirstRdn A flag set if the RDN is the first one
      * @return <code>true</code> if the rule is valid
      */
     private static boolean isValidNameComponents( byte[] bytes, Position pos, boolean isFirstRdn
)
@@ -887,6 +895,7 @@
      * @param rdn The constructed RDN
      * @return The new position in the char array, or PARSING_ERROR if the rule
      *         does not apply to the char array
+     * @throws InvalidNameException If the NameComponent is invalid
      */
     public static int parse( String dn, Position pos, Rdn rdn ) throws InvalidNameException
     {
@@ -906,6 +915,7 @@
      * @param rdn The constructed RDN
      * @return The new position in the byte array, or PARSING_ERROR if the rule
      *         does not apply to the byte array
+     * @throws InvalidNameException If the NameComponent is invalid
      */
     public static int parse( byte[] dn, Position pos, Rdn rdn ) throws InvalidNameException
     {
@@ -974,29 +984,12 @@
      * &lt;spaces&gt; &lt;attributeValue&gt; &lt;nameComponents&gt;
      * </p>
      *
-     * @param dn The String to parse
-     * @param pos The current position in the buffer
-     * @param isFirstRdn a flag set if the RDN is the first for the current DN
-     * @return <code>true</code> if the RDN is valid
-     */
-    public static boolean isValid( String dn, Position pos, boolean isFirstRdn )
-    {
-        return isValid( StringTools.getBytesUtf8( dn ), pos, isFirstRdn );
-    }
-
-
-    /**
-     * Validate a NameComponent : <br>
-     * <p>
-     * &lt;name-component&gt; ::= &lt;attributeType&gt; &lt;spaces&gt;
'='
-     * &lt;spaces&gt; &lt;attributeValue&gt; &lt;nameComponents&gt;
-     * </p>
-     *
      * @param dn The byte array to parse
      * @param pos The current position in the buffer
+     * @param isFirstRdn a flag set if the RDN is the first for the current DN
      * @return <code>true</code> if the RDN is valid
      */
-    public static boolean isValid( byte[] dn, Position pos, boolean isfirstRdn )
+    public static boolean isValid( byte[] dn, Position pos, boolean isFirstRdn )
     {
         StringTools.trimLeft( dn, pos );
 
@@ -1033,7 +1026,7 @@
         pos.start = pos.end;
         pos.length = 0;
 
-        if ( !isValidNameComponents( dn, pos, isfirstRdn )  )
+        if ( !isValidNameComponents( dn, pos, isFirstRdn )  )
         {
             return false;
         }
@@ -1053,6 +1046,7 @@
      * @param dn The String to parse
      * @param rdn The RDN to fill. Beware that if the RDN is not empty, the new
      *            AttributeTypeAndValue will be added.
+     * @throws InvalidNameException If the NameComponent is invalid
      */
     public static void parse( String dn, Rdn rdn ) throws InvalidNameException
     {

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/name/RdnSerializer.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/name/RdnSerializer.java?rev=657688&r1=657687&r2=657688&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/name/RdnSerializer.java
(original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/name/RdnSerializer.java
Sun May 18 16:01:12 2008
@@ -56,6 +56,9 @@
      * <li>length</li> The ATAV user provided length
      * <li>Call the ATAV write method</li> The ATAV itself
      *  
+     * @param rdn The RDN to serialize
+     * @param out the stream in which the RDN will be serialized
+     * @throws IOException If we can't write in this stream
      */
     public static void serialize( Rdn rdn, ObjectOutput out ) throws IOException
     {
@@ -93,6 +96,10 @@
      * We read back the data to create a new RDB. The structure 
      * read is exposed in the {@link Rdn#writeExternal(ObjectOutput)} 
      * method<p>
+     * 
+     * @param in The input stream from which the RDN is read
+     * @return a deserialized RDN
+     * @throws IOException If the stream can't be read
      */
     public static Rdn deserialize( ObjectInput in ) throws IOException
     {

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/parser/OpenLdapSchemaParser.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/parser/OpenLdapSchemaParser.java?rev=657688&r1=657687&r2=657688&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/parser/OpenLdapSchemaParser.java
(original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/parser/OpenLdapSchemaParser.java
Sun May 18 16:01:12 2008
@@ -20,11 +20,6 @@
 package org.apache.directory.shared.ldap.schema.parser;
 
 
-import org.apache.directory.shared.ldap.schema.parser.antlrOpenLdapSchemaLexer;
-import org.apache.directory.shared.ldap.schema.parser.antlrOpenLdapSchemaParser;
-import org.apache.directory.shared.ldap.util.ExceptionUtils;
-
-import java.util.List;
 import java.io.ByteArrayInputStream;
 import java.io.File;
 import java.io.FileInputStream;
@@ -33,6 +28,9 @@
 import java.io.PipedInputStream;
 import java.io.PipedOutputStream;
 import java.text.ParseException;
+import java.util.List;
+
+import org.apache.directory.shared.ldap.util.ExceptionUtils;
 
 import antlr.RecognitionException;
 import antlr.TokenStreamException;
@@ -48,8 +46,10 @@
 {
     /** the monitor to use for this parser */
     private ParserMonitor monitor = new ParserMonitorAdapter();
+    
     /** The antlr generated parser */
     private antlrOpenLdapSchemaParser parser = null;
+    
     /** A pipe into the parser */
     private PipedOutputStream parserIn = null;
 
@@ -80,12 +80,19 @@
     }
 
 
+    /**
+     * Reset the parser 
+     *
+     */
     public synchronized void clear()
     {
         parser.clear();
     }
 
 
+    /**
+     * @return the AttributeTypes list
+     */
     public List getAttributeTypes()
     {
         return parser.getAttributeTypes();
@@ -102,6 +109,8 @@
      * Thread safe method parses an OpenLDAP schemaObject element/object.
      *
      * @param schemaObject the String image of a complete schema object
+     * @throws IOException If the schemaObject can't be transformed to a byteArrayInputStream
+     * @throws ParseException If the schemaObject can't be parsed
      */
     public synchronized void parse( String schemaObject ) throws IOException, ParseException
     {
@@ -155,6 +164,8 @@
      * Thread safe method parses a stream of OpenLDAP schemaObject elements/objects.
      *
      * @param schemaIn a stream of schema objects
+     * @throws IOException If the schemaObject can't be transformed to a byteArrayInputStream
+     * @throws ParseException If the schemaObject can't be parsed
      */
     public synchronized void parse( InputStream schemaIn ) throws IOException, ParseException
     {
@@ -174,6 +185,8 @@
      * Thread safe method parses a file of OpenLDAP schemaObject elements/objects.
      *
      * @param schemaFile a file of schema objects
+     * @throws IOException If the schemaObject can't be transformed to a byteArrayInputStream
+     * @throws ParseException If the schemaObject can't be parsed
      */
     public synchronized void parse( File schemaFile ) throws IOException, ParseException
     {



Mime
View raw message