hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r603318 - in /jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http: auth/ client/ client/methods/ client/protocol/ conn/ cookie/ impl/client/
Date Tue, 11 Dec 2007 18:06:53 GMT
Author: olegk
Date: Tue Dec 11 10:06:50 2007
New Revision: 603318

URL: http://svn.apache.org/viewvc?rev=603318&view=rev
Log:
More generics all over

Modified:
    jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/auth/AuthSchemeRegistry.java
    jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/client/AuthenticationHandler.java
    jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/client/methods/HttpOptions.java
    jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/client/protocol/RequestAddCookies.java
    jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/client/protocol/RequestDefaultHeaders.java
    jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/conn/SchemeRegistry.java
    jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/cookie/CookieIdentityComparator.java
    jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/cookie/CookiePathComparator.java
    jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/cookie/CookieSpecRegistry.java
    jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/client/AbstractAuthenticationHandler.java

Modified: jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/auth/AuthSchemeRegistry.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/auth/AuthSchemeRegistry.java?rev=603318&r1=603317&r2=603318&view=diff
==============================================================================
--- jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/auth/AuthSchemeRegistry.java
(original)
+++ jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/auth/AuthSchemeRegistry.java
Tue Dec 11 10:06:50 2007
@@ -49,8 +49,12 @@
  */
 public final class AuthSchemeRegistry {
 
-    private final Map<String,AuthSchemeFactory> registeredSchemes =
-        new LinkedHashMap<String,AuthSchemeFactory>();
+    private final Map<String,AuthSchemeFactory> registeredSchemes;
+    
+    public AuthSchemeRegistry() {
+        super();
+        this.registeredSchemes = new LinkedHashMap<String,AuthSchemeFactory>();
+    }
     
     /**
      * Registers a {@link AuthSchemeFactory} with  the given identifier. If a factory with
the 

Modified: jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/client/AuthenticationHandler.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/client/AuthenticationHandler.java?rev=603318&r1=603317&r2=603318&view=diff
==============================================================================
--- jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/client/AuthenticationHandler.java
(original)
+++ jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/client/AuthenticationHandler.java
Tue Dec 11 10:06:50 2007
@@ -33,6 +33,7 @@
 
 import java.util.Map;
 
+import org.apache.http.Header;
 import org.apache.http.HttpResponse;
 import org.apache.http.auth.AuthScheme;
 import org.apache.http.auth.AuthenticationException;
@@ -44,12 +45,17 @@
  */
 public interface AuthenticationHandler {
 
-    boolean isAuthenticationRequested(HttpResponse response, HttpContext context);
+    boolean isAuthenticationRequested(
+            HttpResponse response, 
+            HttpContext context);
     
-    Map getChallenges(HttpResponse response, HttpContext context) 
-        throws MalformedChallengeException;
+    Map<String, Header> getChallenges(
+            HttpResponse response, 
+            HttpContext context) throws MalformedChallengeException;
     
-    AuthScheme selectScheme(Map challenges, HttpResponse response, HttpContext context) 
-        throws AuthenticationException;
+    AuthScheme selectScheme(
+            Map<String, Header> challenges, 
+            HttpResponse response, 
+            HttpContext context) throws AuthenticationException;
     
 }

Modified: jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/client/methods/HttpOptions.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/client/methods/HttpOptions.java?rev=603318&r1=603317&r2=603318&view=diff
==============================================================================
--- jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/client/methods/HttpOptions.java
(original)
+++ jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/client/methods/HttpOptions.java
Tue Dec 11 10:06:50 2007
@@ -82,13 +82,13 @@
         return METHOD_NAME;
     }
     
-    public Set getAllowedMethods(final HttpResponse response) {
+    public Set<String> getAllowedMethods(final HttpResponse response) {
         if (response == null) {
             throw new IllegalArgumentException("HTTP response may not be null");
         }
         
         HeaderIterator it = response.headerIterator("Allow");
-        Set methods = new HashSet();
+        Set<String> methods = new HashSet<String>();
         while (it.hasNext()) {
             Header header = it.nextHeader();
             HeaderElement[] elements = header.getElements();

Modified: jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/client/protocol/RequestAddCookies.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/client/protocol/RequestAddCookies.java?rev=603318&r1=603317&r2=603318&view=diff
==============================================================================
--- jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/client/protocol/RequestAddCookies.java
(original)
+++ jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/client/protocol/RequestAddCookies.java
Tue Dec 11 10:06:50 2007
@@ -148,7 +148,7 @@
         // Get all cookies available in the HTTP state
         Cookie[] cookies = cookieStore.getCookies();
         // Find cookies matching the given origin
-        List matchedCookies = new ArrayList(cookies.length);
+        List<Cookie> matchedCookies = new ArrayList<Cookie>(cookies.length);
         for (int i = 0; i < cookies.length; i++) {
             Cookie cookie = cookies[i];
             if (cookieSpec.match(cookie, cookieOrigin)) {
@@ -159,7 +159,7 @@
             }
         }
         // Generate Cookie request headers
-        cookies = (Cookie[]) matchedCookies.toArray(new Cookie[matchedCookies.size()]);
+        cookies = matchedCookies.toArray(new Cookie[matchedCookies.size()]);
         if (cookies.length > 0) {
             Header[] headers = cookieSpec.formatCookies(cookies);
             for (int i = 0; i < headers.length; i++) {

Modified: jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/client/protocol/RequestDefaultHeaders.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/client/protocol/RequestDefaultHeaders.java?rev=603318&r1=603317&r2=603318&view=diff
==============================================================================
--- jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/client/protocol/RequestDefaultHeaders.java
(original)
+++ jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/client/protocol/RequestDefaultHeaders.java
Tue Dec 11 10:06:50 2007
@@ -63,10 +63,10 @@
             throw new IllegalArgumentException("HTTP request may not be null");
         }
         // Add default headers
-        Collection defHeaders = (Collection) request.getParams().getParameter(
+        Collection<?> defHeaders = (Collection<?>) request.getParams().getParameter(
                 ClientPNames.DEFAULT_HEADERS);
         if (defHeaders != null) {
-            for (Iterator it = defHeaders.iterator(); it.hasNext(); ) {
+            for (Iterator<?> it = defHeaders.iterator(); it.hasNext(); ) {
                 request.addHeader((Header) it.next());
             }
         }

Modified: jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/conn/SchemeRegistry.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/conn/SchemeRegistry.java?rev=603318&r1=603317&r2=603318&view=diff
==============================================================================
--- jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/conn/SchemeRegistry.java
(original)
+++ jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/conn/SchemeRegistry.java
Tue Dec 11 10:06:50 2007
@@ -166,7 +166,7 @@
      *
      * @return  List containing registered scheme names.
      */
-    public synchronized final List getSchemeNames() {
+    public synchronized final List<String> getSchemeNames() {
         return new ArrayList<String>(registeredSchemes.keySet());
     }
 

Modified: jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/cookie/CookieIdentityComparator.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/cookie/CookieIdentityComparator.java?rev=603318&r1=603317&r2=603318&view=diff
==============================================================================
--- jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/cookie/CookieIdentityComparator.java
(original)
+++ jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/cookie/CookieIdentityComparator.java
Tue Dec 11 10:06:50 2007
@@ -43,11 +43,9 @@
  * 
  * @author <a href="mailto:oleg at ural.ru">Oleg Kalnichevski</a>
  */
-public class CookieIdentityComparator implements Comparator {
+public class CookieIdentityComparator implements Comparator<Cookie> {
 
-    public int compare(final Object o1, final Object o2) {
-        Cookie c1 = (Cookie) o1;
-        Cookie c2 = (Cookie) o2;
+    public int compare(final Cookie c1, final Cookie c2) {
         int res = c1.getName().compareTo(c2.getName());
         if (res == 0) {
             // do not differentiate empty and null domains 

Modified: jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/cookie/CookiePathComparator.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/cookie/CookiePathComparator.java?rev=603318&r1=603317&r2=603318&view=diff
==============================================================================
--- jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/cookie/CookiePathComparator.java
(original)
+++ jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/cookie/CookiePathComparator.java
Tue Dec 11 10:06:50 2007
@@ -47,7 +47,7 @@
  * 
  * @author <a href="mailto:oleg at ural.ru">Oleg Kalnichevski</a>
  */
-public class CookiePathComparator implements Comparator {
+public class CookiePathComparator implements Comparator<Cookie> {
 
     private String normalizePath(final Cookie cookie) {
         String path = cookie.getPath();
@@ -60,9 +60,7 @@
         return path;
     }
     
-    public int compare(final Object o1, final Object o2) {
-        Cookie c1 = (Cookie) o1;
-        Cookie c2 = (Cookie) o2;
+    public int compare(final Cookie c1, final Cookie c2) {
         String path1 = normalizePath(c1);
         String path2 = normalizePath(c2);
         if (path1.equals(path2)) {

Modified: jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/cookie/CookieSpecRegistry.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/cookie/CookieSpecRegistry.java?rev=603318&r1=603317&r2=603318&view=diff
==============================================================================
--- jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/cookie/CookieSpecRegistry.java
(original)
+++ jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/cookie/CookieSpecRegistry.java
Tue Dec 11 10:06:50 2007
@@ -138,7 +138,7 @@
      * 
      * @return list of registered cookie spec names
      */
-    public synchronized List getSpecNames(){
+    public synchronized List<String> getSpecNames(){
         return new ArrayList<String>(registeredSpecs.keySet()); 
     }
     

Modified: jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/client/AbstractAuthenticationHandler.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/client/AbstractAuthenticationHandler.java?rev=603318&r1=603317&r2=603318&view=diff
==============================================================================
--- jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/client/AbstractAuthenticationHandler.java
(original)
+++ jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/client/AbstractAuthenticationHandler.java
Tue Dec 11 10:06:50 2007
@@ -59,7 +59,7 @@
 
     private static final Log LOG = LogFactory.getLog(AbstractAuthenticationHandler.class);
     
-    private static List DEFAULT_SCHEME_PRIORITY = Arrays.asList(new String[] {
+    private static List<String> DEFAULT_SCHEME_PRIORITY = Arrays.asList(new String[]
{
             "digest",
             "basic"
     });
@@ -68,10 +68,10 @@
         super();
     }
     
-    protected Map parseChallenges(
+    protected Map<String, Header> parseChallenges(
             final Header[] headers) throws MalformedChallengeException {
         
-        Map map = new HashMap(headers.length);
+        Map<String, Header> map = new HashMap<String, Header>(headers.length);
         for (int i = 0; i < headers.length; i++) {
             Header header = headers[i];
             CharArrayBuffer buffer;
@@ -102,12 +102,12 @@
         return map;
     }
     
-    protected List getAuthPreferences() {
+    protected List<String> getAuthPreferences() {
         return DEFAULT_SCHEME_PRIORITY;
     }
     
     public AuthScheme selectScheme(
-            final Map challenges, 
+            final Map<String, Header> challenges, 
             final HttpResponse response,
             final HttpContext context) throws AuthenticationException {
         
@@ -117,15 +117,15 @@
             throw new IllegalStateException("AuthScheme registry not set in HTTP context");
         }
         
-        List authPrefs = getAuthPreferences();
+        List<String> authPrefs = getAuthPreferences();
         if (LOG.isDebugEnabled()) {
             LOG.debug("Supported authentication schemes in the order of preference: " 
                 + authPrefs);
         }
 
         AuthScheme authScheme = null;
-        for (Iterator it = authPrefs.iterator(); it.hasNext(); ) {
-            String id = (String) it.next();
+        for (Iterator<String> it = authPrefs.iterator(); it.hasNext(); ) {
+            String id = it.next();
             Header challenge = (Header) challenges.get(id.toLowerCase()); 
             if (challenge != null) {
                 if (LOG.isDebugEnabled()) {



Mime
View raw message