directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r480662 - in /directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap: codec/util/LdapURL.java exception/LdapReferralException.java
Date Wed, 29 Nov 2006 18:02:02 GMT
Author: elecharny
Date: Wed Nov 29 10:02:00 2006
New Revision: 480662

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

Modified:
    directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/util/LdapURL.java
    directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/exception/LdapReferralException.java

Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/util/LdapURL.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/util/LdapURL.java?view=diff&rev=480662&r1=480661&r2=480662
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/util/LdapURL.java
(original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/util/LdapURL.java
Wed Nov 29 10:02:00 2006
@@ -34,7 +34,9 @@
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.HashSet;
-import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
 
 import javax.naming.InvalidNameException;
 import javax.naming.directory.SearchControls;
@@ -89,7 +91,7 @@
     private LdapDN dn;
 
     /** The attributes */
-    private ArrayList attributes;
+    private List<String> attributes;
 
     /** The scope */
     private int scope;
@@ -98,10 +100,10 @@
     private String filter;
 
     /** The extensions */
-    private HashMap extensions;
+    private Map<String, String> extensions;
 
     /** The criticals extensions */
-    private HashMap criticalExtensions;
+    private Map<String, String> criticalExtensions;
 
     /** Stores the LdapURL as a String */
     private String string;
@@ -121,11 +123,11 @@
         host = null;
         port = -1;
         dn = null;
-        attributes = new ArrayList();
+        attributes = new ArrayList<String>();
         scope = SearchControls.OBJECT_SCOPE;
         filter = null;
-        extensions = new HashMap();
-        criticalExtensions = new HashMap();
+        extensions = new HashMap<String, String>();
+        criticalExtensions = new HashMap<String, String>();
     }
 
     /**
@@ -138,11 +140,11 @@
         host = null;
         port = -1;
         dn = null;
-        attributes = new ArrayList();
+        attributes = new ArrayList<String>();
         scope = SearchControls.OBJECT_SCOPE;
         filter = null;
-        extensions = new HashMap();
-        criticalExtensions = new HashMap();
+        extensions = new HashMap<String, String>();
+        criticalExtensions = new HashMap<String, String>();
 
         if ( ( chars == null ) || ( chars.length == 0 ) )
         {
@@ -791,7 +793,7 @@
 
         int start = pos;
         int end = pos;
-        HashSet hAttributes = new HashSet();
+        Set<String> hAttributes = new HashSet<String>();
         boolean hadComma = false;
 
         try
@@ -1220,15 +1222,21 @@
             {
                 sb.append( '?' );
 
-                for ( int i = 0; i < attributes.size(); i++ )
+                boolean isFirst = true;
+                
+                for ( String attribute:attributes )
                 {
 
-                    if ( i > 0 )
+                    if ( isFirst )
+                    {
+                        isFirst = false;
+                    }
+                    else
                     {
                         sb.append( ',' );
                     }
 
-                    sb.append( urlEncode( ( String ) attributes.get( i ), false ) );
+                    sb.append( urlEncode( attribute, false ) );
                 }
             }
 
@@ -1271,10 +1279,7 @@
 
                         if ( extensions.size() != 0 )
                         {
-
-                            Iterator keys = extensions.keySet().iterator();
-
-                            while ( keys.hasNext() )
+                            for ( String key:extensions.keySet() )
                             {
 
                                 if ( isFirst == false )
@@ -1286,10 +1291,8 @@
                                     isFirst = false;
                                 }
 
-                                String key = ( String ) keys.next();
-
                                 sb.append( urlEncode( key, false ) ).append( '=' ).append(
-                                    urlEncode( ( String ) extensions.get( key ), true ) );
+                                    urlEncode( extensions.get( key ), true ) );
                             }
                         }
 
@@ -1297,10 +1300,7 @@
 
                         if ( criticalExtensions.size() != 0 )
                         {
-
-                            Iterator keys = criticalExtensions.keySet().iterator();
-
-                            while ( keys.hasNext() )
+                            for ( String key:criticalExtensions.keySet() )
                             {
 
                                 if ( isFirst == false )
@@ -1313,10 +1313,8 @@
                                     isFirst = false;
                                 }
 
-                                String key = ( String ) keys.next();
-
                                 sb.append( urlEncode( key, false ) ).append( '=' ).append(
-                                    urlEncode( ( String ) criticalExtensions.get( key ),
true ) );
+                                    urlEncode( criticalExtensions.get( key ), true ) );
                             }
                         }
                     }
@@ -1335,7 +1333,7 @@
     /**
      * @return Returns the attributes.
      */
-    public ArrayList getAttributes()
+    public List<String> getAttributes()
     {
         return attributes;
     }
@@ -1344,7 +1342,7 @@
     /**
      * @return Returns the criticalExtensions.
      */
-    public HashMap getCriticalExtensions()
+    public Map<String, String> getCriticalExtensions()
     {
         return criticalExtensions;
     }
@@ -1362,7 +1360,7 @@
     /**
      * @return Returns the extensions.
      */
-    public HashMap getExtensions()
+    public Map<String, String> getExtensions()
     {
         return extensions;
     }

Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/exception/LdapReferralException.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/exception/LdapReferralException.java?view=diff&rev=480662&r1=480661&r2=480662
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/exception/LdapReferralException.java
(original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/exception/LdapReferralException.java
Wed Nov 29 10:02:00 2006
@@ -49,7 +49,7 @@
 {
     static final long serialVersionUID = -8611970137960601723L;
 
-    private final List refs;
+    private final List<String> refs;
 
     private int index = 0;
 
@@ -57,19 +57,19 @@
     /**
      * @see ReferralException#ReferralException()
      */
-    public LdapReferralException(Collection refs)
+    public LdapReferralException( Collection<String> refs )
     {
-        this.refs = new ArrayList( refs );
+        this.refs = new ArrayList<String>( refs );
     }
 
 
     /**
      * @see ReferralException#ReferralException(java.lang.String)
      */
-    public LdapReferralException(Collection refs, String explanation)
+    public LdapReferralException( Collection<String> refs, String explanation )
     {
         super( explanation );
-        this.refs = new ArrayList( refs );
+        this.refs = new ArrayList<String>( refs );
     }
 
 
@@ -84,7 +84,7 @@
     }
 
 
-    public Object getReferralInfo()
+    public String getReferralInfo()
     {
         return refs.get( index );
     }



Mime
View raw message