directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r473090 - in /directory/branches/apacheds-schema/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec: LdapMessage.java LdapResult.java TwixTransformer.java
Date Thu, 09 Nov 2006 22:10:46 GMT
Author: elecharny
Date: Thu Nov  9 14:10:45 2006
New Revision: 473090

URL: http://svn.apache.org/viewvc?view=rev&rev=473090
Log:
Fixed warnings by using generics

Modified:
    directory/branches/apacheds-schema/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapMessage.java
    directory/branches/apacheds-schema/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapResult.java
    directory/branches/apacheds-schema/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/TwixTransformer.java

Modified: directory/branches/apacheds-schema/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapMessage.java
URL: http://svn.apache.org/viewvc/directory/branches/apacheds-schema/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapMessage.java?view=diff&rev=473090&r1=473089&r2=473090
==============================================================================
--- directory/branches/apacheds-schema/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapMessage.java
(original)
+++ directory/branches/apacheds-schema/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapMessage.java
Thu Nov  9 14:10:45 2006
@@ -50,7 +50,6 @@
 import java.nio.ByteBuffer;
 
 import java.util.ArrayList;
-import java.util.Iterator;
 
 
 /**
@@ -71,7 +70,7 @@
     private Asn1Object protocolOp;
 
     /** The controls */
-    private ArrayList controls;
+    private ArrayList<Control> controls;
 
     /** The current control */
     private transient Control currentControl;
@@ -109,7 +108,7 @@
      */
     public Control getControls( int i )
     {
-        return ( Control ) controls.get( i );
+        return controls.get( i );
     }
 
 
@@ -118,7 +117,7 @@
      * 
      * @return The Control Objects
      */
-    public ArrayList getControls()
+    public ArrayList<Control> getControls()
     {
         return controls;
     }
@@ -143,10 +142,12 @@
     public void addControl( Control control )
     {
         currentControl = control;
+        
         if ( this.controls == null )
         {
-            this.controls = new ArrayList();
+            this.controls = new ArrayList<Control>();
         }
+        
         this.controls.add( control );
     }
 
@@ -156,7 +157,7 @@
      */
     public void initControls()
     {
-        controls = new ArrayList();
+        controls = new ArrayList<Control>();
     }
 
 
@@ -560,12 +561,10 @@
             // + Length(L3) + L3
             controlsSequenceLength = 0;
 
-            Iterator controlIterator = controls.iterator();
-
             // We may have more than one control. ControlsLength is L4.
-            while ( controlIterator.hasNext() )
+            for ( Control control:controls )
             {
-                controlsSequenceLength += ( ( Control ) controlIterator.next() ).computeLength();
+                controlsSequenceLength += control.computeLength();
             }
 
             // Computes the controls length
@@ -638,11 +637,9 @@
             bb.put( TLV.getBytes( controlsLength ) );
 
             // Encode each control
-            Iterator controlIterator = controls.iterator();
-
-            while ( controlIterator.hasNext() )
+            for ( Control control:controls )
             {
-                ( ( Control ) controlIterator.next() ).encode( bb );
+                control.encode( bb );
             }
         }
 
@@ -665,9 +662,9 @@
 
         if ( controls != null )
         {
-            for ( int i = 0; i < controls.size(); i++ )
+            for ( Control control:controls )
             {
-                sb.append( ( ( Control ) controls.get( i ) ).toString() );
+                sb.append( control );
             }
         }
 

Modified: directory/branches/apacheds-schema/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapResult.java
URL: http://svn.apache.org/viewvc/directory/branches/apacheds-schema/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapResult.java?view=diff&rev=473090&r1=473089&r2=473090
==============================================================================
--- directory/branches/apacheds-schema/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapResult.java
(original)
+++ directory/branches/apacheds-schema/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapResult.java
Thu Nov  9 14:10:45 2006
@@ -33,7 +33,6 @@
 import java.nio.BufferOverflowException;
 import java.nio.ByteBuffer;
 import java.util.ArrayList;
-import java.util.Iterator;
 
 
 /**
@@ -112,7 +111,7 @@
     private transient byte[] errorMessageBytes;
 
     /** The referrals, if any. This is an optional element */
-    private ArrayList referrals;
+    private ArrayList<LdapURL> referrals;
 
     /** The inner size of the referrals sequence */
     private transient int referralsLength;
@@ -137,7 +136,7 @@
      */
     public void initReferrals()
     {
-        referrals = new ArrayList();
+        referrals = new ArrayList<LdapURL>();
     }
     
     /**
@@ -189,7 +188,7 @@
      * 
      * @return Returns the referrals.
      */
-    public ArrayList getReferrals()
+    public ArrayList<LdapURL> getReferrals()
     {
         return referrals;
     }
@@ -276,15 +275,11 @@
 
         if ( ( referrals != null ) && ( referrals.size() != 0 ) )
         {
-            Iterator referralIterator = referrals.iterator();
-
             referralsLength = 0;
 
             // Each referral
-            while ( referralIterator.hasNext() )
+            for ( LdapURL referral:referrals )
             {
-                LdapURL referral = ( LdapURL ) referralIterator.next();
-
                 referralsLength += 1 + TLV.getNbBytes( referral.getNbBytes() ) + referral.getNbBytes();
             }
 
@@ -336,12 +331,8 @@
             buffer.put( TLV.getBytes( referralsLength ) );
 
             // Each referral
-            Iterator referralIterator = referrals.iterator();
-
-            while ( referralIterator.hasNext() )
+            for ( LdapURL referral:referrals )
             {
-                LdapURL referral = ( LdapURL ) referralIterator.next();
-
                 // Ecode the current referral
                 Value.encode( buffer, referral.getBytes() );
             }
@@ -609,14 +600,12 @@
         if ( ( referrals != null ) && ( referrals.size() != 0 ) )
         {
             sb.append( "            Referrals :\n" );
+            int i = 0;
 
-            for ( int i = 0; i < referrals.size(); i++ )
+            for ( LdapURL referral:referrals )
             {
-
-                LdapURL referral = ( LdapURL ) referrals.get( i );
-
-                sb.append( "                Referral[" ).append( i ).append( "] :" ).append(
referral == null ? "" : referral.toString() )
-                    .append( '\n' );
+                sb.append( "                Referral[" ).append( i++ ).append( "] :" )
+                    .append( referral == null ? "" : referral.toString() ).append( '\n' );
             }
         }
 

Modified: directory/branches/apacheds-schema/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/TwixTransformer.java
URL: http://svn.apache.org/viewvc/directory/branches/apacheds-schema/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/TwixTransformer.java?view=diff&rev=473090&r1=473089&r2=473090
==============================================================================
--- directory/branches/apacheds-schema/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/TwixTransformer.java
(original)
+++ directory/branches/apacheds-schema/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/TwixTransformer.java
Thu Nov  9 14:10:45 2006
@@ -510,7 +510,7 @@
                     SubstringFilter filter = ( SubstringFilter ) twixFilter;
                     String initialString = null;
                     String finalString = null;
-                    ArrayList anyString = null;
+                    ArrayList<String> anyString = null;
 
                     if ( filter.getInitialSubstrings() != null )
                     {
@@ -524,12 +524,11 @@
 
                     if ( filter.getAnySubstrings() != null )
                     {
-                        Iterator iter = filter.getAnySubstrings().iterator();
-                        anyString = new ArrayList();
+                        anyString = new ArrayList<String>();
 
-                        while ( iter.hasNext() )
+                        for ( String anySubstring:filter.getAnySubstrings() )
                         {
-                            anyString.add( iter.next().toString() );
+                            anyString.add( anySubstring );
                         }
                     }
 



Mime
View raw message