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/08 11:47:10 UTC

svn commit: r545485 - in /incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver: AbstractResolver.java BasicResolver.java

Author: xavier
Date: Fri Jun  8 04:47:09 2007
New Revision: 545485

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

Modified:
    incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/AbstractResolver.java
    incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/BasicResolver.java

Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/AbstractResolver.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/AbstractResolver.java?view=diff&rev=545485&r1=545484&r2=545485
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/AbstractResolver.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/AbstractResolver.java Fri Jun  8 04:47:09 2007
@@ -56,44 +56,44 @@
      * True if parsed ivy files should be validated against xsd, false if they should not, null if
      * default behaviour should be used
      */
-    private Boolean _validate = null;
+    private Boolean validate = null;
 
-    private String _name;
+    private String name;
 
-    private String _changingPattern;
+    private String changingPattern;
 
-    private String _changingMatcherName = PatternMatcher.EXACT_OR_REGEXP;
+    private String changingMatcherName = PatternMatcher.EXACT_OR_REGEXP;
 
-    private IvySettings _settings;
+    private IvySettings settings;
 
     /**
      * The latest strategy to use to find latest among several artifacts
      */
-    private LatestStrategy _latestStrategy;
+    private LatestStrategy latestStrategy;
 
-    private String _latestStrategyName;
+    private String latestStrategyName;
 
     /**
      * The namespace to which this resolver belongs
      */
-    private Namespace _namespace;
+    private Namespace namespace;
 
-    private String _namespaceName;
+    private String namespaceName;
 
     public IvySettings getSettings() {
-        return _settings;
+        return settings;
     }
 
     public void setSettings(IvySettings ivy) {
-        _settings = ivy;
+        settings = ivy;
     }
 
     public String getName() {
-        return _name;
+        return name;
     }
 
     public void setName(String name) {
-        _name = name;
+        this.name = name;
     }
 
     /**
@@ -108,19 +108,19 @@
     }
 
     protected boolean doValidate(ResolveData data) {
-        if (_validate != null) {
-            return _validate.booleanValue();
+        if (validate != null) {
+            return validate.booleanValue();
         } else {
             return data.isValidate();
         }
     }
 
     public boolean isValidate() {
-        return _validate == null ? true : _validate.booleanValue();
+        return validate == null ? true : validate.booleanValue();
     }
 
     public void setValidate(boolean validate) {
-        _validate = Boolean.valueOf(validate);
+        this.validate = Boolean.valueOf(validate);
     }
 
     protected void checkInterrupted() {
@@ -177,65 +177,66 @@
     }
 
     public LatestStrategy getLatestStrategy() {
-        if (_latestStrategy == null) {
+        if (latestStrategy == null) {
             if (getSettings() != null) {
-                if (_latestStrategyName != null && !"default".equals(_latestStrategyName)) {
-                    _latestStrategy = getSettings().getLatestStrategy(_latestStrategyName);
-                    if (_latestStrategy == null) {
-                        Message.error("unknown latest strategy: " + _latestStrategyName);
-                        _latestStrategy = getSettings().getDefaultLatestStrategy();
+                if (latestStrategyName != null && !"default".equals(latestStrategyName)) {
+                    latestStrategy = getSettings().getLatestStrategy(latestStrategyName);
+                    if (latestStrategy == null) {
+                        Message.error("unknown latest strategy: " + latestStrategyName);
+                        latestStrategy = getSettings().getDefaultLatestStrategy();
                     }
                 } else {
-                    _latestStrategy = getSettings().getDefaultLatestStrategy();
+                    latestStrategy = getSettings().getDefaultLatestStrategy();
                     Message.debug(getName() + ": no latest strategy defined: using default");
                 }
             } else {
                 throw new IllegalStateException(
-                        "no ivy instance found: impossible to get a latest strategy without ivy instance");
+                    "no ivy instance found: "
+                    + "impossible to get a latest strategy without ivy instance");
             }
         }
-        return _latestStrategy;
+        return latestStrategy;
     }
 
     public void setLatestStrategy(LatestStrategy latestStrategy) {
-        _latestStrategy = latestStrategy;
+        this.latestStrategy = latestStrategy;
     }
 
     public void setLatest(String strategyName) {
-        _latestStrategyName = strategyName;
+        latestStrategyName = strategyName;
     }
 
     public String getLatest() {
-        if (_latestStrategyName == null) {
-            _latestStrategyName = "default";
+        if (latestStrategyName == null) {
+            latestStrategyName = "default";
         }
-        return _latestStrategyName;
+        return latestStrategyName;
     }
 
     public Namespace getNamespace() {
-        if (_namespace == null) {
+        if (namespace == null) {
             if (getSettings() != null) {
-                if (_namespaceName != null) {
-                    _namespace = getSettings().getNamespace(_namespaceName);
-                    if (_namespace == null) {
-                        Message.error("unknown namespace: " + _namespaceName);
-                        _namespace = getSettings().getSystemNamespace();
+                if (namespaceName != null) {
+                    namespace = getSettings().getNamespace(namespaceName);
+                    if (namespace == null) {
+                        Message.error("unknown namespace: " + namespaceName);
+                        namespace = getSettings().getSystemNamespace();
                     }
                 } else {
-                    _namespace = getSettings().getSystemNamespace();
+                    namespace = getSettings().getSystemNamespace();
                     Message.debug(getName() + ": no namespace defined: using system");
                 }
             } else {
                 Message.verbose(getName()
                         + ": no namespace defined nor ivy instance: using system namespace");
-                _namespace = Namespace.SYSTEM_NAMESPACE;
+                namespace = Namespace.SYSTEM_NAMESPACE;
             }
         }
-        return _namespace;
+        return namespace;
     }
 
     public void setNamespace(String namespaceName) {
-        _namespaceName = namespaceName;
+        this.namespaceName = namespaceName;
     }
 
     // Namespace conversion methods
@@ -285,31 +286,31 @@
     }
 
     public String getChangingMatcherName() {
-        return _changingMatcherName;
+        return changingMatcherName;
     }
 
     public void setChangingMatcher(String changingMatcherName) {
-        _changingMatcherName = changingMatcherName;
+        this.changingMatcherName = changingMatcherName;
     }
 
     public String getChangingPattern() {
-        return _changingPattern;
+        return changingPattern;
     }
 
     public void setChangingPattern(String changingPattern) {
-        _changingPattern = changingPattern;
+        this.changingPattern = changingPattern;
     }
 
     public Matcher getChangingMatcher() {
-        if (_changingPattern == null) {
+        if (changingPattern == null) {
             return NoMatcher.INSTANCE;
         }
-        PatternMatcher matcher = _settings.getMatcher(_changingMatcherName);
+        PatternMatcher matcher = settings.getMatcher(changingMatcherName);
         if (matcher == null) {
-            throw new IllegalStateException("unknown matcher '" + _changingMatcherName
+            throw new IllegalStateException("unknown matcher '" + changingMatcherName
                     + "'. It is set as changing matcher in " + this);
         }
-        return matcher.getMatcher(_changingPattern);
+        return matcher.getMatcher(changingPattern);
     }
 
 }

Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/BasicResolver.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/BasicResolver.java?view=diff&rev=545485&r1=545484&r2=545485
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/BasicResolver.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/BasicResolver.java Fri Jun  8 04:47:09 2007
@@ -80,49 +80,49 @@
 public abstract class BasicResolver extends AbstractResolver {
     public static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyyMMddHHmmss");
 
-    protected String _workspaceName;
+    private String workspaceName;
 
     /**
      * True if the files resolved are dependent of the environment from which they have been
      * resolved, false otherwise. In general, relative paths are dependent of the environment, and
      * absolute paths including machine reference are not.
      */
-    private boolean _envDependent = true;
+    private boolean envDependent = true;
 
-    private List _ivyattempts = new ArrayList();
+    private List ivyattempts = new ArrayList();
 
-    private Map _artattempts = new HashMap();
+    private Map artattempts = new HashMap();
 
-    private Boolean _checkmodified = null;
+    private Boolean checkmodified = null;
 
-    private boolean _checkconsistency = true;
+    private boolean checkconsistency = true;
 
-    private boolean _allownomd = true;
+    private boolean allownomd = true;
 
-    private String _checksums = null;
+    private String checksums = null;
 
-    private URLRepository _extartifactrep = new URLRepository(); // used only to download
+    private URLRepository extartifactrep = new URLRepository(); // used only to download
 
     // external artifacts
 
     public BasicResolver() {
-        _workspaceName = HostUtil.getLocalHostName();
+        workspaceName = HostUtil.getLocalHostName();
     }
 
     public String getWorkspaceName() {
-        return _workspaceName;
+        return workspaceName;
     }
 
     public void setWorkspaceName(String workspaceName) {
-        _workspaceName = workspaceName;
+        this.workspaceName = workspaceName;
     }
 
     public boolean isEnvDependent() {
-        return _envDependent;
+        return envDependent;
     }
 
     public void setEnvDependent(boolean envDependent) {
-        _envDependent = envDependent;
+        this.envDependent = envDependent;
     }
 
     /**
@@ -131,7 +131,7 @@
      * @return
      */
     public boolean isCheckmodified() {
-        if (_checkmodified == null) {
+        if (checkmodified == null) {
             if (getSettings() != null) {
                 String check = getSettings().getVariable("ivy.resolver.default.check.modified");
                 return check != null ? Boolean.valueOf(check).booleanValue() : false;
@@ -139,12 +139,12 @@
                 return false;
             }
         } else {
-            return _checkmodified.booleanValue();
+            return checkmodified.booleanValue();
         }
     }
 
     public void setCheckmodified(boolean check) {
-        _checkmodified = Boolean.valueOf(check);
+        checkmodified = Boolean.valueOf(check);
     }
 
     public ResolvedModuleRevision getDependency(DependencyDescriptor dd, ResolveData data)
@@ -161,7 +161,7 @@
             ModuleRevisionId mrid = dd.getDependencyRevisionId();
             // check revision
             int index = mrid.getRevision().indexOf("@");
-            if (index != -1 && !mrid.getRevision().substring(index + 1).equals(_workspaceName)) {
+            if (index != -1 && !mrid.getRevision().substring(index + 1).equals(workspaceName)) {
                 Message.verbose("\t" + getName() + ": unhandled revision => " + mrid.getRevision());
                 return null;
             }
@@ -217,12 +217,6 @@
                 if (artifactRef == null) {
                     Message.verbose("\t" + getName() + ": no ivy file nor artifact found for "
                             + mrid);
-                    String[] conf = md.getConfigurationsNames();
-                    for (int i = 0; i < conf.length; i++) {
-                        Artifact[] artifacts = md.getArtifacts(conf[i]);
-                        for (int j = 0; j < artifacts.length; j++) {
-                        }
-                    }
                     if (!checkedCache) {
                         cachedRmr = findModuleInCache(data, mrid);
                     }
@@ -264,7 +258,7 @@
 
                     // check descriptor data is in sync with resource revision and names
                     systemMd = toSystem(md);
-                    if (_checkconsistency) {
+                    if (checkconsistency) {
                         checkDescriptorConsistency(mrid, md, ivyRef);
                         checkDescriptorConsistency(systemDd.getDependencyRevisionId(), systemMd,
                             ivyRef);
@@ -274,8 +268,9 @@
                             ((DefaultModuleDescriptor) md).setModuleRevisionId(ModuleRevisionId
                                     .newInstance(mrid, revision));
                         } else {
-                            Message
-                                    .warn("consistency disabled with instance of non DefaultModuleDescriptor... module info can't be updated, so consistency check will be done");
+                            Message.warn(
+                              "consistency disabled with instance of non DefaultModuleDescriptor..."
+                              + " module info can't be updated, so consistency check will be done");
                             checkDescriptorConsistency(mrid, md, ivyRef);
                             checkDescriptorConsistency(systemDd.getDependencyRevisionId(),
                                 systemMd, ivyRef);
@@ -292,7 +287,8 @@
             ModuleRevisionId resolvedMrid = mrid;
             if (isDynamic) {
                 resolvedMrid = md.getResolvedModuleRevisionId();
-                if (resolvedMrid.getRevision() == null || resolvedMrid.getRevision().length() == 0) {
+                if (resolvedMrid.getRevision() == null 
+                        || resolvedMrid.getRevision().length() == 0) {
                     if (ivyRef.getRevision() == null || ivyRef.getRevision().length() == 0) {
                         resolvedMrid = ModuleRevisionId.newInstance(resolvedMrid, "working@"
                                 + getName());
@@ -344,11 +340,13 @@
                         DefaultModuleDescriptor dmd = (DefaultModuleDescriptor) md;
                         if (data.getSettings().logNotConvertedExclusionRule()
                                 && dmd.isNamespaceUseful()) {
-                            Message
-                                    .warn("the module descriptor "
-                                            + ivyRef.getResource()
-                                            + " has information which can't be converted into the system namespace. It will require the availability of the namespace '"
-                                            + getNamespace().getName() + "' to be fully usable.");
+                            Message.warn(
+                                "the module descriptor "
+                                + ivyRef.getResource()
+                                + " has information which can't be converted into "
+                                + "the system namespace. "
+                                + "It will require the availability of the namespace '"
+                                + getNamespace().getName() + "' to be fully usable.");
                         }
                     }
                     // copy and update ivy file from source to cache
@@ -620,7 +618,7 @@
     }
 
     protected void clearIvyAttempts() {
-        _ivyattempts.clear();
+        ivyattempts.clear();
         clearArtifactAttempts();
     }
 
@@ -662,15 +660,15 @@
     }
 
     protected void logIvyAttempt(String attempt) {
-        _ivyattempts.add(attempt);
+        ivyattempts.add(attempt);
         Message.verbose("\t\ttried " + attempt);
     }
 
     protected void logArtifactAttempt(Artifact art, String attempt) {
-        List attempts = (List) _artattempts.get(art);
+        List attempts = (List) artattempts.get(art);
         if (attempts == null) {
             attempts = new ArrayList();
-            _artattempts.put(art, attempts);
+            artattempts.put(art, attempts);
         }
         attempts.add(attempt);
         Message.verbose("\t\ttried " + attempt);
@@ -691,13 +689,13 @@
 
     public void reportFailure() {
         Message.warn("==== " + getName() + ": tried");
-        for (ListIterator iter = _ivyattempts.listIterator(); iter.hasNext();) {
+        for (ListIterator iter = ivyattempts.listIterator(); iter.hasNext();) {
             String m = (String) iter.next();
             Message.warn("  " + m);
         }
-        for (Iterator iter = _artattempts.keySet().iterator(); iter.hasNext();) {
+        for (Iterator iter = artattempts.keySet().iterator(); iter.hasNext();) {
             Artifact art = (Artifact) iter.next();
-            List attempts = (List) _artattempts.get(art);
+            List attempts = (List) artattempts.get(art);
             if (attempts != null) {
                 Message.warn("  -- artifact " + art + ":");
                 for (ListIterator iterator = attempts.listIterator(); iterator.hasNext();) {
@@ -710,7 +708,7 @@
 
     public void reportFailure(Artifact art) {
         Message.warn("==== " + getName() + ": tried");
-        List attempts = (List) _artattempts.get(art);
+        List attempts = (List) artattempts.get(art);
         if (attempts != null) {
             for (ListIterator iter = attempts.listIterator(); iter.hasNext();) {
                 String m = (String) iter.next();
@@ -804,7 +802,7 @@
                                     if (tmp.getParentFile() != null) {
                                         tmp.getParentFile().mkdirs();
                                     }
-                                    _extartifactrep.get(artifactRef.getResource().getName(), tmp);
+                                    extartifactrep.get(artifactRef.getResource().getName(), tmp);
                                     adr.setSize(tmp.length());
                                 } else {
                                     adr.setSize(getAndCheck(artifactRef.getResource(), tmp));
@@ -844,7 +842,7 @@
     }
 
     protected void clearArtifactAttempts() {
-        _artattempts.clear();
+        artattempts.clear();
     }
 
     public boolean exists(Artifact artifact) {
@@ -855,7 +853,8 @@
         return false;
     }
 
-    protected long getPublicationDate(ModuleDescriptor md, DependencyDescriptor dd, ResolveData data) {
+    protected long getPublicationDate(ModuleDescriptor md, DependencyDescriptor dd, 
+            ResolveData data) {
         if (md.getPublicationDate() != null) {
             return md.getPublicationDate().getTime();
         }
@@ -1002,23 +1001,23 @@
     protected abstract long get(Resource resource, File dest) throws IOException;
 
     public boolean isCheckconsistency() {
-        return _checkconsistency;
+        return checkconsistency;
     }
 
     public void setCheckconsistency(boolean checkConsitency) {
-        _checkconsistency = checkConsitency;
+        checkconsistency = checkConsitency;
     }
 
     public boolean isAllownomd() {
-        return _allownomd;
+        return allownomd;
     }
 
     public void setAllownomd(boolean b) {
-        _allownomd = b;
+        allownomd = b;
     }
 
     public String[] getChecksumAlgorithms() {
-        String csDef = _checksums == null ? getSettings().getVariable("ivy.checksums") : _checksums;
+        String csDef = checksums == null ? getSettings().getVariable("ivy.checksums") : checksums;
         if (csDef == null) {
             return new String[0];
         }
@@ -1036,7 +1035,7 @@
     }
 
     public void setChecksums(String checksums) {
-        _checksums = checksums;
+        this.checksums = checksums;
     }
 
 }