You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ivy-commits@incubator.apache.org by xa...@apache.org on 2007/06/26 20:37:51 UTC

svn commit: r550935 - in /incubator/ivy/core/trunk/src/java/org/apache/ivy/util: extendable/ filter/ url/

Author: xavier
Date: Tue Jun 26 13:37:50 2007
New Revision: 550935

URL: http://svn.apache.org/viewvc?view=rev&rev=550935
Log:
clean code

Modified:
    incubator/ivy/core/trunk/src/java/org/apache/ivy/util/extendable/ExtendableItemHelper.java
    incubator/ivy/core/trunk/src/java/org/apache/ivy/util/extendable/UnmodifiableExtendableItem.java
    incubator/ivy/core/trunk/src/java/org/apache/ivy/util/filter/AndFilter.java
    incubator/ivy/core/trunk/src/java/org/apache/ivy/util/filter/ArtifactTypeFilter.java
    incubator/ivy/core/trunk/src/java/org/apache/ivy/util/filter/FilterHelper.java
    incubator/ivy/core/trunk/src/java/org/apache/ivy/util/filter/NoFilter.java
    incubator/ivy/core/trunk/src/java/org/apache/ivy/util/filter/NotFilter.java
    incubator/ivy/core/trunk/src/java/org/apache/ivy/util/filter/OrFilter.java
    incubator/ivy/core/trunk/src/java/org/apache/ivy/util/url/ApacheURLLister.java
    incubator/ivy/core/trunk/src/java/org/apache/ivy/util/url/BasicURLHandler.java
    incubator/ivy/core/trunk/src/java/org/apache/ivy/util/url/CredentialsStore.java
    incubator/ivy/core/trunk/src/java/org/apache/ivy/util/url/HttpClientHandler.java
    incubator/ivy/core/trunk/src/java/org/apache/ivy/util/url/IvyAuthenticator.java
    incubator/ivy/core/trunk/src/java/org/apache/ivy/util/url/URLHandler.java
    incubator/ivy/core/trunk/src/java/org/apache/ivy/util/url/URLHandlerDispatcher.java
    incubator/ivy/core/trunk/src/java/org/apache/ivy/util/url/URLHandlerRegistry.java

Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/util/extendable/ExtendableItemHelper.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/util/extendable/ExtendableItemHelper.java?view=diff&rev=550935&r1=550934&r2=550935
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/util/extendable/ExtendableItemHelper.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/util/extendable/ExtendableItemHelper.java Tue Jun 26 13:37:50 2007
@@ -25,7 +25,9 @@
 
 import org.xml.sax.Attributes;
 
-public class ExtendableItemHelper {
+public final class ExtendableItemHelper {
+    private ExtendableItemHelper() {
+    }
 
     public static Map getExtraAttributes(Attributes attributes, String prefix) {
         Map ret = new HashMap();

Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/util/extendable/UnmodifiableExtendableItem.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/util/extendable/UnmodifiableExtendableItem.java?view=diff&rev=550935&r1=550934&r2=550935
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/util/extendable/UnmodifiableExtendableItem.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/util/extendable/UnmodifiableExtendableItem.java Tue Jun 26 13:37:50 2007
@@ -22,39 +22,39 @@
 import java.util.Map;
 
 public class UnmodifiableExtendableItem implements ExtendableItem {
-    private Map _attributes = new HashMap();
+    private Map attributes = new HashMap();
 
-    private Map _unmodifiableAttributesView = Collections.unmodifiableMap(_attributes);
+    private Map unmodifiableAttributesView = Collections.unmodifiableMap(attributes);
 
-    private Map _stdAttributes = new HashMap();
+    private Map stdAttributes = new HashMap();
 
-    private Map _unmodifiableStdAttributesView = Collections.unmodifiableMap(_stdAttributes);
+    private Map unmodifiableStdAttributesView = Collections.unmodifiableMap(stdAttributes);
 
-    private Map _extraAttributes = new HashMap();
+    private Map extraAttributes = new HashMap();
 
-    private Map _unmodifiableExtraAttributesView = Collections.unmodifiableMap(_extraAttributes);
+    private Map unmodifiableExtraAttributesView = Collections.unmodifiableMap(extraAttributes);
 
     public UnmodifiableExtendableItem(Map stdAttributes, Map extraAttributes) {
         if (stdAttributes != null) {
-            _attributes.putAll(stdAttributes);
-            _stdAttributes.putAll(stdAttributes);
+            attributes.putAll(stdAttributes);
+            stdAttributes.putAll(stdAttributes);
         }
         if (extraAttributes != null) {
-            _attributes.putAll(extraAttributes);
-            _extraAttributes.putAll(extraAttributes);
+            attributes.putAll(extraAttributes);
+            extraAttributes.putAll(extraAttributes);
         }
     }
 
     public String getAttribute(String attName) {
-        return (String) _attributes.get(attName);
+        return (String) attributes.get(attName);
     }
 
     public String getExtraAttribute(String attName) {
-        return (String) _extraAttributes.get(attName);
+        return (String) extraAttributes.get(attName);
     }
 
     public String getStandardAttribute(String attName) {
-        return (String) _stdAttributes.get(attName);
+        return (String) stdAttributes.get(attName);
     }
 
     protected void setExtraAttribute(String attName, String attValue) {
@@ -67,23 +67,23 @@
 
     protected void setAttribute(String attName, String attValue, boolean extra) {
         if (extra) {
-            _extraAttributes.put(attName, attValue);
+            extraAttributes.put(attName, attValue);
         } else {
-            _stdAttributes.put(attName, attValue);
+            stdAttributes.put(attName, attValue);
         }
-        _attributes.put(attName, attValue);
+        attributes.put(attName, attValue);
     }
 
     public Map getAttributes() {
-        return _unmodifiableAttributesView;
+        return unmodifiableAttributesView;
     }
 
     public Map getStandardAttributes() {
-        return _unmodifiableStdAttributesView;
+        return unmodifiableStdAttributesView;
     }
 
     public Map getExtraAttributes() {
-        return _unmodifiableExtraAttributesView;
+        return unmodifiableExtraAttributesView;
     }
 
 }

Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/util/filter/AndFilter.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/util/filter/AndFilter.java?view=diff&rev=550935&r1=550934&r2=550935
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/util/filter/AndFilter.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/util/filter/AndFilter.java Tue Jun 26 13:37:50 2007
@@ -18,24 +18,24 @@
 package org.apache.ivy.util.filter;
 
 public class AndFilter implements Filter {
-    private Filter _op1;
+    private Filter op1;
 
-    private Filter _op2;
+    private Filter op2;
 
     public AndFilter(Filter op1, Filter op2) {
-        _op1 = op1;
-        _op2 = op2;
+        this.op1 = op1;
+        this.op2 = op2;
     }
 
     public Filter getOp1() {
-        return _op1;
+        return op1;
     }
 
     public Filter getOp2() {
-        return _op2;
+        return op2;
     }
 
     public boolean accept(Object o) {
-        return _op1.accept(o) && _op2.accept(o);
+        return op1.accept(o) && op2.accept(o);
     }
 }

Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/util/filter/ArtifactTypeFilter.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/util/filter/ArtifactTypeFilter.java?view=diff&rev=550935&r1=550934&r2=550935
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/util/filter/ArtifactTypeFilter.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/util/filter/ArtifactTypeFilter.java Tue Jun 26 13:37:50 2007
@@ -23,10 +23,10 @@
 import org.apache.ivy.core.module.descriptor.Artifact;
 
 public class ArtifactTypeFilter implements Filter {
-    private Collection _acceptedTypes;
+    private Collection acceptedTypes;
 
     public ArtifactTypeFilter(Collection acceptedTypes) {
-        _acceptedTypes = new ArrayList(acceptedTypes);
+        this.acceptedTypes = new ArrayList(acceptedTypes);
     }
 
     public boolean accept(Object o) {
@@ -34,6 +34,6 @@
             return false;
         }
         Artifact art = (Artifact) o;
-        return _acceptedTypes.contains(art.getType());
+        return acceptedTypes.contains(art.getType());
     }
 }

Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/util/filter/FilterHelper.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/util/filter/FilterHelper.java?view=diff&rev=550935&r1=550934&r2=550935
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/util/filter/FilterHelper.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/util/filter/FilterHelper.java Tue Jun 26 13:37:50 2007
@@ -22,8 +22,11 @@
 import java.util.Iterator;
 import java.util.List;
 
-public class FilterHelper {
-    public static Filter NO_FILTER = NoFilter.INSTANCE;
+public final class FilterHelper {
+    private FilterHelper() {
+    }
+    
+    public static final Filter NO_FILTER = NoFilter.INSTANCE;
 
     public static Filter getArtifactTypeFilter(String types) {
         if (types == null || types.trim().equals("*")) {

Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/util/filter/NoFilter.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/util/filter/NoFilter.java?view=diff&rev=550935&r1=550934&r2=550935
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/util/filter/NoFilter.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/util/filter/NoFilter.java Tue Jun 26 13:37:50 2007
@@ -17,7 +17,7 @@
  */
 package org.apache.ivy.util.filter;
 
-public class NoFilter implements Filter {
+public final class NoFilter implements Filter {
     public static final Filter INSTANCE = new NoFilter();
 
     private NoFilter() {

Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/util/filter/NotFilter.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/util/filter/NotFilter.java?view=diff&rev=550935&r1=550934&r2=550935
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/util/filter/NotFilter.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/util/filter/NotFilter.java Tue Jun 26 13:37:50 2007
@@ -18,17 +18,17 @@
 package org.apache.ivy.util.filter;
 
 public class NotFilter implements Filter {
-    private Filter _op;
+    private Filter op;
 
     public NotFilter(Filter op) {
-        _op = op;
+        this.op = op;
     }
 
     public Filter getOp() {
-        return _op;
+        return op;
     }
 
     public boolean accept(Object o) {
-        return !_op.accept(o);
+        return !op.accept(o);
     }
 }

Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/util/filter/OrFilter.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/util/filter/OrFilter.java?view=diff&rev=550935&r1=550934&r2=550935
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/util/filter/OrFilter.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/util/filter/OrFilter.java Tue Jun 26 13:37:50 2007
@@ -18,24 +18,24 @@
 package org.apache.ivy.util.filter;
 
 public class OrFilter implements Filter {
-    private Filter _op1;
+    private Filter op1;
 
-    private Filter _op2;
+    private Filter op2;
 
     public OrFilter(Filter op1, Filter op2) {
-        _op1 = op1;
-        _op2 = op2;
+        this.op1 = op1;
+        this.op2 = op2;
     }
 
     public Filter getOp1() {
-        return _op1;
+        return op1;
     }
 
     public Filter getOp2() {
-        return _op2;
+        return op2;
     }
 
     public boolean accept(Object o) {
-        return _op1.accept(o) || _op2.accept(o);
+        return op1.accept(o) || op2.accept(o);
     }
 }

Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/util/url/ApacheURLLister.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/util/url/ApacheURLLister.java?view=diff&rev=550935&r1=550934&r2=550935
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/util/url/ApacheURLLister.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/util/url/ApacheURLLister.java Tue Jun 26 13:37:50 2007
@@ -138,7 +138,8 @@
             int dotIndex = text.indexOf('.');
 
             if (((dotIndex != -1) && !href.startsWith(text.substring(0, dotIndex)))
-                    || ((dotIndex == -1) && !href.toLowerCase(Locale.US).equals(text.toLowerCase(Locale.US)))) {
+                    || ((dotIndex == -1) 
+                            && !href.toLowerCase(Locale.US).equals(text.toLowerCase(Locale.US)))) {
                 // the href and the text do not "match"
                 continue;
             }

Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/util/url/BasicURLHandler.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/util/url/BasicURLHandler.java?view=diff&rev=550935&r1=550934&r2=550935
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/util/url/BasicURLHandler.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/util/url/BasicURLHandler.java Tue Jun 26 13:37:50 2007
@@ -36,7 +36,9 @@
  */
 public class BasicURLHandler extends AbstractURLHandler {
 
-    private static interface HttpStatus {
+    private static final int BUFFER_SIZE = 4096;
+
+    private static class HttpStatus {
         static final int SC_OK = 200;
 
         static final int SC_PROXY_AUTHENTICATION_REQUIRED = 407;
@@ -83,8 +85,8 @@
             }
         } catch (UnknownHostException e) {
             Message.warn("Host " + e.getMessage() + " not found. url=" + url);
-            Message
-                    .info("You probably access the destination server through a proxy server that is not well configured.");
+            Message.info("You probably access the destination server through "
+                + "a proxy server that is not well configured.");
         } catch (IOException e) {
             Message.error("Server access Error: " + e.getMessage() + " url=" + url);
         } finally {
@@ -101,7 +103,7 @@
             inStream = conn.getInputStream();
             ByteArrayOutputStream outStream = new ByteArrayOutputStream();
 
-            byte[] buffer = new byte[4096];
+            byte[] buffer = new byte[BUFFER_SIZE];
             int len;
             while ((len = inStream.read(buffer)) > 0) {
                 outStream.write(buffer, 0, len);
@@ -146,6 +148,7 @@
             try {
                 con.getInputStream().close();
             } catch (IOException e) {
+                // ignored
             }
         }
     }

Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/util/url/CredentialsStore.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/util/url/CredentialsStore.java?view=diff&rev=550935&r1=550934&r2=550935
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/util/url/CredentialsStore.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/util/url/CredentialsStore.java Tue Jun 26 13:37:50 2007
@@ -26,13 +26,13 @@
 /**
  * 
  */
-public class CredentialsStore {
+public final class CredentialsStore {
     /**
      * A Map of Credentials objects keyed by the 'key' of the Credentials.
      */
-    private final static Map keyring = new HashMap();
+    private static final Map KEYRING = new HashMap();
 
-    public final static CredentialsStore INSTANCE = new CredentialsStore();
+    public static final CredentialsStore INSTANCE = new CredentialsStore();
 
     private CredentialsStore() {
     }
@@ -43,14 +43,14 @@
         }
         Credentials c = new Credentials(realm, host, userName, passwd);
         Message.debug("credentials added: " + c);
-        keyring.put(c.getKey(), c);
+        KEYRING.put(c.getKey(), c);
         // add also with host only, to be able to find credential with host only
         // (useful for httpclient especially)
-        keyring.put(c.getHost(), c);
+        KEYRING.put(c.getHost(), c);
     }
 
     public Credentials getCredentials(String realm, String host) {
-        return (Credentials) keyring.get(Credentials.buildKey(realm, host));
+        return (Credentials) KEYRING.get(Credentials.buildKey(realm, host));
     }
 
 }

Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/util/url/HttpClientHandler.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/util/url/HttpClientHandler.java?view=diff&rev=550935&r1=550934&r2=550935
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/util/url/HttpClientHandler.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/util/url/HttpClientHandler.java Tue Jun 26 13:37:50 2007
@@ -50,35 +50,35 @@
             "EEE, d MMM yyyy HH:mm:ss z", Locale.US);
 
     // proxy configuration: obtain from system properties
-    private int _proxyPort;
+    private int proxyPort;
 
-    private String _proxyRealm = null;
+    private String proxyRealm = null;
 
-    private String _proxyHost = null;
+    private String proxyHost = null;
 
-    private String _proxyUserName = null;
+    private String proxyUserName = null;
 
-    private String _proxyPasswd = null;
+    private String proxyPasswd = null;
 
-    private HttpClientHelper _httpClientHelper;
+    private HttpClientHelper httpClientHelper;
 
     public HttpClientHandler() {
         configureProxy();
     }
 
     private void configureProxy() {
-        _proxyRealm = null;
+        proxyRealm = null;
         // no equivalent for realm in jdk proxy support ?
-        _proxyHost = System.getProperty("http.proxyHost");
+        proxyHost = System.getProperty("http.proxyHost");
         // TODO constant is better ...
         if (useProxy()) {
-            _proxyPort = Integer.parseInt(System.getProperty("http.proxyPort", "80"));
-            _proxyUserName = System.getProperty("http.proxyUser");
-            _proxyPasswd = System.getProperty("http.proxyPassword");
+            proxyPort = Integer.parseInt(System.getProperty("http.proxyPort", "80"));
+            proxyUserName = System.getProperty("http.proxyUser");
+            proxyPasswd = System.getProperty("http.proxyPassword");
             // It seems there is no equivalent in HttpClient for
             // 'http.nonProxyHosts' property
-            Message.verbose("proxy configured: host=" + _proxyHost + " port=" + _proxyPort
-                    + " user=" + _proxyUserName);
+            Message.verbose("proxy configured: host=" + proxyHost + " port=" + proxyPort
+                    + " user=" + proxyUserName);
         } else {
             Message.verbose("no proxy configured");
         }
@@ -122,8 +122,8 @@
                     + e.getReason() + " url=" + url);
         } catch (UnknownHostException e) {
             Message.warn("Host " + e.getMessage() + " not found. url=" + url);
-            Message
-                    .info("You probably access the destination server through a proxy server that is not well configured.");
+            Message.info("You probably access the destination server through "
+                + "a proxy server that is not well configured.");
         } catch (IOException e) {
             Message.error("HttpClientHandler: " + e.getMessage() + " url=" + url);
         } finally {
@@ -141,6 +141,7 @@
             try {
                 return LAST_MODIFIED_FORMAT.parse(lastModified).getTime();
             } catch (ParseException e) {
+                // ignored
             }
             return System.currentTimeMillis();
         } else {
@@ -153,24 +154,25 @@
     }
 
     private HttpClientHelper getHttpClientHelper() {
-        if (_httpClientHelper == null) {
+        if (httpClientHelper == null) {
             // use commons httpclient 3.0 if available
             try {
                 HttpMethodBase.class.getMethod("getResponseContentLength", new Class[0]);
-                _httpClientHelper = new HttpClientHelper3x();
+                httpClientHelper = new HttpClientHelper3x();
                 Message.verbose("using commons httpclient 3.x helper");
             } catch (SecurityException e) {
-                Message
-                        .verbose("unable to get access to getResponseContentLength of commons-httpclient HeadMethod. Please use commons-httpclient 3.0 or use ivy with sufficient security permissions.");
+                Message.verbose("unable to get access to getResponseContentLength of "
+                    + "commons-httpclient HeadMethod. Please use commons-httpclient 3.0 or "
+                    + "use ivy with sufficient security permissions.");
                 Message.verbose("exception: " + e.getMessage());
-                _httpClientHelper = new HttpClientHelper2x();
+                httpClientHelper = new HttpClientHelper2x();
                 Message.verbose("using commons httpclient 2.x helper");
             } catch (NoSuchMethodException e) {
-                _httpClientHelper = new HttpClientHelper2x();
+                httpClientHelper = new HttpClientHelper2x();
                 Message.verbose("using commons httpclient 2.x helper");
             }
         }
-        return _httpClientHelper;
+        return httpClientHelper;
     }
 
     public int getHttpClientMajorVersion() {
@@ -178,7 +180,7 @@
         return helper.getHttpClientMajorVersion();
     }
 
-    private GetMethod doGet(URL url) throws IOException, HttpException {
+    private GetMethod doGet(URL url) throws IOException {
         HttpClient client = getClient(url);
 
         GetMethod get = new GetMethod(url.toExternalForm());
@@ -187,7 +189,7 @@
         return get;
     }
 
-    private HeadMethod doHead(URL url, int timeout) throws IOException, HttpException {
+    private HeadMethod doHead(URL url, int timeout) throws IOException {
         HttpClient client = getClient(url);
         client.setTimeout(timeout);
 
@@ -207,10 +209,10 @@
         client.getParams().setParameter(AuthPolicy.AUTH_SCHEME_PRIORITY, authPrefs);
 
         if (useProxy()) {
-            client.getHostConfiguration().setProxy(_proxyHost, _proxyPort);
+            client.getHostConfiguration().setProxy(proxyHost, proxyPort);
             if (useProxyAuthentication()) {
-                client.getState().setProxyCredentials(_proxyRealm, _proxyHost,
-                    new UsernamePasswordCredentials(_proxyUserName, _proxyPasswd));
+                client.getState().setProxyCredentials(proxyRealm, proxyHost,
+                    new UsernamePasswordCredentials(proxyUserName, proxyPasswd));
             }
         }
         Credentials c = getCredentials(url);
@@ -223,7 +225,7 @@
     }
 
     private boolean useProxy() {
-        return _proxyHost != null && _proxyHost.trim().length() > 0;
+        return proxyHost != null && proxyHost.trim().length() > 0;
     }
 
     private boolean useAuthentication(URL url) {
@@ -235,70 +237,72 @@
     }
 
     private boolean useProxyAuthentication() {
-        return (_proxyUserName != null && _proxyUserName.trim().length() > 0);
+        return (proxyUserName != null && proxyUserName.trim().length() > 0);
     }
 
     private static final class GETInputStream extends InputStream {
-        private InputStream _is;
+        private InputStream is;
 
-        private GetMethod _get;
+        private GetMethod get;
 
         private GETInputStream(GetMethod get) throws IOException {
-            _get = get;
-            _is = get.getResponseBodyAsStream();
+            this.get = get;
+            is = get.getResponseBodyAsStream();
         }
 
         public int available() throws IOException {
-            return _is.available();
+            return is.available();
         }
 
         public void close() throws IOException {
-            _is.close();
-            _get.releaseConnection();
+            is.close();
+            get.releaseConnection();
         }
 
         public boolean equals(Object obj) {
-            return _is.equals(obj);
+            return is.equals(obj);
         }
 
         public int hashCode() {
-            return _is.hashCode();
+            return is.hashCode();
         }
 
         public void mark(int readlimit) {
-            _is.mark(readlimit);
+            is.mark(readlimit);
         }
 
         public boolean markSupported() {
-            return _is.markSupported();
+            return is.markSupported();
         }
 
         public int read() throws IOException {
-            return _is.read();
+            return is.read();
         }
 
         public int read(byte[] b, int off, int len) throws IOException {
-            return _is.read(b, off, len);
+            return is.read(b, off, len);
         }
 
         public int read(byte[] b) throws IOException {
-            return _is.read(b);
+            return is.read(b);
         }
 
         public void reset() throws IOException {
-            _is.reset();
+            is.reset();
         }
 
         public long skip(long n) throws IOException {
-            return _is.skip(n);
+            return is.skip(n);
         }
 
         public String toString() {
-            return _is.toString();
+            return is.toString();
         }
     }
 
     private static final class HttpClientHelper3x implements HttpClientHelper {
+        private static final int VERSION = 3;
+
         private HttpClientHelper3x() {
         }
 
@@ -310,11 +314,13 @@
          * {@inheritDoc}
          */
         public int getHttpClientMajorVersion() {
-            return 3;
+            return VERSION;
         }
     }
 
     private static final class HttpClientHelper2x implements HttpClientHelper {
+        private static final int VERSION = 2;
+
         private HttpClientHelper2x() {
         }
 
@@ -334,7 +340,7 @@
          * {@inheritDoc}
          */
         public int getHttpClientMajorVersion() {
-            return 2;
+            return VERSION;
         }
     }
 

Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/util/url/IvyAuthenticator.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/util/url/IvyAuthenticator.java?view=diff&rev=550935&r1=550934&r2=550935
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/util/url/IvyAuthenticator.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/util/url/IvyAuthenticator.java Tue Jun 26 13:37:50 2007
@@ -31,7 +31,7 @@
     /**
      * The sole instance.
      */
-    public final static IvyAuthenticator INSTANCE = new IvyAuthenticator();
+    public static final IvyAuthenticator INSTANCE = new IvyAuthenticator();
 
     /**
      * Private c'tor to prevent instantiation. Also installs this as the default Authenticator to

Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/util/url/URLHandler.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/util/url/URLHandler.java?view=diff&rev=550935&r1=550934&r2=550935
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/util/url/URLHandler.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/util/url/URLHandler.java Tue Jun 26 13:37:50 2007
@@ -30,28 +30,28 @@
  */
 public interface URLHandler {
     public static class URLInfo {
-        private long _contentLength;
+        private long contentLength;
 
-        private long _lastModified;
+        private long lastModified;
 
-        private boolean _available;
+        private boolean available;
 
         protected URLInfo(boolean available, long contentLength, long lastModified) {
-            _available = available;
-            _contentLength = contentLength;
-            _lastModified = lastModified;
+            this.available = available;
+            this.contentLength = contentLength;
+            this.lastModified = lastModified;
         }
 
         public boolean isReachable() {
-            return _available;
+            return available;
         }
 
         public long getContentLength() {
-            return _contentLength;
+            return contentLength;
         }
 
         public long getLastModified() {
-            return _lastModified;
+            return lastModified;
         }
     }
 

Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/util/url/URLHandlerDispatcher.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/util/url/URLHandlerDispatcher.java?view=diff&rev=550935&r1=550934&r2=550935
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/util/url/URLHandlerDispatcher.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/util/url/URLHandlerDispatcher.java Tue Jun 26 13:37:50 2007
@@ -30,9 +30,9 @@
  * This class is used to dispatch downloading requests
  */
 public class URLHandlerDispatcher implements URLHandler {
-    protected Map _handlers = new HashMap();
+    private Map handlers = new HashMap();
 
-    protected URLHandler _default = new BasicURLHandler();
+    private URLHandler defaultHandler = new BasicURLHandler();
 
     public URLHandlerDispatcher() {
     }
@@ -78,19 +78,19 @@
     }
 
     public void setDownloader(String protocol, URLHandler downloader) {
-        _handlers.put(protocol, downloader);
+        handlers.put(protocol, downloader);
     }
 
     public URLHandler getHandler(String protocol) {
-        URLHandler downloader = (URLHandler) _handlers.get(protocol);
-        return downloader == null ? _default : downloader;
+        URLHandler downloader = (URLHandler) handlers.get(protocol);
+        return downloader == null ? defaultHandler : downloader;
     }
 
     public URLHandler getDefault() {
-        return _default;
+        return defaultHandler;
     }
 
     public void setDefault(URLHandler default1) {
-        _default = default1;
+        defaultHandler = default1;
     }
 }

Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/util/url/URLHandlerRegistry.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/util/url/URLHandlerRegistry.java?view=diff&rev=550935&r1=550934&r2=550935
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/util/url/URLHandlerRegistry.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/util/url/URLHandlerRegistry.java Tue Jun 26 13:37:50 2007
@@ -22,15 +22,18 @@
 /**
  *
  */
-public class URLHandlerRegistry {
-    private static URLHandler _default = new BasicURLHandler();
+public final class URLHandlerRegistry {
+    private URLHandlerRegistry() {
+    }
+    
+    private static URLHandler defaultHandler = new BasicURLHandler();
 
     public static URLHandler getDefault() {
-        return _default;
+        return defaultHandler;
     }
 
     public static void setDefault(URLHandler def) {
-        _default = def;
+        defaultHandler = def;
     }
 
     /**



Re: svn commit: r550935 - in /incubator/ivy/core/trunk/src/java/org/apache/ivy/util: extendable/ filter/ url/

Posted by Xavier Hanin <xa...@gmail.com>.
On 6/27/07, Gilles Scokart <gs...@gmail.com> wrote:
>
> >      public UnmodifiableExtendableItem(Map stdAttributes, Map
> extraAttributes) {
> >          if (stdAttributes != null) {
> > -            _attributes.putAll(stdAttributes);
> > -            _stdAttributes.putAll(stdAttributes);
> > +            attributes.putAll(stdAttributes);
> > +            stdAttributes.putAll(stdAttributes);
> >          }
> >          if (extraAttributes != null) {
> > -            _attributes.putAll(extraAttributes);
> > -            _extraAttributes.putAll(extraAttributes);
> > +            attributes.putAll(extraAttributes);
> > +            extraAttributes.putAll(extraAttributes);
> >          }
> >      }
> >
>
> The gump failure comes from this : extraAttributes.putAll
> (extraAttributes).


Indeed. I've checked in fix, for this and another problem in IvyBuildNumber

Tips in eclipse: use the refactoring "rename" (Alt+Shit+R) instead of
> the rename in files (Ctrl+Shift+1).  The 'refactoring' rename check
> that the new name is not already used, while the 'rename in files'
> doesn't.  (Unfortunately, it is a little bit slower)


I already use refactor rename, but apply it despite problems and fix
problems after. And sometimes I forget some problems... Fortunately we have
unit tests, but it's not the safest way to do, I might introduce problems in
untested code. But this refactoring is already so painful that I don't know
if I'll have enough time, energy and motivation to do it much more
carefully. OTOH the earlier we do it, and the more real world tests we will
have.

Xavier

--
> Gilles SCOKART
>



-- 
Xavier Hanin - Independent Java Consultant
Manage your dependencies with Ivy!
http://incubator.apache.org/ivy/

Re: svn commit: r550935 - in /incubator/ivy/core/trunk/src/java/org/apache/ivy/util: extendable/ filter/ url/

Posted by Gilles Scokart <gs...@gmail.com>.
>      public UnmodifiableExtendableItem(Map stdAttributes, Map extraAttributes) {
>          if (stdAttributes != null) {
> -            _attributes.putAll(stdAttributes);
> -            _stdAttributes.putAll(stdAttributes);
> +            attributes.putAll(stdAttributes);
> +            stdAttributes.putAll(stdAttributes);
>          }
>          if (extraAttributes != null) {
> -            _attributes.putAll(extraAttributes);
> -            _extraAttributes.putAll(extraAttributes);
> +            attributes.putAll(extraAttributes);
> +            extraAttributes.putAll(extraAttributes);
>          }
>      }
>

The gump failure comes from this : extraAttributes.putAll(extraAttributes).

Tips in eclipse: use the refactoring "rename" (Alt+Shit+R) instead of
the rename in files (Ctrl+Shift+1).  The 'refactoring' rename check
that the new name is not already used, while the 'rename in files'
doesn't.  (Unfortunately, it is a little bit slower)

-- 
Gilles SCOKART