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 ma...@apache.org on 2007/06/28 10:13:12 UTC
svn commit: r551525 - in
/incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/version:
AbstractVersionMatcher.java Match.java PatternVersionMatcher.java
VersionRangeMatcher.java
Author: maartenc
Date: Thu Jun 28 03:13:11 2007
New Revision: 551525
URL: http://svn.apache.org/viewvc?view=rev&rev=551525
Log:
code style
Modified:
incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/version/AbstractVersionMatcher.java
incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/version/Match.java
incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/version/PatternVersionMatcher.java
incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/version/VersionRangeMatcher.java
Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/version/AbstractVersionMatcher.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/version/AbstractVersionMatcher.java?view=diff&rev=551525&r1=551524&r2=551525
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/version/AbstractVersionMatcher.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/version/AbstractVersionMatcher.java Thu Jun 28 03:13:11 2007
@@ -26,7 +26,7 @@
import org.apache.ivy.util.Checks;
public abstract class AbstractVersionMatcher implements VersionMatcher, IvySettingsAware {
- private String _name;
+ private String name;
private IvySettings settings;
@@ -34,15 +34,15 @@
}
public AbstractVersionMatcher(String name) {
- _name = name;
+ this.name = name;
}
public String getName() {
- return _name;
+ return name;
}
public void setName(String name) {
- _name = name;
+ this.name = name;
}
public boolean needModuleDescriptor(ModuleRevisionId askedMrid, ModuleRevisionId foundMrid) {
Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/version/Match.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/version/Match.java?view=diff&rev=551525&r1=551524&r2=551525
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/version/Match.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/version/Match.java Thu Jun 28 03:13:11 2007
@@ -33,44 +33,44 @@
*
*/
public class Match {
- private String _revision;
+ private String revision;
- private String _pattern;
+ private String pattern;
- private String _args;
+ private String args;
- private String _matcher;
+ private String matcher;
public String getArgs() {
- return _args;
+ return args;
}
public void setArgs(String args) {
- this._args = args;
+ this.args = args;
}
public String getMatcher() {
- return _matcher;
+ return matcher;
}
public void setMatcher(String matcher) {
- this._matcher = matcher;
+ this.matcher = matcher;
}
public String getPattern() {
- return _pattern;
+ return pattern;
}
public void setPattern(String pattern) {
- this._pattern = pattern;
+ this.pattern = pattern;
}
public String getRevision() {
- return _revision;
+ return revision;
}
public void setRevision(String revision) {
- this._revision = revision;
+ this.revision = revision;
}
public Matcher getPatternMatcher(ModuleRevisionId askedMrid) {
@@ -91,7 +91,7 @@
String pattern = getPattern();
pattern = IvyPatternHelper.substituteVariables(pattern, variables);
- PatternMatcher pMatcher = IvyContext.getContext().getSettings().getMatcher(_matcher);
+ PatternMatcher pMatcher = IvyContext.getContext().getSettings().getMatcher(matcher);
return pMatcher.getMatcher(pattern);
}
Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/version/PatternVersionMatcher.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/version/PatternVersionMatcher.java?view=diff&rev=551525&r1=551524&r2=551525
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/version/PatternVersionMatcher.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/version/PatternVersionMatcher.java Thu Jun 28 03:13:11 2007
@@ -31,28 +31,28 @@
*/
public class PatternVersionMatcher extends AbstractVersionMatcher {
- private List _matches = new ArrayList();
+ private List matches = new ArrayList();
- private Map _revisionMatches = new HashMap(); // revision -> list of Match instances
+ private Map revisionMatches = new HashMap(); // revision -> list of Match instances
- private boolean _init = false;
+ private boolean init = false;
public void addMatch(Match match) {
- _matches.add(match);
+ matches.add(match);
}
private void init() {
- if (!_init) {
- for (Iterator it = _matches.iterator(); it.hasNext();) {
+ if (!init) {
+ for (Iterator it = matches.iterator(); it.hasNext();) {
Match match = (Match) it.next();
- List matches = (List) _revisionMatches.get(match.getRevision());
- if (matches == null) {
- matches = new ArrayList();
- _revisionMatches.put(match.getRevision(), matches);
+ List revMatches = (List) revisionMatches.get(match.getRevision());
+ if (revMatches == null) {
+ revMatches = new ArrayList();
+ revisionMatches.put(match.getRevision(), revMatches);
}
- matches.add(match);
+ revMatches.add(match);
}
- _init = true;
+ init = true;
}
}
@@ -69,10 +69,10 @@
revision = revision.substring(0, bracketIndex);
}
- List matches = (List) _revisionMatches.get(revision);
+ List revMatches = (List) revisionMatches.get(revision);
- if (matches != null) {
- Iterator it = matches.iterator();
+ if (revMatches != null) {
+ Iterator it = revMatches.iterator();
while (!accept && it.hasNext()) {
Match match = (Match) it.next();
Matcher matcher = match.getPatternMatcher(askedMrid);
@@ -93,7 +93,7 @@
if (bracketIndex > 0) {
revision = revision.substring(0, bracketIndex);
}
- return _revisionMatches.containsKey(revision);
+ return revisionMatches.containsKey(revision);
}
}
Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/version/VersionRangeMatcher.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/version/VersionRangeMatcher.java?view=diff&rev=551525&r1=551524&r2=551525
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/version/VersionRangeMatcher.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/version/VersionRangeMatcher.java Thu Jun 28 03:13:11 2007
@@ -39,66 +39,66 @@
*/
public class VersionRangeMatcher extends AbstractVersionMatcher {
// todo: check these constants
- private final static String OPEN_INC = "[";
+ private static final String OPEN_INC = "[";
- private final static String OPEN_EXC = "]";
+ private static final String OPEN_EXC = "]";
- private final static String CLOSE_INC = "]";
+ private static final String CLOSE_INC = "]";
- private final static String CLOSE_EXC = "[";
+ private static final String CLOSE_EXC = "[";
- private final static String LOWER_INFINITE = "(";
+ private static final String LOWER_INFINITE = "(";
- private final static String UPPER_INFINITE = ")";
+ private static final String UPPER_INFINITE = ")";
- private final static String SEPARATOR = ",";
+ private static final String SEPARATOR = ",";
// following patterns are built upon constants above and should not be modified
- private final static String OPEN_INC_PATTERN = "\\" + OPEN_INC;
+ private static final String OPEN_INC_PATTERN = "\\" + OPEN_INC;
- private final static String OPEN_EXC_PATTERN = "\\" + OPEN_EXC;
+ private static final String OPEN_EXC_PATTERN = "\\" + OPEN_EXC;
- private final static String CLOSE_INC_PATTERN = "\\" + CLOSE_INC;
+ private static final String CLOSE_INC_PATTERN = "\\" + CLOSE_INC;
- private final static String CLOSE_EXC_PATTERN = "\\" + CLOSE_EXC;
+ private static final String CLOSE_EXC_PATTERN = "\\" + CLOSE_EXC;
- private final static String LI_PATTERN = "\\" + LOWER_INFINITE;
+ private static final String LI_PATTERN = "\\" + LOWER_INFINITE;
- private final static String UI_PATTERN = "\\" + UPPER_INFINITE;
+ private static final String UI_PATTERN = "\\" + UPPER_INFINITE;
- private final static String SEP_PATTERN = "\\s*\\" + SEPARATOR + "\\s*";
+ private static final String SEP_PATTERN = "\\s*\\" + SEPARATOR + "\\s*";
- private final static String OPEN_PATTERN = "[" + OPEN_INC_PATTERN + OPEN_EXC_PATTERN + "]";
+ private static final String OPEN_PATTERN = "[" + OPEN_INC_PATTERN + OPEN_EXC_PATTERN + "]";
- private final static String CLOSE_PATTERN = "[" + CLOSE_INC_PATTERN + CLOSE_EXC_PATTERN + "]";
+ private static final String CLOSE_PATTERN = "[" + CLOSE_INC_PATTERN + CLOSE_EXC_PATTERN + "]";
- private final static String ANY_NON_SPECIAL_PATTERN = "[^\\s" + SEPARATOR + OPEN_INC_PATTERN
+ private static final String ANY_NON_SPECIAL_PATTERN = "[^\\s" + SEPARATOR + OPEN_INC_PATTERN
+ OPEN_EXC_PATTERN + CLOSE_INC_PATTERN + CLOSE_EXC_PATTERN + LI_PATTERN + UI_PATTERN
+ "]";
- private final static String FINITE_PATTERN = OPEN_PATTERN + "\\s*(" + ANY_NON_SPECIAL_PATTERN
+ private static final String FINITE_PATTERN = OPEN_PATTERN + "\\s*(" + ANY_NON_SPECIAL_PATTERN
+ "+)" + SEP_PATTERN + "(" + ANY_NON_SPECIAL_PATTERN + "+)\\s*" + CLOSE_PATTERN;
- private final static String LOWER_INFINITE_PATTERN = LI_PATTERN + SEP_PATTERN + "("
+ private static final String LOWER_INFINITE_PATTERN = LI_PATTERN + SEP_PATTERN + "("
+ ANY_NON_SPECIAL_PATTERN + "+)\\s*" + CLOSE_PATTERN;
- private final static String UPPER_INFINITE_PATTERN = OPEN_PATTERN + "\\s*("
+ private static final String UPPER_INFINITE_PATTERN = OPEN_PATTERN + "\\s*("
+ ANY_NON_SPECIAL_PATTERN + "+)" + SEP_PATTERN + UI_PATTERN;
- private final static Pattern FINITE_RANGE = Pattern.compile(FINITE_PATTERN);
+ private static final Pattern FINITE_RANGE = Pattern.compile(FINITE_PATTERN);
- private final static Pattern LOWER_INFINITE_RANGE = Pattern.compile(LOWER_INFINITE_PATTERN);
+ private static final Pattern LOWER_INFINITE_RANGE = Pattern.compile(LOWER_INFINITE_PATTERN);
- private final static Pattern UPPER_INFINITE_RANGE = Pattern.compile(UPPER_INFINITE_PATTERN);
+ private static final Pattern UPPER_INFINITE_RANGE = Pattern.compile(UPPER_INFINITE_PATTERN);
- private final static Pattern ALL_RANGE = Pattern.compile(FINITE_PATTERN + "|"
+ private static final Pattern ALL_RANGE = Pattern.compile(FINITE_PATTERN + "|"
+ LOWER_INFINITE_PATTERN + "|" + UPPER_INFINITE_PATTERN);
private final class MRIDArtifactInfo implements ArtifactInfo {
- private ModuleRevisionId _mrid;
+ private ModuleRevisionId mrid;
public MRIDArtifactInfo(ModuleRevisionId id) {
- _mrid = id;
+ mrid = id;
}
public long getLastModified() {
@@ -106,11 +106,11 @@
}
public String getRevision() {
- return _mrid.getRevision();
+ return mrid.getRevision();
}
}
- private final Comparator COMPARATOR = new Comparator() {
+ private final Comparator comparator = new Comparator() {
public int compare(Object o1, Object o2) {
if (o1.equals(o2)) {
return 0;
@@ -123,9 +123,9 @@
}
};
- private LatestStrategy _latestStrategy;
+ private LatestStrategy latestStrategy;
- private String _latestStrategyName = "default";
+ private String latestStrategyName = "default";
public VersionRangeMatcher() {
super("version-range");
@@ -137,7 +137,7 @@
public VersionRangeMatcher(String name, LatestStrategy strategy) {
super(name);
- _latestStrategy = strategy;
+ this.latestStrategy = strategy;
}
public boolean isDynamic(ModuleRevisionId askedMrid) {
@@ -170,14 +170,16 @@
private boolean isLower(ModuleRevisionId askedMrid, String revision,
ModuleRevisionId foundMrid, boolean inclusive) {
- return COMPARATOR.compare(ModuleRevisionId.newInstance(askedMrid, revision), foundMrid) <= (inclusive ? 0
- : -1);
+ ModuleRevisionId mRevId = ModuleRevisionId.newInstance(askedMrid, revision);
+ int result = comparator.compare(mRevId, foundMrid);
+ return result <= (inclusive ? 0 : -1);
}
private boolean isUpper(ModuleRevisionId askedMrid, String revision,
ModuleRevisionId foundMrid, boolean inclusive) {
- return COMPARATOR.compare(ModuleRevisionId.newInstance(askedMrid, revision), foundMrid) >= (inclusive ? 0
- : 1);
+ ModuleRevisionId mRevId = ModuleRevisionId.newInstance(askedMrid, revision);
+ int result = comparator.compare(mRevId, foundMrid);
+ return result >= (inclusive ? 0 : 1);
}
public int compare(ModuleRevisionId askedMrid, ModuleRevisionId foundMrid,
@@ -210,31 +212,31 @@
}
public LatestStrategy getLatestStrategy() {
- if (_latestStrategy == null) {
+ if (latestStrategy == null) {
if (getSettings() == null) {
throw new IllegalStateException(
"no ivy instance nor latest strategy configured in version range matcher "
+ this);
}
- if (_latestStrategyName == null) {
+ if (latestStrategyName == null) {
throw new IllegalStateException(
"null latest strategy defined in version range matcher " + this);
}
- _latestStrategy = getSettings().getLatestStrategy(_latestStrategyName);
- if (_latestStrategy == null) {
- throw new IllegalStateException("unknown latest strategy '" + _latestStrategyName
+ latestStrategy = getSettings().getLatestStrategy(latestStrategyName);
+ if (latestStrategy == null) {
+ throw new IllegalStateException("unknown latest strategy '" + latestStrategyName
+ "' configured in version range matcher " + this);
}
}
- return _latestStrategy;
+ return latestStrategy;
}
public void setLatestStrategy(LatestStrategy latestStrategy) {
- _latestStrategy = latestStrategy;
+ this.latestStrategy = latestStrategy;
}
public void setLatest(String latestStrategyName) {
- _latestStrategyName = latestStrategyName;
+ this.latestStrategyName = latestStrategyName;
}
}