directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r480965 - in /directory/trunks/shared/ldap/src: main/java/org/apache/directory/shared/ldap/codec/search/ main/java/org/apache/directory/shared/ldap/ldif/ main/java/org/apache/directory/shared/ldap/name/ test/java/org/apache/directory/shared...
Date Thu, 30 Nov 2006 15:31:03 GMT
Author: elecharny
Date: Thu Nov 30 07:31:01 2006
New Revision: 480965

URL: http://svn.apache.org/viewvc?view=rev&rev=480965
Log:
Removed some warning by using Java 5 generics

Modified:
    directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/SearchResultEntry.java
    directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/ldif/Entry.java
    directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/ldif/LdifReader.java
    directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/name/AttributeTypeAndValue.java
    directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/name/LdapDN.java
    directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/name/LdapDnParser.java
    directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/name/Rdn.java
    directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/codec/search/SearchRequestTest.java
    directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/name/DnParserDIRSERVER_584_Test.java

Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/SearchResultEntry.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/SearchResultEntry.java?view=diff&rev=480965&r1=480964&r2=480965
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/SearchResultEntry.java
(original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/SearchResultEntry.java
Thu Nov 30 07:31:01 2006
@@ -88,10 +88,10 @@
     private transient int attributesLength;
 
     /** The list of all attributes length */
-    private transient List attributeLength;
+    private transient List<Integer> attributeLength;
 
     /** The list of all vals length */
-    private transient List valsLength;
+    private transient List<Integer> valsLength;
 
 
     // ~ Constructors
@@ -240,8 +240,8 @@
         if ( ( partialAttributeList != null ) && ( partialAttributeList.size() !=
0 ) )
         {
             NamingEnumeration attributes = partialAttributeList.getAll();
-            attributeLength = new LinkedList();
-            valsLength = new LinkedList();
+            attributeLength = new LinkedList<Integer>();
+            valsLength = new LinkedList<Integer>();
 
             // Compute the attributes length
             while ( attributes.hasMoreElements() )
@@ -313,8 +313,8 @@
                 // add the attribute length to the attributes length
                 attributesLength += 1 + TLV.getNbBytes( localAttributeLength ) + localAttributeLength;
 
-                attributeLength.add( new Integer( localAttributeLength ) );
-                valsLength.add( new Integer( localValuesLength ) );
+                attributeLength.add( localAttributeLength );
+                valsLength.add( localValuesLength );
             }
         }
 
@@ -383,7 +383,7 @@
 
                     // The partial attribute list sequence
                     buffer.put( UniversalTag.SEQUENCE_TAG );
-                    int localAttributeLength = ( ( Integer ) attributeLength.get( attributeNumber
) ).intValue();
+                    int localAttributeLength = attributeLength.get( attributeNumber );
                     buffer.put( TLV.getBytes( localAttributeLength ) );
 
                     // The attribute type
@@ -391,7 +391,7 @@
 
                     // The values
                     buffer.put( UniversalTag.SET_TAG );
-                    int localValuesLength = ( ( Integer ) valsLength.get( attributeNumber
) ).intValue();
+                    int localValuesLength = valsLength.get( attributeNumber );
                     buffer.put( TLV.getBytes( localValuesLength ) );
 
                     if ( attribute.size() != 0 )

Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/ldif/Entry.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/ldif/Entry.java?view=diff&rev=480965&r1=480964&r2=480965
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/ldif/Entry.java
(original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/ldif/Entry.java
Thu Nov 30 07:31:01 2006
@@ -22,7 +22,6 @@
 
 import java.util.Enumeration;
 import java.util.HashMap;
-import java.util.Iterator;
 import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
@@ -53,9 +52,9 @@
     private int changeType;
 
     /** the modification item list */
-    private List modificationList;
+    private List<ModificationItem> modificationList;
 
-    private Map modificationItems;
+    private Map<String, ModificationItem> modificationItems;
 
     /** the dn of the ldif entry */
     private String dn;
@@ -92,8 +91,8 @@
     public Entry()
     {
         changeType = ADD; // Default LDIF content
-        modificationList = new LinkedList();
-        modificationItems = new HashMap();
+        modificationList = new LinkedList<ModificationItem>();
+        modificationItems = new HashMap<String, ModificationItem>();
         dn = null;
         attributeList = new BasicAttributes( true );
         control = null;
@@ -182,7 +181,7 @@
         {
             if ( modificationItems.containsKey( attr.getID() ) )
             {
-                ModificationItem item = (ModificationItem) modificationItems.get( attr.getID()
);
+                ModificationItem item = modificationItems.get( attr.getID() );
                 Attribute attribute = item.getAttribute();
 
                 Enumeration attrs = attr.getAll();
@@ -221,7 +220,7 @@
 
             if ( modificationItems.containsKey( id ) )
             {
-                ModificationItem item = (ModificationItem) modificationItems.get( id );
+                ModificationItem item = modificationItems.get( id );
                 
                 if ( item.getModificationOp() != modOp )
                 {
@@ -317,7 +316,7 @@
     /**
      * @return The list of modification items
      */
-    public List getModificationItems()
+    public List<ModificationItem> getModificationItems()
     {
         return modificationList;
     }
@@ -502,9 +501,8 @@
 
         if ( modificationList != null )
         {
-            for ( Iterator iter = modificationList.iterator(); iter.hasNext(); )
+            for ( ModificationItem modif:modificationList )
             {
-                ModificationItem modif = (ModificationItem) ( iter.next() );
                 ModificationItem modifClone = new ModificationItem( modif.getModificationOp(),
(Attribute) modif.getAttribute()
                         .clone() );
                 clone.modificationList.add( modifClone );
@@ -513,10 +511,9 @@
 
         if ( modificationItems != null )
         {
-            for ( Iterator iter = modificationItems.entrySet().iterator(); iter.hasNext();
)
+            for ( String key:modificationItems.keySet() )
             {
-                Object key = iter.next();
-                ModificationItem modif = (ModificationItem) ( modificationItems.get( key
) );
+                ModificationItem modif = modificationItems.get( key );
                 ModificationItem modifClone = new ModificationItem( modif.getModificationOp(),
(Attribute) modif.getAttribute()
                         .clone() );
                 clone.modificationItems.put( key, modifClone );
@@ -609,10 +606,8 @@
     {
         StringBuffer sb = new StringBuffer();
         
-        for ( Iterator iter = modificationList.iterator(); iter.hasNext(); )
+        for ( ModificationItem modif:modificationList )
         {
-            ModificationItem modif = (ModificationItem) ( iter.next() );
-            
             sb.append( "            Operation: " );
             
             switch ( modif.getModificationOp() )

Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/ldif/LdifReader.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/ldif/LdifReader.java?view=diff&rev=480965&r1=480964&r2=480965
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/ldif/LdifReader.java
(original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/ldif/LdifReader.java
Thu Nov 30 07:31:01 2006
@@ -48,6 +48,7 @@
 import org.apache.directory.shared.asn1.codec.DecoderException;
 import org.apache.directory.shared.asn1.primitives.OID;
 import org.apache.directory.shared.ldap.name.LdapDnParser;
+import org.apache.directory.shared.ldap.name.Rdn;
 import org.apache.directory.shared.ldap.util.Base64;
 import org.apache.directory.shared.ldap.util.StringTools;
 import org.slf4j.Logger;
@@ -175,7 +176,7 @@
     }
 
     /** A list of read lines */
-    private List lines;
+    private List<String> lines;
 
     /** The current position */
     private Position position;
@@ -229,7 +230,7 @@
      */
     public LdifReader()
     {
-        lines = new ArrayList();
+        lines = new ArrayList<String>();
         position = new Position();
         version = DEFAULT_VERSION;
     }
@@ -237,7 +238,7 @@
     private void init( BufferedReader in ) throws NamingException
     {
         this.in = in;
-        lines = new ArrayList();
+        lines = new ArrayList<String>();
         position = new Position();
         version = DEFAULT_VERSION;
         containsChanges = false;
@@ -527,7 +528,7 @@
         // Check that the DN is valid. If not, an exception will be thrown
         try
         {
-            LdapDnParser.parseInternal( dn, new ArrayList() );
+            LdapDnParser.parseInternal( dn, new ArrayList<Rdn>() );
         }
         catch (InvalidNameException ine)
         {
@@ -1168,7 +1169,7 @@
         }
 
         // The entry must start with a dn: or a dn::
-        String line = ( (String) lines.get( 0 ) );
+        String line = lines.get( 0 );
 
         String dn = parseDn( line );
 
@@ -1325,7 +1326,7 @@
         }
 
         // get the first line
-        String line = (String) lines.get( 0 );
+        String line = lines.get( 0 );
 
         // <ldif-file> ::= "version:" <fill> <number>
         char[] document = line.toCharArray();
@@ -1655,10 +1656,10 @@
      * @throws NamingException
      *             If something went wrong
      */
-    public List parseLdif( BufferedReader in ) throws NamingException
+    public List<Entry> parseLdif( BufferedReader in ) throws NamingException
     {
         // Create a list that will contain the read entries
-        List entries = new ArrayList();
+        List<Entry> entries = new ArrayList<Entry>();
 
         this.in = in;
 

Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/name/AttributeTypeAndValue.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/name/AttributeTypeAndValue.java?view=diff&rev=480965&r1=480964&r2=480965
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/name/AttributeTypeAndValue.java
(original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/name/AttributeTypeAndValue.java
Thu Nov 30 07:31:01 2006
@@ -129,35 +129,6 @@
    }
 
    /**
-    * Construct an AttributeTypeAndValue. The type and value are normalized :
-    * - the type is trimmed and lowercased
-    * - the value is trimmed
-    *
-    * @param type
-    *            The type
-    * @param value
-    *            the value
-    */
-   /*public AttributeTypeAndValue(String dn, int start, int length ) throws InvalidNameException
-   {
-       if ( StringTools.isEmpty( dn ) || StringTools.isEmpty( dn.trim() ) )
-       {
-           log.error( "The atav cannot be empty or null" );
-           throw new InvalidNameException( "Null or empty atav is not allowed" );
-       }
-
-       String atav = dn.substring( start, start + length );
-       String type = atav.substring( 0, atav.indexOf( '=' ) );
-       String value = dn.substring( start + type.length() + 1, start + length );
-
-       this.type = type.trim().toLowerCase();
-       this.value = StringTools.isEmpty( value ) ? "" : value.trim();
-       upName = atav;
-       this.start = start;
-       this.length = length;
-   }*/
-
-   /**
     * Get the type of a AttributeTypeAndValue
     *
     * @return The type

Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/name/LdapDN.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/name/LdapDN.java?view=diff&rev=480965&r1=480964&r2=480965
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/name/LdapDN.java
(original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/name/LdapDN.java
Thu Nov 30 07:31:01 2006
@@ -81,7 +81,7 @@
    // ~ Static fields/initializers
    // -----------------------------------------------------------------
    /** The RDNs that are elements of the DN */
-   private List rdns = new ArrayList( 5 );
+   private List<Rdn> rdns = new ArrayList<Rdn>( 5 );
 
    /** The user provided name */
    private String upName;
@@ -255,7 +255,7 @@
            StringBuffer sb = new StringBuffer();
            boolean isFirst = true;
 
-           for ( int i = 0; i < rdns.size(); i++ )
+           for ( Rdn rdn:rdns )
            {
                if ( isFirst )
                {
@@ -266,7 +266,7 @@
                    sb.append( ',' );
                }
 
-               sb.append( ( ( Rdn ) rdns.get( i ) ) );
+               sb.append( rdn );
            }
 
            String newNormName = sb.toString();
@@ -310,7 +310,7 @@
            StringBuffer sb = new StringBuffer();
            boolean isFirst = true;
 
-           for ( int i = 0; i < rdns.size(); i++ )
+           for ( Rdn rdn:rdns )
            {
                if ( isFirst )
                {
@@ -321,7 +321,7 @@
                    sb.append( ',' );
                }
 
-               sb.append( ( ( Rdn ) rdns.get( i ) ).getUpName() );
+               sb.append( rdn.getUpName() );
            }
 
            upName = sb.toString();
@@ -379,7 +379,7 @@
                sb.append( ',' );
            }
 
-           sb.append( ( ( Rdn ) rdns.get( i ) ).getUpName() );
+           sb.append( rdns.get( i ).getUpName() );
        }
 
        return sb.toString();
@@ -425,7 +425,7 @@
                sb.append( ',' );
            }
 
-           sb.append( ( ( Rdn ) rdns.get( i ) ).getUpName() );
+           sb.append( rdns.get( i ).getUpName() );
        }
 
        return sb.toString();
@@ -443,10 +443,10 @@
 
        if ( ( rdns != null ) || ( rdns.size() == 0 ) )
        {
-               for ( Iterator rdnsIter = rdns.iterator(); rdnsIter.hasNext(); )
-               {
-                       result = result * 37 + rdnsIter.next().hashCode();
-               }
+           for ( Rdn rdn:rdns )
+           {
+               result = result * 37 + rdn.hashCode();
+           }
        }
 
        return result;
@@ -544,8 +544,8 @@
 
            for ( int i = nameDN.size() - 1; i >= 0; i-- )
            {
-               Rdn nameRdn = ( Rdn ) ( nameDN.rdns.get( nameDN.rdns.size() - i - 1 ) );
-               Rdn ldapRdn = ( Rdn ) rdns.get( rdns.size() - i - 1 );
+               Rdn nameRdn = nameDN.rdns.get( nameDN.rdns.size() - i - 1 );
+               Rdn ldapRdn = rdns.get( rdns.size() - i - 1 );
 
                if ( nameRdn.compareTo( ldapRdn ) != 0 )
                {
@@ -573,8 +573,9 @@
 
            for ( int i = name.size() - 1; i >= 0; i-- )
            {
-               Rdn ldapRdn = ( Rdn ) rdns.get( rdns.size() - i - 1 );
+               Rdn ldapRdn = rdns.get( rdns.size() - i - 1 );
                Rdn nameRdn = null;
+               
                try
                {
                    nameRdn = new Rdn( ( String ) name.get( name.size() - i - 1 ) );
@@ -634,8 +635,8 @@
            // Ok, iterate through all the RDN of the name
            for ( int i = 0; i < nameDN.size(); i++ )
            {
-               Rdn nameRdn = ( Rdn ) ( nameDN.rdns.get( i ) );
-               Rdn ldapRdn = ( Rdn ) rdns.get( i );
+               Rdn nameRdn = nameDN.rdns.get( i );
+               Rdn ldapRdn = rdns.get( i );
 
                if ( nameRdn.compareTo( ldapRdn ) != 0 )
                {
@@ -683,7 +684,7 @@
        }
        else
        {
-           Rdn rdn = ( Rdn ) rdns.get( rdns.size() - posn - 1 );
+           Rdn rdn = rdns.get( rdns.size() - posn - 1 );
 
            return rdn.toString();
        }
@@ -708,7 +709,7 @@
        }
        else
        {
-           Rdn rdn = ( Rdn ) rdns.get( rdns.size() - posn - 1 );
+           Rdn rdn = rdns.get( rdns.size() - posn - 1 );
 
            return rdn;
        }
@@ -727,9 +728,7 @@
        }
        else
        {
-           Rdn rdn = ( Rdn ) rdns.get( 0 );
-
-           return rdn;
+           return rdns.get( 0 );
        }
    }
 
@@ -741,12 +740,12 @@
     */
    public List getRdns()
    {
-       List newRdns = new ArrayList();
+       List<Rdn> newRdns = new ArrayList<Rdn>();
 
        // We will clone the list, to avoid user modifications
-       for ( int i = 0; i < rdns.size(); i++ )
+       for ( Rdn rdn:rdns )
        {
-           newRdns.add( i, ( ( Rdn ) rdns.get( i ) ).clone() );
+           newRdns.add( (Rdn)rdn.clone() );
        }
 
        return newRdns;
@@ -760,7 +759,7 @@
     *
     * @return an enumeration of the components of this name, each as string
     */
-   public Enumeration getAll()
+   public Enumeration<String> getAll()
    {
        /*
         * Note that by accessing the name component using the get() method on
@@ -768,7 +767,7 @@
         * right to left with increasing index values. LdapName.get() does the
         * index translation on m_list for us.
         */
-       return new Enumeration()
+       return new Enumeration<String>()
        {
            private int pos;
 
@@ -779,7 +778,7 @@
            }
 
 
-           public Object nextElement()
+           public String nextElement()
            {
                if ( pos >= rdns.size() )
                {
@@ -787,9 +786,9 @@
                    throw new NoSuchElementException();
                }
 
-               Object obj = rdns.get( rdns.size() - pos - 1 );
+               Rdn rdn = rdns.get( rdns.size() - pos - 1 );
                pos++;
-               return obj.toString();
+               return rdn.toString();
            }
        };
    }
@@ -802,7 +801,7 @@
     *
     * @return an enumeration of the components of this name, as Rdn
     */
-   public Enumeration getAllRdn()
+   public Enumeration<Rdn> getAllRdn()
    {
        /*
         * Note that by accessing the name component using the get() method on
@@ -810,7 +809,7 @@
         * right to left with increasing index values. LdapName.get() does the
         * index translation on m_list for us.
         */
-       return new Enumeration()
+       return new Enumeration<Rdn>()
        {
            private int pos;
 
@@ -821,7 +820,7 @@
            }
 
 
-           public Object nextElement()
+           public Rdn nextElement()
            {
                if ( pos >= rdns.size() )
                {
@@ -829,9 +828,9 @@
                    throw new NoSuchElementException();
                }
 
-               Object obj = rdns.get( rdns.size() - pos - 1 );
+               Rdn rdn = rdns.get( rdns.size() - pos - 1 );
                pos++;
-               return obj;
+               return rdn;
            }
        };
    }
@@ -869,7 +868,7 @@
        for ( int i = rdns.size() - posn; i < rdns.size(); i++ )
        {
            // Don't forget to clone the rdns !
-           newLdapDN.rdns.add( ( ( Rdn ) rdns.get( i ) ).clone() );
+           newLdapDN.rdns.add( ( Rdn ) rdns.get( i ).clone() );
        }
 
        newLdapDN.normName = newLdapDN.toNormName();
@@ -912,7 +911,7 @@
        for ( int i = 0; i < size() - posn; i++ )
        {
            // Don't forget to clone the rdns !
-           newLdapDN.rdns.add( ( ( Rdn ) rdns.get( i ) ).clone() );
+           newLdapDN.rdns.add( ( Rdn ) rdns.get( i ).clone() );
        }
 
        newLdapDN.normName = newLdapDN.toNormName();
@@ -983,14 +982,16 @@
                return this;
            }
 
-           for ( int ii = name.size() - 1; ii >= 0; ii-- )
+           for ( int i = name.size() - 1; i >= 0; i-- )
            {
-               Rdn rdn = new Rdn( name.get( ii ) );
+               Rdn rdn = new Rdn( name.get( i ) );
                rdns.add( size() - posn, rdn );
            }
+           
            normalizeInternal();
            toUpName();
        }
+       
        return this;
    }
 
@@ -1105,7 +1106,7 @@
        }
 
        int realPos = size() - posn - 1;
-       Rdn rdn = ( Rdn ) rdns.remove( realPos );
+       Rdn rdn = rdns.remove( realPos );
 
        normalizeInternal();
        toUpName();
@@ -1126,11 +1127,11 @@
        try
        {
            LdapDN dn = ( LdapDN ) super.clone();
-           dn.rdns = new ArrayList();
+           dn.rdns = new ArrayList<Rdn>();
 
-           for ( int i = 0; i < rdns.size(); i++ )
+           for ( Rdn rdn:rdns )
            {
-               dn.rdns.add( i, ( ( Rdn ) rdns.get( i ) ).clone() );
+               dn.rdns.add( ( Rdn ) rdn.clone() );
            }
 
            return dn;
@@ -1161,9 +1162,9 @@
                return false;
            }
 
-           for ( int i = 0; i < size(); i++ )
+           for ( int i = 0; i < this.size(); i++ )
            {
-               if ( ( ( Rdn ) name.rdns.get( i ) ).compareTo( rdns.get( i ) ) != 0 )
+               if ( name.rdns.get( i ).compareTo( rdns.get( i ) ) != 0 )
                {
                    return false;
                }
@@ -1213,8 +1214,8 @@
 
            for ( int i = rdns.size(); i > 0; i-- )
            {
-               Rdn rdn1 = ( Rdn ) rdns.get( i - 1 );
-               Rdn rdn2 = ( Rdn ) ldapDN.rdns.get( i - 1 );
+               Rdn rdn1 = rdns.get( i - 1 );
+               Rdn rdn2 = ldapDN.rdns.get( i - 1 );
                int res = rdn1.compareTo( rdn2 );
 
                if ( res != 0 )
@@ -1383,12 +1384,12 @@
 
        LdapDN newDn = ( LdapDN ) dn.clone();
 
-       Enumeration rdns = newDn.getAllRdn();
+       Enumeration<Rdn> rdns = newDn.getAllRdn();
 
        // Loop on all RDNs
        while ( rdns.hasMoreElements() )
        {
-           Rdn rdn = ( Rdn ) rdns.nextElement();
+           Rdn rdn = rdns.nextElement();
            String upName = rdn.getUpName();
            rdnOidToName( rdn, oidsMap );
            rdn.normalizeString();
@@ -1422,12 +1423,12 @@
            return;
        }
 
-       Enumeration rdns = getAllRdn();
+       Enumeration<Rdn> rdns = getAllRdn();
 
        // Loop on all RDNs
        while ( rdns.hasMoreElements() )
        {
-           Rdn rdn = ( Rdn ) rdns.nextElement();
+           Rdn rdn = rdns.nextElement();
            String upName = rdn.getUpName();
            rdnOidToName( rdn, oidsMap );
            rdn.normalizeString();

Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/name/LdapDnParser.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/name/LdapDnParser.java?view=diff&rev=480965&r1=480964&r2=480965
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/name/LdapDnParser.java
(original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/name/LdapDnParser.java
Thu Nov 30 07:31:01 2006
@@ -102,7 +102,7 @@
     * @throws InvalidNameException
     *             If the DN is invalid
     */
-   public static void parseInternal( String dn, List rdns ) throws InvalidNameException
+   public static void parseInternal( String dn, List<Rdn> rdns ) throws InvalidNameException
    {
        if ( dn.length() == 0 )
        {

Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/name/Rdn.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/name/Rdn.java?view=diff&rev=480965&r1=480964&r2=480965
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/name/Rdn.java
(original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/name/Rdn.java
Thu Nov 30 07:31:01 2006
@@ -24,6 +24,7 @@
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
 import java.util.TreeSet;
 
 import javax.naming.InvalidNameException;
@@ -130,13 +131,15 @@
     * because we want the ATAVs to be sorted. An atav may contain more than one
     * value. In this case, the values are String stored in a List.
     */
-   private TreeSet atavs = null;
+   private Set<AttributeTypeAndValue> atavs = null;
 
    /**
     * We also keep a set of types, in order to use manipulations. A type is
     * connected with the atav it represents.
+    * 
+    * Note : there is no Generic available classes in commons-collection...
     */
-   private Map atavTypes = new MultiHashMap();
+   private Map<String, AttributeTypeAndValue> atavTypes = new MultiHashMap();
 
    /**
     * We keep the type for a single valued RDN, to avoid the creation of an HashMap
@@ -265,15 +268,15 @@
 
            default:
                // We must duplicate the treeSet and the hashMap
-               Iterator iter = rdn.atavs.iterator();
+               Iterator<AttributeTypeAndValue> iter = rdn.atavs.iterator();
 
-               atavs = new TreeSet();
+               atavs = new TreeSet<AttributeTypeAndValue>();
                atavTypes = new MultiHashMap();
 
                while ( iter.hasNext() )
                {
                    AttributeTypeAndValue currentAtav = ( AttributeTypeAndValue ) iter.next();
-                   atavs.add( currentAtav.clone() );
+                   atavs.add( (AttributeTypeAndValue)currentAtav.clone() );
                    atavTypes.put( currentAtav.getType(), currentAtav );
                }
        }
@@ -315,13 +318,10 @@
                // We have more than one AttributeTypeAndValue
                StringBuffer sb = new StringBuffer();
 
-               Iterator elems = atavs.iterator();
                boolean isFirst = true;
 
-               while ( elems.hasNext() )
+               for ( AttributeTypeAndValue ata:atavs )
                {
-                   AttributeTypeAndValue ata = ( AttributeTypeAndValue ) elems.next();
-
                    if ( isFirst )
                    {
                        isFirst = false;
@@ -372,7 +372,7 @@
                // We already have an atav. We have to put it in the HashMap
                // before adding a new one.
                // First, create the HashMap,
-               atavs = new TreeSet();
+               atavs = new TreeSet<AttributeTypeAndValue>();
 
                // and store the existing AttributeTypeAndValue into it.
                atavs.add( atav );
@@ -536,11 +536,11 @@
     *
     * @return an enumeration of the components of this name, each a string
     */
-   public Iterator iterator()
+   public Iterator<AttributeTypeAndValue> iterator()
    {
        if ( nbAtavs == 1 )
        {
-           return new Iterator()
+           return new Iterator<AttributeTypeAndValue>()
            {
                private boolean hasMoreElement = true;
 
@@ -551,9 +551,9 @@
                }
 
 
-               public Object next()
+               public AttributeTypeAndValue next()
                {
-                   Object obj = atav;
+                   AttributeTypeAndValue obj = atav;
                    hasMoreElement = false;
                    return obj;
                }
@@ -596,14 +596,11 @@
                default:
                    // We must duplicate the treeSet and the hashMap
                    rdn.atavTypes = new MultiHashMap();
-                   rdn.atavs = new TreeSet();
-
-                   Iterator iter = this.atavs.iterator();
+                   rdn.atavs = new TreeSet<AttributeTypeAndValue>();
 
-                   while ( iter.hasNext() )
+                   for ( AttributeTypeAndValue currentAtav:this.atavs )
                    {
-                       AttributeTypeAndValue currentAtav = ( AttributeTypeAndValue ) iter.next();
-                       rdn.atavs.add( currentAtav.clone() );
+                       rdn.atavs.add( (AttributeTypeAndValue)currentAtav.clone() );
                        rdn.atavTypes.put( currentAtav.getType(), currentAtav );
                    }
 
@@ -660,11 +657,9 @@
                default:
                    // We have more than one value. We will
                    // go through all of them.
-                   Iterator keys = atavs.iterator();
 
-                   while ( keys.hasNext() )
+                   for ( AttributeTypeAndValue current:atavs )
                    {
-                       AttributeTypeAndValue current = ( AttributeTypeAndValue ) keys.next();
                        String type = current.getType();
 
                        if ( rdn.atavTypes.containsKey( type ) )
@@ -787,7 +782,7 @@
                return atav;
 
            default:
-               return ( AttributeTypeAndValue ) atavs.first();
+               return (AttributeTypeAndValue)((TreeSet)atavs).first();
        }
    }
 
@@ -808,7 +803,7 @@
                return atav.getType();
 
            default:
-               return ( ( AttributeTypeAndValue ) atavs.first() ).getType();
+               return ( ( AttributeTypeAndValue )((TreeSet)atavs).first() ).getType();
        }
    }
 
@@ -829,7 +824,7 @@
                return atav.getValue();
 
            default:
-               return ( ( AttributeTypeAndValue ) atavs.first() ).getValue();
+               return ( ( AttributeTypeAndValue )((TreeSet)atavs).first() ).getValue();
        }
    }
 
@@ -1183,9 +1178,8 @@
            default:
                // We have more than one AttributeTypeAndValue
 
-               for ( Iterator elems = atavs.iterator();elems.hasNext(); )
+               for ( AttributeTypeAndValue ata:atavs )
                {
-                   AttributeTypeAndValue ata = ( AttributeTypeAndValue ) elems.next();
                    result = result * 37 + ata.hashCode();
                }
        }

Modified: directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/codec/search/SearchRequestTest.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/codec/search/SearchRequestTest.java?view=diff&rev=480965&r1=480964&r2=480965
==============================================================================
--- directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/codec/search/SearchRequestTest.java
(original)
+++ directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/codec/search/SearchRequestTest.java
Thu Nov 30 07:31:01 2006
@@ -4249,7 +4249,6 @@
                     0x30, (byte)0x84, 0x00, 0x00, 0x00, 0x00
             } );
 
-        String decodedPdu = StringTools.dumpBytes( stream.array() );
         stream.flip();
 
         // Allocate a BindRequest Container

Modified: directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/name/DnParserDIRSERVER_584_Test.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/name/DnParserDIRSERVER_584_Test.java?view=diff&rev=480965&r1=480964&r2=480965
==============================================================================
--- directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/name/DnParserDIRSERVER_584_Test.java
(original)
+++ directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/name/DnParserDIRSERVER_584_Test.java
Thu Nov 30 07:31:01 2006
@@ -43,7 +43,7 @@
    {
        try
        {
-           LdapDnParser.parseInternal( "ou=test=testing", new ArrayList() );
+           LdapDnParser.parseInternal( "ou=test=testing", new ArrayList<Rdn>() );
            fail( "should never get here" );
        }
        catch ( InvalidNameException e )
@@ -58,6 +58,6 @@
     */
    public void testb() throws Exception
    {
-       LdapDnParser.parseInternal( "ou=system", new ArrayList() );
+       LdapDnParser.parseInternal( "ou=system", new ArrayList<Rdn>() );
    }
 }



Mime
View raw message