directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r657508 - /directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/name/Rdn.java
Date Sun, 18 May 2008 08:02:38 GMT
Author: elecharny
Date: Sun May 18 01:02:38 2008
New Revision: 657508

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

Modified:
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/name/Rdn.java

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=657508&r1=657507&r2=657508&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 01:02:38 2008
@@ -251,15 +251,12 @@
 
 
    /**
-    * A constructor that constructs a RDN from a type and a value. Constructs
-    * an Rdn from the given attribute type and value. The string attribute
-    * values are not interpreted as RFC 2253 formatted RDN strings. That is,
-    * the values are used literally (not parsed) and assumed to be unescaped.
+    * A constructor that constructs a RDN from a type, a position and a length.
     *
-    * @param start 
-    *            The type of the RDN
-    * @param value
-    *            The value of the RDN
+    * @param start The starting point for this RDN in the user provided DN
+    * @param length The RDN's length
+    * @param upName The user provided name
+    * @param normName the normalized name
     */
    /* No protection */ Rdn( int start, int length, String upName, String normName )
    {
@@ -430,24 +427,21 @@
    /**
     * Add a AttributeTypeAndValue to the current RDN
     *
-    * @param type
-    *            The type of the added RDN.
-    * @param value
-    *            The value of the added RDN
+    * @param value The added AttributeTypeAndValue
     */
    // WARNING : The protection level is left unspecified intentionnaly.
    // We need this method to be visible from the DnParser class, but not
    // from outside this package.
    @SuppressWarnings({"unchecked"})
-   /* Unspecified protection */void addAttributeTypeAndValue( AttributeTypeAndValue atav
)
+   /* Unspecified protection */void addAttributeTypeAndValue( AttributeTypeAndValue value
)
    {
-       String normalizedType = atav.getNormType();
+       String normalizedType = value.getNormType();
 
        switch ( nbAtavs )
        {
            case 0:
                // This is the first AttributeTypeAndValue. Just stores it.
-               this.atav = atav;
+               this.atav = value;
                nbAtavs = 1;
                atavType = normalizedType;
                return;
@@ -470,8 +464,8 @@
 
            default:
                // add a new AttributeTypeAndValue
-               atavs.add( atav );
-               atavTypes.put( normalizedType, atav );
+               atavs.add( value );
+               atavTypes.put( normalizedType, value );
 
                nbAtavs++;
                break;
@@ -504,6 +498,7 @@
     * @param type
     *            The type of the NameArgument
     * @return The Value to be returned, or null if none found.
+    * @throws InvalidNameException 
     */
    public Object getValue( String type ) throws InvalidNameException
    {
@@ -520,10 +515,8 @@
                {
                    return atav.getNormValue();
                }
-               else
-               {
-                   return "";
-               }
+
+               return "";
 
            default:
                if ( atavTypes.containsKey( normalizedType ) )
@@ -538,11 +531,10 @@
                    {
                        StringBuffer sb = new StringBuffer();
                        boolean isFirst = true;
+                       List<AttributeTypeAndValue> atavList = ( ( List<AttributeTypeAndValue>
) obj );
 
-                       for ( int i = 0; i < ( ( List ) obj ).size(); i++ )
+                       for ( AttributeTypeAndValue elem:atavList )
                        {
-                           AttributeTypeAndValue elem = ( AttributeTypeAndValue ) ( ( List
) obj ).get( i );
-
                            if ( isFirst )
                            {
                                isFirst = false;
@@ -562,10 +554,8 @@
                        throw new InvalidNameException( "Bad object stored in the RDN" );
                    }
                }
-               else
-               {
-                   return "";
-               }
+
+               return "";
        }
    }
 
@@ -615,20 +605,16 @@
                {
                    return atav;
                }
-               else
-               {
-                   return null;
-               }
+
+               return null;
 
            default:
                if ( atavTypes.containsKey( normalizedType ) )
                {
                    return atavTypes.get( normalizedType );
                }
-               else
-               {
-                   return null;
-               }
+
+               return null;
        }
    }
 
@@ -678,8 +664,9 @@
 
    /**
     * Clone the Rdn
+    * 
+    * @return A clone of the current RDN
     */
-   @SuppressWarnings({"unchecked"})
    public Object clone()
    {
        try
@@ -816,7 +803,7 @@
 
 
    /**
-    * Returns a String representation of the RDN
+    * @return a String representation of the RDN
     */
    public String toString()
    {
@@ -825,7 +812,7 @@
 
 
    /**
-    * Returns a String representation of the RDN
+    * @return the user provided name
     */
    public String getUpName()
    {
@@ -834,7 +821,7 @@
 
 
    /**
-    * Returns The normalized name
+    * @return The normalized name
     */
    public String getNormName()
    {
@@ -844,6 +831,7 @@
 
    /**
     * Set the User Provided Name
+    * @param upName the User Provided dame 
     */
    public void setUpName( String upName )
    {
@@ -877,7 +865,7 @@
                return atav;
 
            default:
-               return (AttributeTypeAndValue)((TreeSet)atavs).first();
+               return ((TreeSet<AttributeTypeAndValue>)atavs).first();
        }
    }
 
@@ -898,7 +886,7 @@
                return atav.getUpType();
 
            default:
-               return ( ( AttributeTypeAndValue )((TreeSet)atavs).first() ).getUpType();
+               return ((TreeSet<AttributeTypeAndValue>)atavs).first().getUpType();
        }
    }
 
@@ -918,7 +906,7 @@
                return atav.getNormType();
 
            default:
-               return ( ( AttributeTypeAndValue )((TreeSet)atavs).first() ).getNormType();
+               return ((TreeSet<AttributeTypeAndValue>)atavs).first().getNormType();
        }
    }
 
@@ -938,7 +926,7 @@
                return atav.getNormValue();
 
            default:
-               return ( ( AttributeTypeAndValue )((TreeSet)atavs).first() ).getNormValue();
+               return ((TreeSet<AttributeTypeAndValue>)atavs).first().getNormValue();
        }
    }
 
@@ -959,7 +947,7 @@
                return atav.getUpValue();
 
            default:
-               return ( ( AttributeTypeAndValue )((TreeSet)atavs).first() ).getUpValue();
+               return ((TreeSet<AttributeTypeAndValue>)atavs).first().getUpValue();
        }
    }
    
@@ -1060,7 +1048,7 @@
     * @throws IllegalArgumentException -
     *             When an Illegal value is provided.
     */
-   public static Object unescapeValue( String value ) throws IllegalArgumentException
+   public static Object unescapeValue( String value )
    {
        if ( StringTools.isEmpty( value ) )
        {
@@ -1136,6 +1124,8 @@
                                isHex = true;
                                pair = ( (byte)( StringTools.getHexValue( chars[i] ) <<
4 ) );
                            }
+                       
+                           break;
                    }
                }
                else
@@ -1172,11 +1162,10 @@
 
                            default:
                                byte[] result = StringTools.charToBytes( chars[i] );
-
-                               for ( int j = 0; j < result.length; j++ )
-                               {
-                                   bytes[pos++] = result[j];
-                               }
+                               System.arraycopy( result, 0, bytes, pos, result.length );
+                               pos += result.length;
+                               
+                               break;
                        }
                    }
                }
@@ -1296,6 +1285,7 @@
 
                default:
                    newChars[pos++] = chars[i];
+                   break;
 
            }
        }
@@ -1350,6 +1340,8 @@
                {
                    result = result * 17 + ata.hashCode();
                }
+           
+               break;
        }
 
        return result;
@@ -1373,7 +1365,9 @@
     * <li>start</li> The position of this ATAV in the upName string
     * <li>length</li> The ATAV user provided length
     * <li>Call the ATAV write method</li> The ATAV itself
-    *  
+    * 
+    * @param out The stream into which the serialized RDN will be put
+    * @throws IOException If the stream can't be written
     */
    public void writeExternal( ObjectOutput out ) throws IOException
    {
@@ -1402,9 +1396,9 @@
                break;
                
            default :
-               for ( AttributeTypeAndValue atav:atavs )
+               for ( AttributeTypeAndValue value:atavs )
                {
-                   out.writeObject( atav );
+                   out.writeObject( value );
                }
            
                break;
@@ -1420,6 +1414,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 will be read
+    * @throws IOException If we can't read from the input stream
+    * @throws ClassNotFoundException If we can't create a new RDN
     */
    public void readExternal( ObjectInput in ) throws IOException, ClassNotFoundException
    {
@@ -1459,9 +1457,9 @@
 
                for ( int i = 0; i < nbAtavs; i++  )
                {
-                   AttributeTypeAndValue atav = (AttributeTypeAndValue)in.readObject();
-                   atavs.add( atav );
-                   atavTypes.put( atav.getNormType(), atav );
+                   AttributeTypeAndValue value = (AttributeTypeAndValue)in.readObject();
+                   atavs.add( value );
+                   atavTypes.put( value.getNormType(), value );
                }
            
                atav = null;



Mime
View raw message