directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r655677 - in /directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/name: AttributeTypeAndValue.java DefaultStringNormalizer.java LdapDN.java LdapDnParser.java Rdn.java RdnParser.java RdnSerializer.java
Date Mon, 12 May 2008 22:34:02 GMT
Author: elecharny
Date: Mon May 12 15:34:01 2008
New Revision: 655677

URL: http://svn.apache.org/viewvc?rev=655677&view=rev
Log:
o Formatted the code
o Added some missing javadoc

Modified:
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/name/AttributeTypeAndValue.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/name/DefaultStringNormalizer.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/LdapDnParser.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

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/name/AttributeTypeAndValue.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/name/AttributeTypeAndValue.java?rev=655677&r1=655676&r2=655677&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/name/AttributeTypeAndValue.java
(original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/name/AttributeTypeAndValue.java
Mon May 12 15:34:01 2008
@@ -47,6 +47,7 @@
  * called upName.
  *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
  */
 public class AttributeTypeAndValue implements Cloneable, Comparable, Externalizable
 {

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/name/DefaultStringNormalizer.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/name/DefaultStringNormalizer.java?rev=655677&r1=655676&r2=655677&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/name/DefaultStringNormalizer.java
(original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/name/DefaultStringNormalizer.java
Mon May 12 15:34:01 2008
@@ -32,6 +32,7 @@
  * types only.
  *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
  */
 public class DefaultStringNormalizer implements Normalizer
 {
@@ -61,6 +62,14 @@
         return str;
     }
 
+    
+    /**
+     * Normalize the given String
+     *
+     * @param string The string to normalize
+     * @return The normalized object
+     * @throws NamingException If the normalization throws an error
+     */
     public static Object normalizeString( String string ) throws NamingException
     {
         return NORMALIZER.normalize( string );

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=655677&r1=655676&r2=655677&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
Mon May 12 15:34:01 2008
@@ -36,7 +36,6 @@
 import javax.naming.Name;
 import javax.naming.NamingException;
 
-import org.apache.directory.shared.ldap.name.DefaultStringNormalizer;
 import org.apache.directory.shared.ldap.schema.OidNormalizer;
 import org.apache.directory.shared.ldap.util.StringTools;
 import org.slf4j.Logger;
@@ -60,6 +59,7 @@
  * is the first RDN (RDN[n]).
  *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
  */
 public class LdapDN implements Name, Externalizable
 {
@@ -76,10 +76,10 @@
     private static final long serialVersionUID = 1L;
 
     /** Value returned by the compareTo method if values are not equals */
-    public final static int NOT_EQUALS = -1;
+    public static final int NOT_EQUALS = -1;
 
     /** Value returned by the compareTo method if values are equals */
-    public final static int EQUALS = 0;
+    public static final int EQUALS = 0;
 
     /** A flag used to tell if the DN has been normalized */
     private boolean normalized;
@@ -114,7 +114,6 @@
      */
     public LdapDN()
     {
-        super();
         upName = "";
         normName = "";
         normalized = true;
@@ -148,6 +147,7 @@
      * is a String
      *
      * @param list of String name components.
+     * @throws InvalidNameException If the nameComponent is incorrect
      */
     LdapDN( List<String> list ) throws InvalidNameException
     {
@@ -167,8 +167,8 @@
     /**
      * Creates an ldap name using a list of name components.
      *
-     * @param nameComponents
-     *            List of String name components.
+     * @param nameComponents List of String name components.
+     * @throws InvalidNameException If the nameComponent is incorrect
      */
     LdapDN( Iterator<String> nameComponents ) throws InvalidNameException
     {
@@ -215,6 +215,9 @@
 
     /**
      * Create a DN when deserializing it.
+     * @param upName The user provided name
+     * @param normName the normalized name
+     * @param bytes the name as a byte[]
      */
     /* No protection */ LdapDN( String upName, String normName, byte[] bytes )
     {
@@ -495,9 +498,10 @@
 
 
     /**
-     * Gets the hashcode of this name.
+     * Gets the hash code of this name.
      *
      * @see java.lang.Object#hashCode()
+     * @return the instance hash code
      */
     public int hashCode()
     {
@@ -1340,6 +1344,7 @@
 
     /**
      * @see java.lang.Object#equals(java.lang.Object)
+     * @return <code>true</code> if the two instances are equals
      */
     public boolean equals( Object obj )
     {
@@ -1399,17 +1404,17 @@
     {
         if ( obj instanceof LdapDN )
         {
-            LdapDN ldapDN = ( LdapDN ) obj;
+            LdapDN dn = ( LdapDN ) obj;
 
-            if ( ldapDN.size() != size() )
+            if ( dn.size() != size() )
             {
-                return size() - ldapDN.size();
+                return size() - dn.size();
             }
 
             for ( int i = rdns.size(); i > 0; i-- )
             {
                 Rdn rdn1 = rdns.get( i - 1 );
-                Rdn rdn2 = ldapDN.rdns.get( i - 1 );
+                Rdn rdn2 = dn.rdns.get( i - 1 );
                 int res = rdn1.compareTo( rdn2 );
 
                 if ( res != 0 )
@@ -1509,11 +1514,8 @@
             Rdn rdnCopy = ( Rdn ) rdn.clone();
             rdn.clear();
 
-            Iterator<AttributeTypeAndValue> atavs = rdnCopy.iterator();
-
-            while ( atavs.hasNext() )
+            for ( AttributeTypeAndValue val:rdnCopy )
             {
-                AttributeTypeAndValue val = atavs.next();
                 AttributeTypeAndValue newAtav = atavOidToName( val, oidsMap );
                 rdn.addAttributeTypeAndValue( val.getUpType(), newAtav.getNormType(), val.getUpValue(),
newAtav.getNormValue() );
             }
@@ -1591,7 +1593,6 @@
      * @param dn The DN to transform.
      * @param oidsMap The mapping between names and oids.
      * @return A normalized form of the DN.
-     * @throws InvalidNameException If the DN is invalid.
      * @throws NamingException If something went wrong.
      */
     public static LdapDN normalize( LdapDN dn, Map<String, OidNormalizer> oidsMap )
throws NamingException
@@ -1633,8 +1634,8 @@
      * 'commonname' share the same OID.
      *
      * @param oidsMap The mapping between names and oids.
-     * @throws InvalidNameException If the DN is invalid.
      * @throws NamingException If something went wrong.
+     * @return The normalized DN
      */
     public LdapDN normalize( Map<String, OidNormalizer> oidsMap ) throws NamingException
     {
@@ -1701,6 +1702,9 @@
      * 
      * for each rdn :
      * <li>call the RDN write method</li>
+     *
+     *@param out The stream in which the DN will be serialized
+     *@throws IOException If the serialization fail
      */
     public void writeExternal( ObjectOutput out ) throws IOException
     {
@@ -1754,8 +1758,12 @@
      * We read back the data to create a new LdapDN. The structure 
      * read is exposed in the {@link LdapDN#writeExternal(ObjectOutput)} 
      * method<p>
+     * 
+     * @param in The stream from which the DN is read
+     * @throws IOException If the stream can't be read
+     * @throws ClassNotFoundException If the RDN can't be created 
      */
-    public void readExternal( ObjectInput in ) throws IOException, ClassNotFoundException
+    public void readExternal( ObjectInput in ) throws IOException , ClassNotFoundException
     {
         // Read the UPName
         upName = in.readUTF();

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/name/LdapDnParser.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/name/LdapDnParser.java?rev=655677&r1=655676&r2=655677&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/name/LdapDnParser.java
(original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/name/LdapDnParser.java
Mon May 12 15:34:01 2008
@@ -24,13 +24,13 @@
 
 import javax.naming.InvalidNameException;
 import javax.naming.Name;
+import javax.naming.NameParser;
+
 
 import org.apache.directory.shared.ldap.util.DNUtils;
 import org.apache.directory.shared.ldap.util.Position;
 import org.apache.directory.shared.ldap.util.StringTools;
 
-import javax.naming.NameParser;
-
 
 /**
  * This class parses a DN. The DN MUST respect this BNF grammar (as of RFC2253,
@@ -65,6 +65,7 @@
  * </p>
  *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
  */
 public class LdapDnParser implements NameParser
 {
@@ -144,8 +145,8 @@
                rdns.add( rdn );
                rdn = new Rdn();
 
-               if ( ( StringTools.isCharASCII( dn, pos.start, ',' ) == false )
-                   && ( StringTools.isCharASCII( dn, pos.start, ';' ) == false )
)
+               if ( ( !StringTools.isCharASCII( dn, pos.start, ',' ) )
+                   && ( !StringTools.isCharASCII( dn, pos.start, ';' ) ) )
                {
 
                    if ( pos.start != dn.length )
@@ -192,8 +193,8 @@
            // Now, parse the following nameComponents
            do
            {
-               if ( ( StringTools.isCharASCII( dn, pos.start, ',' ) == false )
-                   && ( StringTools.isCharASCII( dn, pos.start, ';' ) == false )
)
+               if ( ( !StringTools.isCharASCII( dn, pos.start, ',' ) )
+                   && ( !StringTools.isCharASCII( dn, pos.start, ';' ) ) )
                {
 
                    if ( pos.start != dn.length )

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=655677&r1=655676&r2=655677&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
Mon May 12 15:34:01 2008
@@ -106,6 +106,7 @@
  * are not case sensitive, we can say that a = A
  *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
  */
 public class Rdn implements Cloneable, Comparable, Serializable, Iterable<AttributeTypeAndValue>
 {
@@ -259,8 +260,6 @@
     *            The type of the RDN
     * @param value
     *            The value of the RDN
-    * @throws InvalidNameException
-    *             If the RDN is invalid
     */
    /* No protection */ Rdn( int start, int length, String upName, String normName )
    {
@@ -435,8 +434,6 @@
     *            The type of the added RDN.
     * @param value
     *            The value of the added RDN
-    * @throws InvalidNameException
-    *             If the RDN is invalid
     */
    // WARNING : The protection level is left unspecified intentionnaly.
    // We need this method to be visible from the DnParser class, but not
@@ -1025,21 +1022,14 @@
                break;
 
            default :
-               Iterator types = atavTypes.keySet().iterator();
-
-               while ( types.hasNext() )
+               for ( String type:atavTypes.keySet() )
                {
-                   String type = ( String ) types.next();
-                   List values = ( List ) atavTypes.get( type );
+                   List<AttributeTypeAndValue> values = ( List<AttributeTypeAndValue>
) atavTypes.get( type );
 
                    attribute = new AttributeImpl( type );
 
-                   Iterator<AttributeTypeAndValue> iterValues = values.iterator();
-
-                   while ( iterValues.hasNext() )
+                   for ( AttributeTypeAndValue value:values )
                    {
-                       AttributeTypeAndValue value = iterValues.next();
-
                        attribute.add( value.getNormValue() );
                    }
 

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=655677&r1=655676&r2=655677&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
Mon May 12 15:34:01 2008
@@ -84,6 +84,7 @@
  * <br>
  *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
  */
 public class RdnParser
 {
@@ -104,7 +105,7 @@
         pos.end = pos.start;
 
         // <attributType> ::= [0-9] <digits> <oids>
-        if ( StringTools.isDigit( bytes, pos.start ) == false )
+        if ( !StringTools.isDigit( bytes, pos.start ) )
         {
             // Nope... An error
             return null;
@@ -120,7 +121,7 @@
             }
 
             // <oids> ::= '.' [0-9] <digits> <oids> | e
-            if ( StringTools.isCharASCII( bytes, pos.end, '.' ) == false )
+            if ( !StringTools.isCharASCII( bytes, pos.end, '.' ) )
             {
                 return null;
             }
@@ -130,7 +131,7 @@
                 {
                     pos.end++;
 
-                    if ( StringTools.isDigit( bytes, pos.end ) == false )
+                    if ( !StringTools.isDigit( bytes, pos.end ) )
                     {
                         return null;
                     }
@@ -169,7 +170,7 @@
         pos.end = pos.start;
 
         // <attributType> ::= [0-9] <digits> <oids>
-        if ( StringTools.isDigit( bytes, pos.start ) == false )
+        if ( !StringTools.isDigit( bytes, pos.start ) )
         {
             // Nope... An error
             return false;
@@ -185,7 +186,7 @@
             }
 
             // <oids> ::= '.' [0-9] <digits> <oids> | e
-            if ( StringTools.isCharASCII( bytes, pos.end, '.' ) == false )
+            if ( !StringTools.isCharASCII( bytes, pos.end, '.' ) )
             {
                 return false;
             }
@@ -195,7 +196,7 @@
                 {
                     pos.end++;
 
-                    if ( StringTools.isDigit( bytes, pos.end ) == false )
+                    if ( !StringTools.isDigit( bytes, pos.end ) )
                     {
                         return false;
                     }
@@ -485,7 +486,7 @@
                         }
                         else
                         {
-                            if ( hasPairChar == false )
+                            if ( !hasPairChar )
                             {
                                 hasPairChar = true;
                             }
@@ -528,10 +529,11 @@
                             //StringTools.trimLeft( string, pos );
 
                             if ( ( DNUtils.isStringChar( bytes, pos.end ) == DNUtils.PARSING_ERROR
)
-                                && ( StringTools.isCharASCII( bytes, pos.end, '\\'
) == false ) )
+                                && ( !StringTools.isCharASCII( bytes, pos.end, '\\'
) ) )
                             {
                                 // Ok, we are done with the stringchar.
-                                String result = StringTools.trimRight( StringTools.utf8ToString(
bytes, pos.start, pos.start + pos.length ) );
+                                String result = StringTools.trimRight( 
+                                    StringTools.utf8ToString( bytes, pos.start, pos.start
+ pos.length ) );
                                 
                                 return result;
                             }
@@ -710,7 +712,7 @@
                             //StringTools.trimLeft( string, pos );
 
                             if ( ( DNUtils.isStringChar( bytes, pos.end ) == DNUtils.PARSING_ERROR
)
-                                && ( StringTools.isCharASCII( bytes, pos.end, '\\'
) == false ) )
+                                && ( !StringTools.isCharASCII( bytes, pos.end, '\\'
) ) )
                             {
                                 // Ok, we are done with the stringchar.
                                 return true;
@@ -930,7 +932,7 @@
 
         StringTools.trimLeft( dn, pos );
 
-        if ( StringTools.isCharASCII( dn, pos.start, '=' ) == false )
+        if ( !StringTools.isCharASCII( dn, pos.start, '=' ) )
         {
             return DNUtils.PARSING_ERROR;
         }
@@ -974,11 +976,12 @@
      *
      * @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 )
+    public static boolean isValid( String dn, Position pos, boolean isFirstRdn )
     {
-        return isValid( StringTools.getBytesUtf8( dn ), pos, isfirstRdn );
+        return isValid( StringTools.getBytesUtf8( dn ), pos, isFirstRdn );
     }
 
 
@@ -1009,7 +1012,7 @@
 
         StringTools.trimLeft( dn, pos );
 
-        if ( StringTools.isCharASCII( dn, pos.start, '=' ) == false )
+        if ( !StringTools.isCharASCII( dn, pos.start, '=' ) )
         {
             return false;
         }

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=655677&r1=655676&r2=655677&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
Mon May 12 15:34:01 2008
@@ -94,7 +94,7 @@
      * read is exposed in the {@link Rdn#writeExternal(ObjectOutput)} 
      * method<p>
      */
-    public static Rdn deserialize( ObjectInput in ) throws IOException, ClassNotFoundException
+    public static Rdn deserialize( ObjectInput in ) throws IOException
     {
         // Read the ATAV number
         int nbAtavs = in.readInt();



Mime
View raw message