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 gs...@apache.org on 2007/06/11 11:17:41 UTC

svn commit: r546093 - in /incubator/ivy/core/trunk: ./ src/java/org/apache/ivy/ant/ src/java/org/apache/ivy/core/cache/

Author: gscokart
Date: Mon Jun 11 04:17:40 2007
New Revision: 546093

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

Modified:
    incubator/ivy/core/trunk/   (props changed)
    incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/AntMessageImpl.java
    incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyAntSettings.java
    incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyAntVariableContainer.java
    incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyArtifactProperty.java
    incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyArtifactReport.java
    incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyVar.java
    incubator/ivy/core/trunk/src/java/org/apache/ivy/core/cache/ArtifactOrigin.java

Propchange: incubator/ivy/core/trunk/
------------------------------------------------------------------------------
--- svn:ignore (original)
+++ svn:ignore Mon Jun 11 04:17:40 2007
@@ -1,4 +1,4 @@
-
+.classpath
 build
 lib
 bin

Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/AntMessageImpl.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/AntMessageImpl.java?view=diff&rev=546093&r1=546092&r2=546093
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/AntMessageImpl.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/AntMessageImpl.java Mon Jun 11 04:17:40 2007
@@ -27,18 +27,20 @@
  * Implementation of the simple message facility for ant.
  */
 public class AntMessageImpl implements MessageImpl {
-    private Task _task;
+    private static final int PROGRESS_LOG_PERIOD = 1500;
 
-    private static long _lastProgressFlush = 0;
+    private Task task;
 
-    private static StringBuffer _buf = new StringBuffer();
+    private static long lastProgressFlush = 0;
+
+    private static StringBuffer buf = new StringBuffer();
 
     /**
-     * @param task
+     * @param aTask
      */
-    public AntMessageImpl(Task task) {
-        _task = task;
-        task.getProject().addBuildListener(new BuildListener() {
+    public AntMessageImpl(Task aTask) {
+        task = aTask;
+        aTask.getProject().addBuildListener(new BuildListener() {
             private int stackDepth = 0;
 
             public void buildFinished(BuildEvent event) {
@@ -76,31 +78,31 @@
     }
 
     public void log(String msg, int level) {
-        _task.log(msg, level);
+        task.log(msg, level);
     }
 
     public void rawlog(String msg, int level) {
-        _task.getProject().log(msg, level);
+        task.getProject().log(msg, level);
     }
 
     public void progress() {
-        _buf.append(".");
-        if (_lastProgressFlush == 0) {
-            _lastProgressFlush = System.currentTimeMillis();
+        buf.append(".");
+        if (lastProgressFlush == 0) {
+            lastProgressFlush = System.currentTimeMillis();
         }
-        if (_task != null) {
+        if (task != null) {
             // log with ant causes a new line -> we do it only once in a while
-            if (System.currentTimeMillis() - _lastProgressFlush > 1500) {
-                _task.log(_buf.toString());
-                _buf.setLength(0);
-                _lastProgressFlush = System.currentTimeMillis();
+            if (System.currentTimeMillis() - lastProgressFlush > PROGRESS_LOG_PERIOD) {
+                task.log(buf.toString());
+                buf.setLength(0);
+                lastProgressFlush = System.currentTimeMillis();
             }
         }
     }
 
     public void endProgress(String msg) {
-        _task.log(_buf + msg);
-        _buf.setLength(0);
-        _lastProgressFlush = 0;
+        task.log(buf + msg);
+        buf.setLength(0);
+        lastProgressFlush = 0;
     }
 }

Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyAntSettings.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyAntSettings.java?view=diff&rev=546093&r1=546092&r2=546093
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyAntSettings.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyAntSettings.java Mon Jun 11 04:17:40 2007
@@ -40,60 +40,60 @@
 public class IvyAntSettings extends DataType {
 
     public static class Credentials {
-        private String _realm;
+        private String realm;
 
-        private String _host;
+        private String host;
 
-        private String _username;
+        private String username;
 
-        private String _passwd;
+        private String passwd;
 
         public String getPasswd() {
-            return _passwd;
+            return this.passwd;
         }
 
         public void setPasswd(String passwd) {
-            _passwd = passwd;
+            this.passwd = passwd;
         }
 
         public String getRealm() {
-            return _realm;
+            return this.realm;
         }
 
         public void setRealm(String realm) {
-            _realm = format(realm);
+            this.realm = format(realm);
         }
 
         public String getHost() {
-            return _host;
+            return this.host;
         }
 
         public void setHost(String host) {
-            _host = format(host);
+            this.host = format(host);
         }
 
         public String getUsername() {
-            return _username;
+            return this.username;
         }
 
         public void setUsername(String userName) {
-            _username = format(userName);
+            this.username = format(userName);
         }
     }
 
-    private Ivy _ivyEngine = null;
+    private Ivy ivyEngine = null;
 
-    private File _file = null;
+    private File file = null;
 
-    private URL _url = null;
+    private URL url = null;
 
-    private String _realm = null;
+    private String realm = null;
 
-    private String _host = null;
+    private String host = null;
 
-    private String _userName = null;
+    private String userName = null;
 
-    private String _passwd = null;
+    private String passwd = null;
 
     private String id = null;
 
@@ -109,8 +109,8 @@
         if (defaultInstanceObj != null
                 && defaultInstanceObj.getClass().getClassLoader() != IvyAntSettings.class
                         .getClassLoader()) {
-            Message
-                    .warn("ivy.instance reference an ivy:settings defined in an other classloader.  An new default one will be used in this project.");
+            Message.warn("ivy.instance reference an ivy:settings defined in an other classloader.  "
+                     + "An new default one will be used in this project.");
             defaultInstanceObj = null;
         }
         if (defaultInstanceObj != null && !(defaultInstanceObj instanceof IvyAntSettings)) {
@@ -119,8 +119,8 @@
                     + " an not an IvyAntSettings.  Please don't use this reference id ()");
         }
         if (defaultInstanceObj == null) {
-            Message
-                    .info("No ivy:settings found for the default reference 'ivy.instance'.  A default instance will be used");
+            Message.info("No ivy:settings found for the default reference 'ivy.instance'.  " 
+                    + "A default instance will be used");
             IvyAntSettings defaultInstance = new IvyAntSettings();
             defaultInstance.setProject(project);
             defaultInstance.registerAsDefault();
@@ -136,43 +136,43 @@
     }
 
     public File getFile() {
-        return _file;
+        return file;
     }
 
     public URL getUrl() {
-        return _url;
+        return url;
     }
 
     public String getPasswd() {
-        return _passwd;
+        return passwd;
     }
 
-    public void setPasswd(String passwd) {
-        _passwd = passwd;
+    public void setPasswd(String aPasswd) {
+        passwd = aPasswd;
     }
 
     public String getRealm() {
-        return _realm;
+        return realm;
     }
 
-    public void setRealm(String realm) {
-        _realm = format(realm);
+    public void setRealm(String aRealm) {
+        realm = format(aRealm);
     }
 
     public String getHost() {
-        return _host;
+        return host;
     }
 
-    public void setHost(String host) {
-        _host = format(host);
+    public void setHost(String aHost) {
+        host = format(aHost);
     }
 
     public String getUsername() {
-        return _userName;
+        return userName;
     }
 
-    public void setUsername(String userName) {
-        _userName = format(userName);
+    public void setUsername(String aUserName) {
+        userName = format(aUserName);
     }
 
     public String getId() {
@@ -193,15 +193,17 @@
     }
 
     public void setFile(File file) {
-        this._file = file;
+        this.file = file;
     }
 
     public void setUrl(String confUrl) throws MalformedURLException {
-        this._url = new URL(confUrl);
+        this.url = new URL(confUrl);
     }
 
     /*
-     * public void execute() throws BuildException { ensureMessageInitialised(); if (getId()==null) {
+     * public void execute() throws BuildException { 
+     * ensureMessageInitialised(); 
+     * if (getId()==null) {
      * log("No id specified for the ivy:settings, set the instance as the default one",
      * Project.MSG_DEBUG); getProject().addReference("ivy.instance", this); } else {
      * getProject().addReference(id, this); } }
@@ -211,10 +213,10 @@
      * @return
      */
     public Ivy getConfiguredIvyInstance() {
-        if (_ivyEngine == null) {
-            _ivyEngine = createIvyEngine();
+        if (ivyEngine == null) {
+            ivyEngine = createIvyEngine();
         }
-        return _ivyEngine;
+        return ivyEngine;
     }
 
     private Ivy createIvyEngine() {
@@ -227,30 +229,31 @@
 
         Ivy ivy = Ivy.newInstance(settings);
 
-        if (_file == null && _url == null) {
+        if (file == null && url == null) {
             defineDefaultSettingFile(ivyAntVariableContainer);
         }
 
         try {
             configureURLHandler();
-            if (_file != null) {
-                if (!_file.exists()) {
-                    throw new BuildException("settings file does not exist: " + _file);
+            if (file != null) {
+                if (!file.exists()) {
+                    throw new BuildException("settings file does not exist: " + file);
                 }
-                ivy.configure(_file);
+                ivy.configure(file);
             } else {
-                if (_url == null) {
+                if (url == null) {
                     throw new AssertionError(
-                            "ivy setting should have either a file, either an url, and if not defineDefaultSettingFile must set it.");
+                            "ivy setting should have either a file, either an url,"
+                                    + " and if not defineDefaultSettingFile must set it.");
                 }
-                ivy.configure(_url);
+                ivy.configure(url);
             }
         } catch (ParseException e) {
             throw new BuildException("impossible to configure ivy:settings with given "
-                    + (_file != null ? "file: " + _file : "url :" + _url) + " :" + e, e);
+                    + (file != null ? "file: " + file : "url :" + url) + " :" + e, e);
         } catch (IOException e) {
             throw new BuildException("impossible to configure ivy:settings with given "
-                    + (_file != null ? "file: " + _file : "url :" + _url) + " :" + e, e);
+                    + (file != null ? "file: " + file : "url :" + url) + " :" + e, e);
         }
         return ivy;
     }
@@ -290,23 +293,23 @@
         File[] settingsLocations = new File[] {
                 new File(getProject().getBaseDir(), settingsFileName),
                 new File(getProject().getBaseDir(), "ivyconf.xml"), new File(settingsFileName),
-                new File("ivyconf.xml"),};
+                new File("ivyconf.xml") };
         for (int i = 0; i < settingsLocations.length; i++) {
-            _file = settingsLocations[i];
-            Message.verbose("searching settings file: trying " + _file);
-            if (_file.exists()) {
+            file = settingsLocations[i];
+            Message.verbose("searching settings file: trying " + file);
+            if (file.exists()) {
                 break;
             }
         }
-        if (!_file.exists()) {
+        if (!file.exists()) {
             if (Boolean.valueOf(getProject().getProperty("ivy.14.compatible")).booleanValue()) {
                 Message.info("no settings file found, using Ivy 1.4 default...");
-                _file = null;
-                _url = IvySettings.getDefault14SettingsURL();
+                file = null;
+                url = IvySettings.getDefault14SettingsURL();
             } else {
                 Message.info("no settings file found, using default...");
-                _file = null;
-                _url = IvySettings.getDefaultSettingsURL();
+                file = null;
+                url = IvySettings.getDefaultSettingsURL();
             }
         }
     }

Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyAntVariableContainer.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyAntVariableContainer.java?view=diff&rev=546093&r1=546092&r2=546093
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyAntVariableContainer.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyAntVariableContainer.java Mon Jun 11 04:17:40 2007
@@ -1,5 +1,19 @@
-/**
- * 
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
  */
 package org.apache.ivy.ant;
 
@@ -13,18 +27,18 @@
 
 class IvyAntVariableContainer extends IvyVariableContainerImpl implements IvyVariableContainer {
 
-    protected Map _overwrittenProperties = new HashMap();
+    private Map overwrittenProperties = new HashMap();
 
-    protected Project _project;
+    private Project project;
 
     public IvyAntVariableContainer(Project project) {
-        this._project = project;
+        this.project = project;
     }
 
     public String getVariable(String name) {
-        String r = (String) _overwrittenProperties.get(name);
+        String r = (String) overwrittenProperties.get(name);
         if (r == null) {
-            r = _project.getProperty(name);
+            r = project.getProperty(name);
         }
         if (r == null) {
             r = super.getVariable(name);
@@ -34,15 +48,15 @@
 
     public Map getVariables() {
         Map r = new HashMap(super.getVariables());
-        r.putAll(_project.getProperties());
-        r.putAll(_overwrittenProperties);
+        r.putAll(project.getProperties());
+        r.putAll(overwrittenProperties);
         return r;
     }
 
     public void setVariable(String varName, String value, boolean overwrite) {
         if (overwrite) {
             Message.debug("setting '" + varName + "' to '" + value + "'");
-            _overwrittenProperties.put(varName, value);
+            overwrittenProperties.put(varName, value);
         } else {
             super.setVariable(varName, value, overwrite);
         }

Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyArtifactProperty.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyArtifactProperty.java?view=diff&rev=546093&r1=546092&r2=546093
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyArtifactProperty.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyArtifactProperty.java Mon Jun 11 04:17:40 2007
@@ -30,24 +30,24 @@
  * Set a set of ant properties according to the last artifact resolved
  */
 public class IvyArtifactProperty extends IvyPostResolveTask {
-    private String _name;
+    private String name;
 
-    private String _value;
+    private String value;
 
     public String getName() {
-        return _name;
+        return this.name;
     }
 
     public void setName(String name) {
-        _name = name;
+        this.name = name;
     }
 
     public String getValue() {
-        return _value;
+        return this.value;
     }
 
     public void setValue(String value) {
-        _value = value;
+        this.value = value;
     }
 
     public void doExecute() throws BuildException {

Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyArtifactReport.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyArtifactReport.java?view=diff&rev=546093&r1=546092&r2=546093
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyArtifactReport.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyArtifactReport.java Mon Jun 11 04:17:40 2007
@@ -51,34 +51,34 @@
  * Generates a report of all artifacts involved during the last resolve.
  */
 public class IvyArtifactReport extends IvyPostResolveTask {
-    private File _tofile;
+    private File tofile;
 
-    private String _pattern;
+    private String pattern;
 
     public File getTofile() {
-        return _tofile;
+        return tofile;
     }
 
-    public void setTofile(File tofile) {
-        _tofile = tofile;
+    public void setTofile(File aFile) {
+        tofile = aFile;
     }
 
     public String getPattern() {
-        return _pattern;
+        return pattern;
     }
 
-    public void setPattern(String pattern) {
-        _pattern = pattern;
+    public void setPattern(String aPattern) {
+        pattern = aPattern;
     }
 
     public void doExecute() throws BuildException {
         prepareAndCheck();
-        if (_tofile == null) {
+        if (tofile == null) {
             throw new BuildException(
                     "no destination file name: please provide it through parameter 'tofile'");
         }
 
-        _pattern = getProperty(_pattern, getSettings(), "ivy.retrieve.pattern");
+        pattern = getProperty(pattern, getSettings(), "ivy.retrieve.pattern");
 
         try {
             String[] confs = splitConfs(getConf());
@@ -87,7 +87,8 @@
             if (getResolveId() != null) {
                 md = (ModuleDescriptor) getResolvedDescriptor(getResolveId());
             } else {
-                md = (ModuleDescriptor) getResolvedDescriptor(getOrganisation(), getModule(), false);
+                md = (ModuleDescriptor) getResolvedDescriptor(getOrganisation(), getModule()
+                        , false);
             }
             IvyNode[] dependencies = getIvyInstance().getResolveEngine().getDependencies(
                 md,
@@ -96,7 +97,7 @@
 
             Map artifactsToCopy = getIvyInstance().getRetrieveEngine().determineArtifactsToCopy(
                 ModuleRevisionId.newInstance(getOrganisation(), getModule(), getRevision()),
-                _pattern,
+                pattern,
                 new RetrieveOptions().setConfs(confs).setResolveId(getResolveId()).setCache(
                     cacheManager));
 
@@ -124,7 +125,7 @@
     private void generateXml(CacheManager cache, IvyNode[] dependencies,
             Map moduleRevToArtifactsMap, Map artifactsToCopy) {
         try {
-            FileOutputStream fileOuputStream = new FileOutputStream(_tofile);
+            FileOutputStream fileOuputStream = new FileOutputStream(tofile);
             try {
                 TransformerHandler saxHandler = createTransformerHandler(fileOuputStream);
 

Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyVar.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyVar.java?view=diff&rev=546093&r1=546092&r2=546093
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyVar.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyVar.java Mon Jun 11 04:17:40 2007
@@ -32,54 +32,54 @@
  * This task let user set ivy variables from ant.
  */
 public class IvyVar extends IvyTask {
-    private String _name;
+    private String name;
 
-    private String _value;
+    private String value;
 
-    private File _file;
+    private File file;
 
-    private String _url;
+    private String url;
 
-    private String _prefix;
+    private String prefix;
 
     public File getFile() {
-        return _file;
+        return file;
     }
 
-    public void setFile(File file) {
-        _file = file;
+    public void setFile(File aFile) {
+        file = aFile;
     }
 
     public String getName() {
-        return _name;
+        return name;
     }
 
-    public void setName(String name) {
-        _name = name;
+    public void setName(String aName) {
+        name = aName;
     }
 
     public String getPrefix() {
-        return _prefix;
+        return prefix;
     }
 
-    public void setPrefix(String prefix) {
-        _prefix = prefix;
+    public void setPrefix(String aPrefix) {
+        prefix = aPrefix;
     }
 
     public String getUrl() {
-        return _url;
+        return url;
     }
 
-    public void setUrl(String url) {
-        _url = url;
+    public void setUrl(String aUrl) {
+        url = aUrl;
     }
 
     public String getValue() {
-        return _value;
+        return value;
     }
 
-    public void setValue(String value) {
-        _value = value;
+    public void setValue(String aValue) {
+        value = aValue;
     }
 
     public void doExecute() throws BuildException {
@@ -106,6 +106,7 @@
                     try {
                         is.close();
                     } catch (Exception e) {
+                        //ignore
                     }
                 }
             }

Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/core/cache/ArtifactOrigin.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/core/cache/ArtifactOrigin.java?view=diff&rev=546093&r1=546092&r2=546093
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/core/cache/ArtifactOrigin.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/core/cache/ArtifactOrigin.java Mon Jun 11 04:17:40 2007
@@ -24,6 +24,8 @@
  * @see org.apache.ivy.plugins.resolver.util.ResolvedResource
  */
 public class ArtifactOrigin {
+    private static final int MAGIC_HASH_VALUE = 31;
+
     private boolean isLocal;
 
     private String location;
@@ -65,17 +67,21 @@
     }
 
     public boolean equals(Object o) {
-        if (this == o)
+        if (this == o) {
             return true;
-        if (o == null || getClass() != o.getClass())
+        }
+        if (o == null || getClass() != o.getClass()) {
             return false;
+        }
 
         ArtifactOrigin that = (ArtifactOrigin) o;
 
-        if (isLocal != that.isLocal)
+        if (isLocal != that.isLocal) {
             return false;
-        if (!location.equals(that.location))
+        }
+        if (!location.equals(that.location)) {
             return false;
+        }
 
         return true;
     }
@@ -83,7 +89,7 @@
     public int hashCode() {
         int result;
         result = (isLocal ? 1 : 0);
-        result = 31 * result + location.hashCode();
+        result = MAGIC_HASH_VALUE * result + location.hashCode();
         return result;
     }
 }