ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gin...@apache.org
Subject [5/6] ant-ivy git commit: Refactor append()
Date Fri, 10 Nov 2017 18:04:42 GMT
Refactor append()

Project: http://git-wip-us.apache.org/repos/asf/ant-ivy/repo
Commit: http://git-wip-us.apache.org/repos/asf/ant-ivy/commit/0c0845e9
Tree: http://git-wip-us.apache.org/repos/asf/ant-ivy/tree/0c0845e9
Diff: http://git-wip-us.apache.org/repos/asf/ant-ivy/diff/0c0845e9

Branch: refs/heads/master
Commit: 0c0845e95cfc5d4bf0909e4ad86be9da5b00b277
Parents: 0600561
Author: Gintas Grigelionis <gintas@apache.org>
Authored: Fri Nov 10 19:03:13 2017 +0100
Committer: Gintas Grigelionis <gintas@apache.org>
Committed: Fri Nov 10 19:03:13 2017 +0100

----------------------------------------------------------------------
 .../apache/ivy/osgi/core/BundleInfoAdapter.java | 21 +++------
 .../org/apache/ivy/osgi/util/VersionRange.java  | 23 ++++------
 .../ivy/plugins/resolver/BasicResolver.java     | 46 +++++++++++---------
 src/java/org/apache/ivy/util/HexEncoder.java    |  3 +-
 4 files changed, 41 insertions(+), 52 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/0c0845e9/src/java/org/apache/ivy/osgi/core/BundleInfoAdapter.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/ivy/osgi/core/BundleInfoAdapter.java b/src/java/org/apache/ivy/osgi/core/BundleInfoAdapter.java
index b8607d5..ee56614 100644
--- a/src/java/org/apache/ivy/osgi/core/BundleInfoAdapter.java
+++ b/src/java/org/apache/ivy/osgi/core/BundleInfoAdapter.java
@@ -224,30 +224,21 @@ public class BundleInfoAdapter {
     private static URI asIvyURI(String org, String name, String branch, String rev, String
type,
             String art, String ext) {
         StringBuilder builder = new StringBuilder();
-        builder.append("ivy:///");
-        builder.append(org);
-        builder.append('/');
-        builder.append(name);
-        builder.append('?');
+        builder.append("ivy:///").append(org).append('/').append(name).append('?');
         if (branch != null) {
-            builder.append("branch=");
-            builder.append(branch);
+            builder.append("branch=").append(branch);
         }
         if (rev != null) {
-            builder.append("&rev=");
-            builder.append(rev);
+            builder.append("&rev=").append(rev);
         }
         if (type != null) {
-            builder.append("&type=");
-            builder.append(type);
+            builder.append("&type=").append(type);
         }
         if (art != null) {
-            builder.append("&art=");
-            builder.append(art);
+            builder.append("&art=").append(art);
         }
         if (ext != null) {
-            builder.append("&ext=");
-            builder.append(ext);
+            builder.append("&ext=").append(ext);
         }
         try {
             return new URI(builder.toString());

http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/0c0845e9/src/java/org/apache/ivy/osgi/util/VersionRange.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/ivy/osgi/util/VersionRange.java b/src/java/org/apache/ivy/osgi/util/VersionRange.java
index abf9c74..9af6213 100644
--- a/src/java/org/apache/ivy/osgi/util/VersionRange.java
+++ b/src/java/org/apache/ivy/osgi/util/VersionRange.java
@@ -264,26 +264,21 @@ public class VersionRange {
     }
 
     public String toString() {
-        return (startExclusive ? "(" : "[") + startVersion + ","
+        return (startExclusive ? "(" : "[") + startVersion.toString() + ","
                 + (endVersion == null ? "" : endVersion.toString()) + (endExclusive ? ")"
: "]");
     }
 
     public String toIvyRevision() {
         StringBuilder buffer = new StringBuilder();
-        buffer.append(startExclusive ? "(" : "[");
-        buffer.append(startVersion);
-        if (endVersion == null) {
-            buffer.append(",)");
-        } else if (!endExclusive || startVersion.equals(endVersion)) {
-            buffer.append(",");
-            buffer.append(endVersion.withNudgedPatch());
-            buffer.append(")");
-        } else {
-            buffer.append(",");
-            buffer.append(endVersion);
-            buffer.append(")");
+        buffer.append(startExclusive ? "(" : "[").append(startVersion).append(",");
+        if (endVersion != null) {
+            if (!endExclusive || startVersion.equals(endVersion)) {
+                buffer.append(endVersion.withNudgedPatch());
+            } else {
+                buffer.append(endVersion);
+            }
         }
-        return buffer.toString();
+        return buffer.append(")").toString();
     }
 
     public boolean isEndExclusive() {

http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/0c0845e9/src/java/org/apache/ivy/plugins/resolver/BasicResolver.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/ivy/plugins/resolver/BasicResolver.java b/src/java/org/apache/ivy/plugins/resolver/BasicResolver.java
index c2f24d2..8ddfc7d 100644
--- a/src/java/org/apache/ivy/plugins/resolver/BasicResolver.java
+++ b/src/java/org/apache/ivy/plugins/resolver/BasicResolver.java
@@ -585,50 +585,54 @@ public abstract class BasicResolver extends AbstractResolver {
         boolean ok = true;
         StringBuilder errors = new StringBuilder();
         if (!mrid.getOrganisation().equals(md.getModuleRevisionId().getOrganisation())) {
-            Message.error("\t" + getName() + ": bad organisation found in " + ivyRef.getResource()
-                    + ": expected='" + mrid.getOrganisation() + "' found='"
-                    + md.getModuleRevisionId().getOrganisation() + "'");
-            errors.append("bad organisation: expected='").append(mrid.getOrganisation()).append("'
found='").append(md.getModuleRevisionId().getOrganisation()).append("'; ");
+            Message.error(String.format("\t%s: bad organisation found in %s: expected='%s'
found='%s'",
+                    getName(), ivyRef.getResource(), mrid.getOrganisation(),
+                    md.getModuleRevisionId().getOrganisation()));
+            errors.append("bad organisation: expected='").append(mrid.getOrganisation())
+                    .append("' found='").append(md.getModuleRevisionId().getOrganisation()).append("';
");
             ok = false;
         }
         if (!mrid.getName().equals(md.getModuleRevisionId().getName())) {
-            Message.error("\t" + getName() + ": bad module name found in " + ivyRef.getResource()
-                    + ": expected='" + mrid.getName() + " found='"
-                    + md.getModuleRevisionId().getName() + "'");
-            errors.append("bad module name: expected='").append(mrid.getName()).append("'
found='").append(md.getModuleRevisionId().getName()).append("'; ");
+            Message.error(String.format("\t%s: bad module name found in %s: expected='%s
found='%s'",
+                    getName(), ivyRef.getResource(), mrid.getName(),
+                    md.getModuleRevisionId().getName()));
+            errors.append("bad module name: expected='").append(mrid.getName()).append("'
found='")
+                    .append(md.getModuleRevisionId().getName()).append("'; ");
             ok = false;
         }
         if (mrid.getBranch() != null
                 && !mrid.getBranch().equals(md.getModuleRevisionId().getBranch()))
{
-            Message.error("\t" + getName() + ": bad branch name found in " + ivyRef.getResource()
-                    + ": expected='" + mrid.getBranch() + " found='"
-                    + md.getModuleRevisionId().getBranch() + "'");
-            errors.append("bad branch name: expected='").append(mrid.getBranch()).append("'
found='").append(md.getModuleRevisionId().getBranch()).append("'; ");
+            Message.error(String.format("\t%s: bad branch name found in %s: expected='%s
found='%s'",
+                    getName(), ivyRef.getResource(), mrid.getBranch(),
+                    md.getModuleRevisionId().getBranch()));
+            errors.append("bad branch name: expected='").append(mrid.getBranch()).append("'
found='")
+                    .append(md.getModuleRevisionId().getBranch()).append("'; ");
             ok = false;
         }
         if (ivyRef.getRevision() != null && !ivyRef.getRevision().startsWith("working@")
                 && !mrid.getRevision().equals(md.getModuleRevisionId().getRevision()))
{
             ModuleRevisionId expectedMrid = ModuleRevisionId.newInstance(mrid, mrid.getRevision());
             if (!getSettings().getVersionMatcher().accept(expectedMrid, md)) {
-                Message.error("\t" + getName() + ": bad revision found in " + ivyRef.getResource()
-                        + ": expected='" + ivyRef.getRevision() + " found='"
-                        + md.getModuleRevisionId().getRevision() + "'");
-                errors.append("bad revision: expected='").append(ivyRef.getRevision()).append("'
found='").append(md.getModuleRevisionId().getRevision()).append("'; ");
+                Message.error(String.format("\t%s: bad revision found in %s: expected='%s
found='%s'",
+                        getName(), ivyRef.getResource(), ivyRef.getRevision(),
+                        md.getModuleRevisionId().getRevision()));
+                errors.append("bad revision: expected='").append(ivyRef.getRevision())
+                        .append("' found='").append(md.getModuleRevisionId().getRevision()).append("';
");
                 ok = false;
             }
         }
         if (!getSettings().getStatusManager().isStatus(md.getStatus())) {
-            Message.error("\t" + getName() + ": bad status found in " + ivyRef.getResource()
-                    + ": '" + md.getStatus() + "'");
+            Message.error(String.format("\t%s: bad status found in %s: '%s'",
+                    getName(), ivyRef.getResource(), md.getStatus()));
             errors.append("bad status: '").append(md.getStatus()).append("'; ");
             ok = false;
         }
         for (Map.Entry<String, String> extra : mrid.getExtraAttributes().entrySet())
{
             if (extra.getValue() != null
                     && !extra.getValue().equals(md.getExtraAttribute(extra.getKey())))
{
-                String errorMsg = "bad " + extra.getKey() + " found in " + ivyRef.getResource()
-                        + ": expected='" + extra.getValue() + "' found='"
-                        + md.getExtraAttribute(extra.getKey()) + "'";
+                String errorMsg = String.format("bad %s found in %s: expected='%s' found='%s'",
+                        extra.getKey(), ivyRef.getResource(), extra.getValue(),
+                        md.getExtraAttribute(extra.getKey()));
                 Message.error("\t" + getName() + ": " + errorMsg);
                 errors.append(errorMsg).append(";");
                 ok = false;

http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/0c0845e9/src/java/org/apache/ivy/util/HexEncoder.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/ivy/util/HexEncoder.java b/src/java/org/apache/ivy/util/HexEncoder.java
index 5b6f78d..c4eb27e 100644
--- a/src/java/org/apache/ivy/util/HexEncoder.java
+++ b/src/java/org/apache/ivy/util/HexEncoder.java
@@ -30,8 +30,7 @@ public class HexEncoder {
         for (byte bt : packet) {
             int highBits = (bt & 0xF0) >> 4;
             int lowBits = bt & 0x0F;
-            chars.append(ALPHABET[highBits]);
-            chars.append(ALPHABET[lowBits]);
+            chars.append(ALPHABET[highBits]).append(ALPHABET[lowBits]);
         }
         return chars.toString();
     }


Mime
View raw message