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/05 12:02:43 UTC
svn commit: r544459 [8/36] - in /incubator/ivy/core/trunk:
src/java/org/apache/ivy/ src/java/org/apache/ivy/ant/
src/java/org/apache/ivy/core/ src/java/org/apache/ivy/core/cache/
src/java/org/apache/ivy/core/check/ src/java/org/apache/ivy/core/deliver/...
Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/core/module/descriptor/DefaultDependencyDescriptor.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/core/module/descriptor/DefaultDependencyDescriptor.java?view=diff&rev=544459&r1=544458&r2=544459
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/core/module/descriptor/DefaultDependencyDescriptor.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/core/module/descriptor/DefaultDependencyDescriptor.java Tue Jun 5 05:02:27 2007
@@ -38,25 +38,21 @@
import org.apache.ivy.plugins.namespace.Namespace;
import org.apache.ivy.plugins.namespace.NamespaceTransformer;
-
/**
- * This class can be used as the default implementation for DependencyDescriptor.
- * It implements required methods and enables to fill dependency information
- * with the addDependencyConfiguration method.
- *
- *
+ * This class can be used as the default implementation for DependencyDescriptor. It implements
+ * required methods and enables to fill dependency information with the addDependencyConfiguration
+ * method.
*/
public class DefaultDependencyDescriptor implements DependencyDescriptor {
private static final Pattern SELF_FALLBACK_PATTERN = Pattern.compile("@(\\(.*\\))?");
+
private static final Pattern THIS_FALLBACK_PATTERN = Pattern.compile("#(\\(.*\\))?");
-
+
/**
- * Transforms the given dependency descriptor of the given namespace and return
- * a new dependency descriptor in the system namespace.
- *
- * <i>Note that exclude rules are not converted in system namespace, because they aren't
- * transformable (the name space hasn't the ability to convert regular expressions).
- * However, method doesExclude will work with system artifacts.</i>
+ * Transforms the given dependency descriptor of the given namespace and return a new dependency
+ * descriptor in the system namespace. <i>Note that exclude rules are not converted in system
+ * namespace, because they aren't transformable (the name space hasn't the ability to convert
+ * regular expressions). However, method doesExclude will work with system artifacts.</i>
*
* @param md
* @param ns
@@ -71,75 +67,98 @@
newdd._namespace = ns;
return newdd;
}
-
+
/**
- * Transforms a dependency descriptor using the given transformer.
+ * Transforms a dependency descriptor using the given transformer. Note that no namespace info
+ * will be attached to the transformed dependency descriptor, so calling doesExclude is not
+ * recommended (doesExclude only works when namespace is properly set)
*
- * Note that no namespace info will be attached to the transformed dependency descriptor,
- * so calling doesExclude is not recommended (doesExclude only works when namespace is properly set)
* @param dd
* @param t
* @return
*/
- public static DefaultDependencyDescriptor transformInstance(DependencyDescriptor dd, NamespaceTransformer t, boolean fromSystem) {
+ public static DefaultDependencyDescriptor transformInstance(DependencyDescriptor dd,
+ NamespaceTransformer t, boolean fromSystem) {
ModuleRevisionId transformParentId = t.transform(dd.getParentRevisionId());
ModuleRevisionId transformMrid = t.transform(dd.getDependencyRevisionId());
- DefaultDependencyDescriptor newdd = new DefaultDependencyDescriptor(null, transformMrid, dd.isForce(), dd.isChanging(), dd.isTransitive());
+ DefaultDependencyDescriptor newdd = new DefaultDependencyDescriptor(null, transformMrid, dd
+ .isForce(), dd.isChanging(), dd.isTransitive());
newdd._parentId = transformParentId;
String[] moduleConfs = dd.getModuleConfigurations();
if (moduleConfs.length == 1 && "*".equals(moduleConfs[0])) {
if (dd instanceof DefaultDependencyDescriptor) {
- DefaultDependencyDescriptor ddd = (DefaultDependencyDescriptor)dd;
+ DefaultDependencyDescriptor ddd = (DefaultDependencyDescriptor) dd;
newdd._confs = new LinkedHashMap(ddd._confs);
newdd._excludeRules = new LinkedHashMap(ddd._excludeRules);
newdd._includeRules = new LinkedHashMap(ddd._includeRules);
newdd._dependencyArtifacts = new LinkedHashMap(ddd._dependencyArtifacts);
} else {
- throw new IllegalArgumentException("dependency descriptor transformation does not support * module confs with descriptors which aren't DefaultDependencyDescriptor");
+ throw new IllegalArgumentException(
+ "dependency descriptor transformation does not support * module confs with descriptors which aren't DefaultDependencyDescriptor");
}
} else {
for (int i = 0; i < moduleConfs.length; i++) {
- newdd._confs.put(moduleConfs[i], new ArrayList(Arrays.asList(dd.getDependencyConfigurations(moduleConfs[i]))));
- newdd._excludeRules.put(moduleConfs[i], new ArrayList(Arrays.asList(dd.getExcludeRules(moduleConfs[i]))));
- newdd._includeRules.put(moduleConfs[i], new ArrayList(Arrays.asList(dd.getIncludeRules(moduleConfs[i]))));
- newdd._dependencyArtifacts.put(moduleConfs[i], new ArrayList(Arrays.asList(dd.getDependencyArtifacts(moduleConfs[i]))));
+ newdd._confs.put(moduleConfs[i], new ArrayList(Arrays.asList(dd
+ .getDependencyConfigurations(moduleConfs[i]))));
+ newdd._excludeRules.put(moduleConfs[i], new ArrayList(Arrays.asList(dd
+ .getExcludeRules(moduleConfs[i]))));
+ newdd._includeRules.put(moduleConfs[i], new ArrayList(Arrays.asList(dd
+ .getIncludeRules(moduleConfs[i]))));
+ newdd._dependencyArtifacts.put(moduleConfs[i], new ArrayList(Arrays.asList(dd
+ .getDependencyArtifacts(moduleConfs[i]))));
}
}
if (fromSystem) {
- newdd._asSystem = dd;
+ newdd._asSystem = dd;
}
return newdd;
}
-
+
private ModuleRevisionId _revId;
+
private Map _confs = new LinkedHashMap();
- private Map _dependencyArtifacts = new LinkedHashMap(); // Map (String masterConf -> Collection(DependencyArtifactDescriptor))
- private Map _includeRules = new LinkedHashMap(); // Map (String masterConf -> Collection(IncludeRule))
- private Map _excludeRules = new LinkedHashMap(); // Map (String masterConf -> Collection(ExcludeRule))
+
+ private Map _dependencyArtifacts = new LinkedHashMap(); // Map (String masterConf ->
+
+ // Collection(DependencyArtifactDescriptor))
+
+ private Map _includeRules = new LinkedHashMap(); // Map (String masterConf ->
+
+ // Collection(IncludeRule))
+
+ private Map _excludeRules = new LinkedHashMap(); // Map (String masterConf ->
+
+ // Collection(ExcludeRule))
+
private Set _extends = new LinkedHashSet();
-
+
/**
- * Used to indicate that this revision must be used in case of conflicts, independently
- * of conflicts manager
+ * Used to indicate that this revision must be used in case of conflicts, independently of
+ * conflicts manager
*/
private boolean _force;
+
/**
- * Used to indicate that the dependency is a changing one, i.e. that ivy should not rely on the version to know if it can trust artifacts in cache
+ * Used to indicate that the dependency is a changing one, i.e. that ivy should not rely on the
+ * version to know if it can trust artifacts in cache
*/
- private boolean _changing;
+ private boolean _changing;
+
private ModuleRevisionId _parentId;
-
+
private boolean _transitive = true;
-
+
/**
- * This namespace should be used to check
+ * This namespace should be used to check
*/
private Namespace _namespace = null;
+
private final ModuleDescriptor _md;
- private DependencyDescriptor _asSystem = this;
-
+
+ private DependencyDescriptor _asSystem = this;
+
public DefaultDependencyDescriptor(DependencyDescriptor dd, String revision) {
- _md = null;
+ _md = null;
_parentId = dd.getParentRevisionId();
_revId = ModuleRevisionId.newInstance(dd.getDependencyRevisionId(), revision);
_force = dd.isForce();
@@ -147,68 +166,69 @@
_transitive = dd.isTransitive();
String[] moduleConfs = dd.getModuleConfigurations();
for (int i = 0; i < moduleConfs.length; i++) {
- _confs.put(moduleConfs[i], new ArrayList(Arrays.asList(dd.getDependencyConfigurations(moduleConfs[i]))));
- _excludeRules.put(moduleConfs[i], new ArrayList(Arrays.asList(dd.getExcludeRules(moduleConfs[i]))));
- _includeRules.put(moduleConfs[i], new ArrayList(Arrays.asList(dd.getIncludeRules(moduleConfs[i]))));
+ _confs.put(moduleConfs[i], new ArrayList(Arrays.asList(dd
+ .getDependencyConfigurations(moduleConfs[i]))));
+ _excludeRules.put(moduleConfs[i], new ArrayList(Arrays.asList(dd
+ .getExcludeRules(moduleConfs[i]))));
+ _includeRules.put(moduleConfs[i], new ArrayList(Arrays.asList(dd
+ .getIncludeRules(moduleConfs[i]))));
}
}
-
- public DefaultDependencyDescriptor(ModuleDescriptor md, ModuleRevisionId mrid, boolean force, boolean changing, boolean transitive) {
+
+ public DefaultDependencyDescriptor(ModuleDescriptor md, ModuleRevisionId mrid, boolean force,
+ boolean changing, boolean transitive) {
_md = md;
_revId = mrid;
_force = force;
_changing = changing;
_transitive = transitive;
}
-
+
public DefaultDependencyDescriptor(ModuleRevisionId mrid, boolean force) {
this(mrid, force, false);
}
-
+
public DefaultDependencyDescriptor(ModuleRevisionId mrid, boolean force, boolean changing) {
- _md = null;
+ _md = null;
_revId = mrid;
_force = force;
_changing = changing;
}
-
-
+
public ModuleId getDependencyId() {
return getDependencyRevisionId().getModuleId();
}
-
+
public ModuleRevisionId getDependencyRevisionId() {
return _revId;
}
-
+
public String[] getModuleConfigurations() {
return (String[]) _confs.keySet().toArray(new String[_confs.keySet().size()]);
}
-
+
public String[] getDependencyConfigurations(String moduleConfiguration) {
return getDependencyConfigurations(moduleConfiguration, moduleConfiguration);
}
-
+
/**
- * Return the dependency configurations mapped to the given moduleConfiguration, actually resolved
- * because of the given requestedConfiguration
- *
- * Usually requestedConfiguration and moduleConfiguration are the same, except when
- * a conf extends another, then the moduleConfiguration is the configuration currently resolved
- * (the extended one), and requestedConfiguration is the one actually requested initially (the
- * extending one).
- *
- * Both moduleConfiguration and requestedConfiguration are configurations of the caller,
- * the array returned is composed of the required configurations of the dependency described by this
+ * Return the dependency configurations mapped to the given moduleConfiguration, actually
+ * resolved because of the given requestedConfiguration Usually requestedConfiguration and
+ * moduleConfiguration are the same, except when a conf extends another, then the
+ * moduleConfiguration is the configuration currently resolved (the extended one), and
+ * requestedConfiguration is the one actually requested initially (the extending one). Both
+ * moduleConfiguration and requestedConfiguration are configurations of the caller, the array
+ * returned is composed of the required configurations of the dependency described by this
* descriptor.
*/
- public String[] getDependencyConfigurations(String moduleConfiguration, String requestedConfiguration) {
- List confs = (List)_confs.get(moduleConfiguration);
+ public String[] getDependencyConfigurations(String moduleConfiguration,
+ String requestedConfiguration) {
+ List confs = (List) _confs.get(moduleConfiguration);
if (confs == null) {
// there is no mapping defined for this configuration, add the 'other' mappings.
- confs = (List)_confs.get("%");
+ confs = (List) _confs.get("%");
}
- List defConfs = (List)_confs.get("*");
+ List defConfs = (List) _confs.get("*");
Collection ret = new LinkedHashSet();
if (confs != null) {
ret.addAll(confs);
@@ -216,15 +236,15 @@
if (defConfs != null) {
ret.addAll(defConfs);
}
-
+
Collection replacedRet = new LinkedHashSet();
for (Iterator iter = ret.iterator(); iter.hasNext();) {
- String c = (String)iter.next();
- String replacedConf = replaceSelfFallbackPattern( c, moduleConfiguration);
- if (replacedConf==null) {
- replacedConf = replaceThisFallbackPattern( c, requestedConfiguration);
+ String c = (String) iter.next();
+ String replacedConf = replaceSelfFallbackPattern(c, moduleConfiguration);
+ if (replacedConf == null) {
+ replacedConf = replaceThisFallbackPattern(c, requestedConfiguration);
}
- if (replacedConf!=null) {
+ if (replacedConf != null) {
c = replacedConf;
}
replacedRet.add(c);
@@ -234,43 +254,51 @@
StringBuffer r = new StringBuffer("*");
// merge excluded configurations as one conf like *!A!B
for (Iterator iter = ret.iterator(); iter.hasNext();) {
- String c = (String)iter.next();
+ String c = (String) iter.next();
if (c.startsWith("!")) {
r.append(c);
}
}
return new String[] {r.toString()};
}
- return (String[])ret.toArray(new String[ret.size()]);
+ return (String[]) ret.toArray(new String[ret.size()]);
}
-
- protected static String replaceSelfFallbackPattern(final String conf, final String moduleConfiguration) {
+
+ protected static String replaceSelfFallbackPattern(final String conf,
+ final String moduleConfiguration) {
return replaceFallbackConfigurationPattern(SELF_FALLBACK_PATTERN, conf, moduleConfiguration);
}
-
- protected static String replaceThisFallbackPattern(final String conf, final String requestedConfiguration) {
- return replaceFallbackConfigurationPattern(THIS_FALLBACK_PATTERN, conf, requestedConfiguration);
+
+ protected static String replaceThisFallbackPattern(final String conf,
+ final String requestedConfiguration) {
+ return replaceFallbackConfigurationPattern(THIS_FALLBACK_PATTERN, conf,
+ requestedConfiguration);
}
-
+
/**
* Replaces fallback patterns with correct values if fallback pattern exists.
- * @param pattern pattern to look for
- * @param conf configuration mapping from dependency element
- * @param moduleConfiguration module's configuration to use for replacement
+ *
+ * @param pattern
+ * pattern to look for
+ * @param conf
+ * configuration mapping from dependency element
+ * @param moduleConfiguration
+ * module's configuration to use for replacement
* @return Replaced string if pattern matched. Otherwise null.
*/
- protected static String replaceFallbackConfigurationPattern(final Pattern pattern, final String conf, final String moduleConfiguration) {
+ protected static String replaceFallbackConfigurationPattern(final Pattern pattern,
+ final String conf, final String moduleConfiguration) {
Matcher matcher = pattern.matcher(conf);
if (matcher.matches()) {
if (matcher.group(1) != null) {
- return moduleConfiguration+matcher.group(1);
+ return moduleConfiguration + matcher.group(1);
} else {
return moduleConfiguration;
}
}
return null;
}
-
+
public String[] getDependencyConfigurations(String[] moduleConfigurations) {
Set confs = new LinkedHashSet();
for (int i = 0; i < moduleConfigurations.length; i++) {
@@ -281,28 +309,30 @@
}
return (String[]) confs.toArray(new String[confs.size()]);
}
-
+
public DependencyArtifactDescriptor[] getDependencyArtifacts(String moduleConfiguration) {
- Collection artifacts = getCollectionForConfiguration(moduleConfiguration, _dependencyArtifacts);
- return (DependencyArtifactDescriptor[]) artifacts.toArray(new DependencyArtifactDescriptor[artifacts.size()]);
+ Collection artifacts = getCollectionForConfiguration(moduleConfiguration,
+ _dependencyArtifacts);
+ return (DependencyArtifactDescriptor[]) artifacts
+ .toArray(new DependencyArtifactDescriptor[artifacts.size()]);
}
-
+
public IncludeRule[] getIncludeRules(String moduleConfiguration) {
Collection rules = getCollectionForConfiguration(moduleConfiguration, _includeRules);
return (IncludeRule[]) rules.toArray(new IncludeRule[rules.size()]);
}
-
+
public ExcludeRule[] getExcludeRules(String moduleConfiguration) {
Collection rules = getCollectionForConfiguration(moduleConfiguration, _excludeRules);
return (ExcludeRule[]) rules.toArray(new ExcludeRule[rules.size()]);
}
-
- private Set getCollectionForConfiguration(String moduleConfiguration, Map collectionMap) {
- if (collectionMap.isEmpty()) {
+
+ private Set getCollectionForConfiguration(String moduleConfiguration, Map collectionMap) {
+ if (collectionMap.isEmpty()) {
return Collections.EMPTY_SET;
}
- Collection artifacts = (Collection)collectionMap.get(moduleConfiguration);
- Collection defArtifacts = (Collection)collectionMap.get("*");
+ Collection artifacts = (Collection) collectionMap.get(moduleConfiguration);
+ Collection defArtifacts = (Collection) collectionMap.get("*");
Set ret = new LinkedHashSet();
if (artifacts != null) {
ret.addAll(artifacts);
@@ -310,17 +340,18 @@
if (defArtifacts != null) {
ret.addAll(defArtifacts);
}
- return ret;
- }
-
+ return ret;
+ }
+
public DependencyArtifactDescriptor[] getDependencyArtifacts(String[] moduleConfigurations) {
Set artifacts = new LinkedHashSet();
for (int i = 0; i < moduleConfigurations.length; i++) {
artifacts.addAll(Arrays.asList(getDependencyArtifacts(moduleConfigurations[i])));
}
- return (DependencyArtifactDescriptor[]) artifacts.toArray(new DependencyArtifactDescriptor[artifacts.size()]);
+ return (DependencyArtifactDescriptor[]) artifacts
+ .toArray(new DependencyArtifactDescriptor[artifacts.size()]);
}
-
+
public IncludeRule[] getIncludeRules(String[] moduleConfigurations) {
Set rules = new LinkedHashSet();
for (int i = 0; i < moduleConfigurations.length; i++) {
@@ -328,7 +359,7 @@
}
return (IncludeRule[]) rules.toArray(new IncludeRule[rules.size()]);
}
-
+
public ExcludeRule[] getExcludeRules(String[] moduleConfigurations) {
Set rules = new LinkedHashSet();
for (int i = 0; i < moduleConfigurations.length; i++) {
@@ -336,41 +367,42 @@
}
return (ExcludeRule[]) rules.toArray(new ExcludeRule[rules.size()]);
}
-
+
public DependencyArtifactDescriptor[] getAllDependencyArtifacts() {
Set ret = mergeAll(_dependencyArtifacts);
- return (DependencyArtifactDescriptor[]) ret.toArray(new DependencyArtifactDescriptor[ret.size()]);
+ return (DependencyArtifactDescriptor[]) ret.toArray(new DependencyArtifactDescriptor[ret
+ .size()]);
}
-
+
public IncludeRule[] getAllIncludeRules() {
Set ret = mergeAll(_includeRules);
- return (IncludeRule[]) ret.toArray(new IncludeRule[ret.size()]);
+ return (IncludeRule[]) ret.toArray(new IncludeRule[ret.size()]);
}
-
+
public ExcludeRule[] getAllExcludeRules() {
Set ret = mergeAll(_excludeRules);
- return (ExcludeRule[]) ret.toArray(new ExcludeRule[ret.size()]);
+ return (ExcludeRule[]) ret.toArray(new ExcludeRule[ret.size()]);
}
-
+
private Set mergeAll(Map artifactsMap) {
Set ret = new LinkedHashSet();
for (Iterator it = artifactsMap.values().iterator(); it.hasNext();) {
- Collection artifacts = (Collection)it.next();
+ Collection artifacts = (Collection) it.next();
ret.addAll(artifacts);
}
return ret;
}
-
+
public void addDependencyConfiguration(String masterConf, String depConf) {
- if ((_md != null) && !"*".equals(masterConf) && !"%".equals(masterConf)) {
- Configuration config = _md.getConfiguration(masterConf);
- if (config == null) {
- throw new IllegalArgumentException("Configuration '" + masterConf
- + "' does not exist in module " + _md);
- }
- }
-
- List confs = (List)_confs.get(masterConf);
+ if ((_md != null) && !"*".equals(masterConf) && !"%".equals(masterConf)) {
+ Configuration config = _md.getConfiguration(masterConf);
+ if (config == null) {
+ throw new IllegalArgumentException("Configuration '" + masterConf
+ + "' does not exist in module " + _md);
+ }
+ }
+
+ List confs = (List) _confs.get(masterConf);
if (confs == null) {
confs = new ArrayList();
_confs.put(masterConf, confs);
@@ -379,76 +411,79 @@
confs.add(depConf);
}
}
-
+
public void addDependencyArtifact(String masterConf, DependencyArtifactDescriptor dad) {
addObjectToConfiguration(masterConf, dad, _dependencyArtifacts);
}
-
+
public void addIncludeRule(String masterConf, IncludeRule rule) {
addObjectToConfiguration(masterConf, rule, _includeRules);
}
-
+
public void addExcludeRule(String masterConf, ExcludeRule rule) {
addObjectToConfiguration(masterConf, rule, _excludeRules);
}
-
+
private void addObjectToConfiguration(String callerConf, Object toAdd, Map confsMap) {
- Collection col = (Collection)confsMap.get(callerConf);
+ Collection col = (Collection) confsMap.get(callerConf);
if (col == null) {
col = new ArrayList();
confsMap.put(callerConf, col);
}
col.add(toAdd);
}
-
+
/**
- * only works when namespace is properly set. The behaviour is not specified if namespace is not set
+ * only works when namespace is properly set. The behaviour is not specified if namespace is not
+ * set
*/
public boolean doesExclude(String[] moduleConfigurations, ArtifactId artifactId) {
if (_namespace != null) {
- artifactId = NameSpaceHelper.transform(artifactId, _namespace.getFromSystemTransformer());
+ artifactId = NameSpaceHelper.transform(artifactId, _namespace
+ .getFromSystemTransformer());
}
ExcludeRule[] rules = getExcludeRules(moduleConfigurations);
for (int i = 0; i < rules.length; i++) {
if (MatcherHelper.matches(rules[i].getMatcher(), rules[i].getId(), artifactId)) {
return true;
}
- }
+ }
return false;
}
-
+
/**
* Returns true if this descriptor contains any exclusion rule
+ *
* @return
*/
public boolean canExclude() {
return !_excludeRules.isEmpty();
}
-
+
public void addExtends(String conf) {
_extends.add(conf);
}
-
+
public String toString() {
- return "dependency: "+_revId+" "+_confs;
+ return "dependency: " + _revId + " " + _confs;
}
-
+
public boolean isForce() {
return _force;
}
-
+
public ModuleRevisionId getParentRevisionId() {
return _md != null ? _md.getResolvedModuleRevisionId() : _parentId;
}
-
+
public boolean isChanging() {
return _changing;
}
-
+
public boolean isTransitive() {
return _transitive;
}
-
+
public Namespace getNamespace() {
return _namespace;
}
@@ -477,8 +512,8 @@
return _revId.getStandardAttributes();
}
- public DependencyDescriptor asSystem() {
- return _asSystem;
- }
-
+ public DependencyDescriptor asSystem() {
+ return _asSystem;
+ }
+
}
Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/core/module/descriptor/DefaultExcludeRule.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/core/module/descriptor/DefaultExcludeRule.java?view=diff&rev=544459&r1=544458&r2=544459
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/core/module/descriptor/DefaultExcludeRule.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/core/module/descriptor/DefaultExcludeRule.java Tue Jun 5 05:02:27 2007
@@ -22,15 +22,13 @@
import org.apache.ivy.core.module.id.ArtifactId;
import org.apache.ivy.plugins.matcher.PatternMatcher;
+public class DefaultExcludeRule extends AbstractIncludeExcludeRule implements ExcludeRule {
-public class DefaultExcludeRule extends AbstractIncludeExcludeRule
- implements ExcludeRule {
+ public DefaultExcludeRule(ArtifactId aid, PatternMatcher matcher, Map extraAttributes) {
+ super(aid, matcher, extraAttributes);
+ }
- public DefaultExcludeRule(ArtifactId aid, PatternMatcher matcher, Map extraAttributes) {
- super(aid, matcher, extraAttributes);
- }
-
- public String toString() {
- return "E:"+super.toString();
- }
+ public String toString() {
+ return "E:" + super.toString();
+ }
}
Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/core/module/descriptor/DefaultIncludeRule.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/core/module/descriptor/DefaultIncludeRule.java?view=diff&rev=544459&r1=544458&r2=544459
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/core/module/descriptor/DefaultIncludeRule.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/core/module/descriptor/DefaultIncludeRule.java Tue Jun 5 05:02:27 2007
@@ -22,15 +22,13 @@
import org.apache.ivy.core.module.id.ArtifactId;
import org.apache.ivy.plugins.matcher.PatternMatcher;
+public class DefaultIncludeRule extends AbstractIncludeExcludeRule implements IncludeRule {
-public class DefaultIncludeRule extends AbstractIncludeExcludeRule
- implements IncludeRule {
+ public DefaultIncludeRule(ArtifactId aid, PatternMatcher matcher, Map extraAttributes) {
+ super(aid, matcher, extraAttributes);
+ }
- public DefaultIncludeRule(ArtifactId aid, PatternMatcher matcher, Map extraAttributes) {
- super(aid, matcher, extraAttributes);
- }
-
- public String toString() {
- return "I:"+super.toString();
- }
+ public String toString() {
+ return "I:" + super.toString();
+ }
}
Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/core/module/descriptor/DefaultModuleDescriptor.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/core/module/descriptor/DefaultModuleDescriptor.java?view=diff&rev=544459&r1=544458&r2=544459
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/core/module/descriptor/DefaultModuleDescriptor.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/core/module/descriptor/DefaultModuleDescriptor.java Tue Jun 5 05:02:27 2007
@@ -48,71 +48,84 @@
import org.apache.ivy.plugins.version.VersionMatcher;
import org.apache.ivy.util.Message;
-
/**
*
*/
public class DefaultModuleDescriptor implements ModuleDescriptor {
-
+
public static DefaultModuleDescriptor newDefaultInstance(ModuleRevisionId mrid) {
return newDefaultInstance(mrid, null);
}
-
- public static DefaultModuleDescriptor newCallerInstance(ModuleRevisionId mrid, String[] confs, boolean transitive, boolean changing) {
- DefaultModuleDescriptor moduleDescriptor = new DefaultModuleDescriptor(ModuleRevisionId.newInstance(mrid.getOrganisation(), mrid.getName()+"-caller", "working"), "integration", null, true);
+
+ public static DefaultModuleDescriptor newCallerInstance(ModuleRevisionId mrid, String[] confs,
+ boolean transitive, boolean changing) {
+ DefaultModuleDescriptor moduleDescriptor = new DefaultModuleDescriptor(ModuleRevisionId
+ .newInstance(mrid.getOrganisation(), mrid.getName() + "-caller", "working"),
+ "integration", null, true);
for (int i = 0; i < confs.length; i++) {
- moduleDescriptor.addConfiguration(new Configuration(confs[i]));
- }
+ moduleDescriptor.addConfiguration(new Configuration(confs[i]));
+ }
moduleDescriptor.setLastModified(System.currentTimeMillis());
- DefaultDependencyDescriptor dd = new DefaultDependencyDescriptor(moduleDescriptor, mrid, true, changing, transitive);
- for (int j = 0; j < confs.length; j++) {
- dd.addDependencyConfiguration(confs[j], confs[j]);
- }
- moduleDescriptor.addDependency(dd);
-
+ DefaultDependencyDescriptor dd = new DefaultDependencyDescriptor(moduleDescriptor, mrid,
+ true, changing, transitive);
+ for (int j = 0; j < confs.length; j++) {
+ dd.addDependencyConfiguration(confs[j], confs[j]);
+ }
+ moduleDescriptor.addDependency(dd);
+
return moduleDescriptor;
}
-
- public static DefaultModuleDescriptor newCallerInstance(ModuleRevisionId[] mrid, boolean transitive, boolean changing) {
- DefaultModuleDescriptor moduleDescriptor = new DefaultModuleDescriptor(ModuleRevisionId.newInstance("caller", "all-caller", "working"), "integration", null, true);
+
+ public static DefaultModuleDescriptor newCallerInstance(ModuleRevisionId[] mrid,
+ boolean transitive, boolean changing) {
+ DefaultModuleDescriptor moduleDescriptor = new DefaultModuleDescriptor(ModuleRevisionId
+ .newInstance("caller", "all-caller", "working"), "integration", null, true);
moduleDescriptor.addConfiguration(new Configuration(DEFAULT_CONFIGURATION));
moduleDescriptor.setLastModified(System.currentTimeMillis());
for (int i = 0; i < mrid.length; i++) {
- DefaultDependencyDescriptor dd = new DefaultDependencyDescriptor(moduleDescriptor, mrid[i], true, changing, transitive);
- dd.addDependencyConfiguration(DEFAULT_CONFIGURATION, "*");
- moduleDescriptor.addDependency(dd);
- }
-
+ DefaultDependencyDescriptor dd = new DefaultDependencyDescriptor(moduleDescriptor,
+ mrid[i], true, changing, transitive);
+ dd.addDependencyConfiguration(DEFAULT_CONFIGURATION, "*");
+ moduleDescriptor.addDependency(dd);
+ }
+
return moduleDescriptor;
}
-
- public static DefaultModuleDescriptor newDefaultInstance(ModuleRevisionId mrid, DependencyArtifactDescriptor[] artifacts) {
- DefaultModuleDescriptor moduleDescriptor = new DefaultModuleDescriptor(mrid, "release", null, true);
+
+ public static DefaultModuleDescriptor newDefaultInstance(ModuleRevisionId mrid,
+ DependencyArtifactDescriptor[] artifacts) {
+ DefaultModuleDescriptor moduleDescriptor = new DefaultModuleDescriptor(mrid, "release",
+ null, true);
moduleDescriptor.addConfiguration(new Configuration(DEFAULT_CONFIGURATION));
if (artifacts != null && artifacts.length > 0) {
for (int i = 0; i < artifacts.length; i++) {
- moduleDescriptor.addArtifact(DEFAULT_CONFIGURATION, new MDArtifact(moduleDescriptor, artifacts[i].getName(), artifacts[i].getType(), artifacts[i].getExt(), artifacts[i].getUrl(), null));
+ moduleDescriptor.addArtifact(DEFAULT_CONFIGURATION, new MDArtifact(
+ moduleDescriptor, artifacts[i].getName(), artifacts[i].getType(),
+ artifacts[i].getExt(), artifacts[i].getUrl(), null));
}
} else {
- moduleDescriptor.addArtifact(DEFAULT_CONFIGURATION, new MDArtifact(moduleDescriptor, mrid.getName(), "jar", "jar"));
+ moduleDescriptor.addArtifact(DEFAULT_CONFIGURATION, new MDArtifact(moduleDescriptor,
+ mrid.getName(), "jar", "jar"));
}
moduleDescriptor.setLastModified(System.currentTimeMillis());
return moduleDescriptor;
}
- public static DefaultModuleDescriptor newBasicInstance(ModuleRevisionId mrid, Date publicationDate) {
- DefaultModuleDescriptor moduleDescriptor = new DefaultModuleDescriptor(mrid, "release", publicationDate, false);
+ public static DefaultModuleDescriptor newBasicInstance(ModuleRevisionId mrid,
+ Date publicationDate) {
+ DefaultModuleDescriptor moduleDescriptor = new DefaultModuleDescriptor(mrid, "release",
+ publicationDate, false);
moduleDescriptor.addConfiguration(new Configuration(DEFAULT_CONFIGURATION));
- moduleDescriptor.addArtifact(DEFAULT_CONFIGURATION, new MDArtifact(moduleDescriptor, mrid.getName(), "jar", "jar"));
+ moduleDescriptor.addArtifact(DEFAULT_CONFIGURATION, new MDArtifact(moduleDescriptor, mrid
+ .getName(), "jar", "jar"));
return moduleDescriptor;
}
/**
- * Transforms the given module descriptor of the given namespace and return
- * a new module descriptor in the system namespace.
- *
- * <i>Note that dependency exclude rules are not converted in system namespace, because they aren't
- * transformable (the name space hasn't the ability to convert regular expressions)</i>
+ * Transforms the given module descriptor of the given namespace and return a new module
+ * descriptor in the system namespace. <i>Note that dependency exclude rules are not converted
+ * in system namespace, because they aren't transformable (the name space hasn't the ability to
+ * convert regular expressions)</i>
*
* @param md
* @param ns
@@ -143,45 +156,69 @@
}
nmd.setDefault(md.isDefault());
if (md instanceof DefaultModuleDescriptor) {
- DefaultModuleDescriptor dmd = (DefaultModuleDescriptor)md;
+ DefaultModuleDescriptor dmd = (DefaultModuleDescriptor) md;
nmd._conflictManagers.putAll(dmd._conflictManagers);
} else {
- Message.warn("transformed module descriptor is not a default module descriptor: impossible to copy conflict manager configuration: "+md);
+ Message
+ .warn("transformed module descriptor is not a default module descriptor: impossible to copy conflict manager configuration: "
+ + md);
}
nmd._licenses.addAll(Arrays.asList(md.getLicenses()));
nmd._homePage = md.getHomePage();
nmd._lastModified = md.getLastModified();
nmd._namespace = ns;
-
+
return nmd;
}
-
- private ModuleRevisionId _revId;
- private ModuleRevisionId _resolvedRevId;
- private String _status = StatusManager.getCurrent().getDefaultStatus();
- private Date _publicationDate;
- private Date _resolvedPublicationDate;
- private List _dependencies = new ArrayList(); // List (DependencyDescriptor)
- private Map _configurations = new LinkedHashMap(); // Map(String conf -> Configuration)
+ private ModuleRevisionId _revId;
+
+ private ModuleRevisionId _resolvedRevId;
+
+ private String _status = StatusManager.getCurrent().getDefaultStatus();
+
+ private Date _publicationDate;
+
+ private Date _resolvedPublicationDate;
+
+ private List _dependencies = new ArrayList(); // List (DependencyDescriptor)
+
+ private Map _configurations = new LinkedHashMap(); // Map(String conf -> Configuration)
+
private Map _artifactsByConf = new HashMap(); // Map (String conf -> Collection(Artifact))
- private Collection _artifacts = new LinkedHashSet(); // Collection(Artifact) // all artifacts could also be found in the artifactsByConf map, but here we can preserve the order
+
+ private Collection _artifacts = new LinkedHashSet(); // Collection(Artifact) // all artifacts
+
+ // could also be found in the
+ // artifactsByConf map, but here we can
+ // preserve the order
+
private boolean _isDefault = false;
+
private Map _conflictManagers = new LinkedHashMap(); // Map (ModuleId -> )
+
private List _licenses = new ArrayList(); // List(License)
+
private String _homePage;
+
private long _lastModified = 0;
+
private Namespace _namespace;
- private boolean _mappingOverride;
- private ModuleDescriptorParser _parser;
- private Resource _resource;
- private List _excludeRules = new ArrayList(); // List(ExcludeRule)
+
+ private boolean _mappingOverride;
+
+ private ModuleDescriptorParser _parser;
+
+ private Resource _resource;
+
+ private List _excludeRules = new ArrayList(); // List(ExcludeRule)
public DefaultModuleDescriptor(ModuleRevisionId id, String status, Date pubDate) {
this(id, status, pubDate, false);
}
-
- public DefaultModuleDescriptor(ModuleRevisionId id, String status, Date pubDate, boolean isDefault) {
+
+ public DefaultModuleDescriptor(ModuleRevisionId id, String status, Date pubDate,
+ boolean isDefault) {
if (id == null) {
throw new NullPointerException("null module revision id not allowed");
}
@@ -192,43 +229,45 @@
_resolvedRevId = id;
_status = status;
_publicationDate = pubDate;
- _resolvedPublicationDate = _publicationDate==null?new Date():_publicationDate;
+ _resolvedPublicationDate = _publicationDate == null ? new Date() : _publicationDate;
_isDefault = isDefault;
}
-
- /**
- * IMPORTANT : at least call setModuleRevisionId and setResolvedPublicationDate
- * with instances created by this constructor !
- *
- */
+
+ /**
+ * IMPORTANT : at least call setModuleRevisionId and setResolvedPublicationDate with instances
+ * created by this constructor !
+ */
public DefaultModuleDescriptor(ModuleDescriptorParser parser, Resource res) {
- _parser = parser;
- _resource = res;
- }
+ _parser = parser;
+ _resource = res;
+ }
- public boolean isDefault() {
+ public boolean isDefault() {
return _isDefault;
}
-
+
public void setPublicationDate(Date publicationDate) {
_publicationDate = publicationDate;
if (_resolvedPublicationDate == null) {
- _resolvedPublicationDate = _publicationDate==null?new Date():_publicationDate;
+ _resolvedPublicationDate = _publicationDate == null ? new Date() : _publicationDate;
}
}
- public Date getPublicationDate() {
+
+ public Date getPublicationDate() {
return _publicationDate;
}
+
public void setResolvedPublicationDate(Date publicationDate) {
if (publicationDate == null) {
throw new NullPointerException("null publication date not allowed");
}
_resolvedPublicationDate = publicationDate;
}
+
public Date getResolvedPublicationDate() {
return _resolvedPublicationDate;
}
-
+
public void setModuleRevisionId(ModuleRevisionId revId) {
if (revId == null) {
throw new NullPointerException("null module revision id not allowed");
@@ -248,26 +287,27 @@
}
public void addDependency(DependencyDescriptor dependency) {
- _dependencies.add(dependency);
- }
-
+ _dependencies.add(dependency);
+ }
+
public void addConfiguration(Configuration conf) {
- _configurations.put(conf.getName(), conf);
- }
-
+ _configurations.put(conf.getName(), conf);
+ }
+
/**
- * Artifact configurations are not used since added artifact may not be
- * entirely completed, so its configurations data may not be accurate
+ * Artifact configurations are not used since added artifact may not be entirely completed, so
+ * its configurations data may not be accurate
+ *
* @param conf
* @param artifact
*/
public void addArtifact(String conf, Artifact artifact) {
- if (!_configurations.containsKey(conf)) {
- throw new IllegalArgumentException("Configuration '" + conf
- + "' doesn't exist in module " + this);
- }
-
- Collection artifacts = (Collection)_artifactsByConf.get(conf);
+ if (!_configurations.containsKey(conf)) {
+ throw new IllegalArgumentException("Configuration '" + conf
+ + "' doesn't exist in module " + this);
+ }
+
+ Collection artifacts = (Collection) _artifactsByConf.get(conf);
if (artifacts == null) {
artifacts = new ArrayList();
_artifactsByConf.put(conf, artifacts);
@@ -275,64 +315,68 @@
artifacts.add(artifact);
_artifacts.add(artifact);
}
-
- public ModuleRevisionId getModuleRevisionId() {
- return _revId;
- }
-
- public ModuleRevisionId getResolvedModuleRevisionId() {
- return _resolvedRevId;
- }
-
- public String getStatus() {
- return _status;
- }
+
+ public ModuleRevisionId getModuleRevisionId() {
+ return _revId;
+ }
+
+ public ModuleRevisionId getResolvedModuleRevisionId() {
+ return _resolvedRevId;
+ }
+
+ public String getStatus() {
+ return _status;
+ }
public Configuration[] getConfigurations() {
- return (Configuration[])_configurations.values().toArray(new Configuration[_configurations.size()]);
+ return (Configuration[]) _configurations.values().toArray(
+ new Configuration[_configurations.size()]);
}
-
+
public String[] getConfigurationsNames() {
- return (String[])_configurations.keySet().toArray(new String[_configurations.size()]);
+ return (String[]) _configurations.keySet().toArray(new String[_configurations.size()]);
}
-
+
public String[] getPublicConfigurationsNames() {
List ret = new ArrayList();
for (Iterator iter = _configurations.values().iterator(); iter.hasNext();) {
- Configuration conf = (Configuration)iter.next();
+ Configuration conf = (Configuration) iter.next();
if (conf.getVisibility() == Configuration.Visibility.PUBLIC) {
ret.add(conf.getName());
}
}
- return (String[])ret.toArray(new String[ret.size()]);
+ return (String[]) ret.toArray(new String[ret.size()]);
}
-
+
/**
* Returns the configuration object with the given name in the current module descriptor, null
* if not found.
*/
public Configuration getConfiguration(String confName) {
- return (Configuration)_configurations.get(confName);
+ return (Configuration) _configurations.get(confName);
}
public Artifact[] getArtifacts(String conf) {
- Collection artifacts = (Collection)_artifactsByConf.get(conf);
+ Collection artifacts = (Collection) _artifactsByConf.get(conf);
if (artifacts == null) {
return new Artifact[0];
} else {
- return (Artifact[])artifacts.toArray(new Artifact[artifacts.size()]);
+ return (Artifact[]) artifacts.toArray(new Artifact[artifacts.size()]);
}
}
+
public Artifact[] getAllArtifacts() {
- return (Artifact[])_artifacts.toArray(new Artifact[_artifacts.size()]);
+ return (Artifact[]) _artifacts.toArray(new Artifact[_artifacts.size()]);
+ }
+
+ public DependencyDescriptor[] getDependencies() {
+ return (DependencyDescriptor[]) _dependencies
+ .toArray(new DependencyDescriptor[_dependencies.size()]);
}
- public DependencyDescriptor[] getDependencies() {
- return (DependencyDescriptor[])_dependencies.toArray(new DependencyDescriptor[_dependencies.size()]);
- }
-
- public boolean dependsOn(VersionMatcher matcher, ModuleDescriptor md) {
- for (Iterator iter = _dependencies.iterator(); iter.hasNext();) {
- DependencyDescriptor dd = (DependencyDescriptor)iter.next();
+
+ public boolean dependsOn(VersionMatcher matcher, ModuleDescriptor md) {
+ for (Iterator iter = _dependencies.iterator(); iter.hasNext();) {
+ DependencyDescriptor dd = (DependencyDescriptor) iter.next();
if (dd.getDependencyId().equals(md.getModuleRevisionId().getModuleId())) {
if (md.getResolvedModuleRevisionId().getRevision() == null) {
return true;
@@ -343,68 +387,74 @@
}
return false;
}
-
- public void toIvyFile(File destFile) throws ParseException, IOException {
- if (_parser != null && _resource != null) {
- _parser.toIvyFile(_resource.openStream(), _resource, destFile, this);
- } else {
- XmlModuleDescriptorWriter.write(this, destFile);
- }
- }
+
+ public void toIvyFile(File destFile) throws ParseException, IOException {
+ if (_parser != null && _resource != null) {
+ _parser.toIvyFile(_resource.openStream(), _resource, destFile, this);
+ } else {
+ XmlModuleDescriptorWriter.write(this, destFile);
+ }
+ }
public String toString() {
- return "module: "+_revId+" status="+_status+" publication="+_publicationDate+" configurations="+_configurations+" artifacts="+_artifactsByConf+" dependencies="+_dependencies;
+ return "module: " + _revId + " status=" + _status + " publication=" + _publicationDate
+ + " configurations=" + _configurations + " artifacts=" + _artifactsByConf
+ + " dependencies=" + _dependencies;
}
public void setDefault(boolean b) {
_isDefault = b;
}
-
+
private static class ModuleIdMatcher {
private PatternMatcher _matcher;
+
private ModuleId _mid;
+
public ModuleIdMatcher(PatternMatcher matcher, ModuleId mid) {
_matcher = matcher;
_mid = mid;
}
+
public boolean matches(ModuleId mid) {
return MatcherHelper.matches(_matcher, _mid, mid);
}
}
/**
- * regular expressions as explained in Pattern class may be used in ModuleId
- * organisation and name
+ * regular expressions as explained in Pattern class may be used in ModuleId organisation and
+ * name
*
* @param moduleId
- * @param matcher
+ * @param matcher
* @param resolverName
*/
- public void addConflictManager(ModuleId moduleId, PatternMatcher matcher, ConflictManager manager) {
+ public void addConflictManager(ModuleId moduleId, PatternMatcher matcher,
+ ConflictManager manager) {
_conflictManagers.put(new ModuleIdMatcher(matcher, moduleId), manager);
}
+
public ConflictManager getConflictManager(ModuleId moduleId) {
for (Iterator iter = _conflictManagers.keySet().iterator(); iter.hasNext();) {
- ModuleIdMatcher matcher = (ModuleIdMatcher)iter.next();
+ ModuleIdMatcher matcher = (ModuleIdMatcher) iter.next();
if (matcher.matches(moduleId)) {
- return (ConflictManager)_conflictManagers.get(matcher);
+ return (ConflictManager) _conflictManagers.get(matcher);
}
}
return null;
}
-
+
public void addLicense(License license) {
_licenses.add(license);
}
public License[] getLicenses() {
- return (License[])_licenses.toArray(new License[_licenses.size()]);
+ return (License[]) _licenses.toArray(new License[_licenses.size()]);
}
public String getHomePage() {
return _homePage;
}
-
public void setHomePage(String homePage) {
_homePage = homePage;
@@ -413,7 +463,6 @@
public long getLastModified() {
return _lastModified;
}
-
public void setLastModified(long lastModified) {
_lastModified = lastModified;
@@ -428,7 +477,7 @@
public boolean isNamespaceUseful() {
for (Iterator iter = _dependencies.iterator(); iter.hasNext();) {
- DependencyDescriptor dd = (DependencyDescriptor)iter.next();
+ DependencyDescriptor dd = (DependencyDescriptor) iter.next();
if (dd.getAllExcludeRules().length > 0) {
return true;
}
@@ -441,28 +490,29 @@
}
/**
- * Throws an exception if the module descriptor is inconsistent
- * For the moment, only extended configurations existence is checked
+ * Throws an exception if the module descriptor is inconsistent For the moment, only extended
+ * configurations existence is checked
*/
public void check() {
for (Iterator iter = _configurations.values().iterator(); iter.hasNext();) {
- Configuration conf = (Configuration)iter.next();
+ Configuration conf = (Configuration) iter.next();
String[] ext = conf.getExtends();
for (int i = 0; i < ext.length; i++) {
if (!_configurations.containsKey(ext[i].trim())) {
- throw new IllegalStateException("unknown configuration '"+ext[i]+"'. It is extended by "+conf.getName());
+ throw new IllegalStateException("unknown configuration '" + ext[i]
+ + "'. It is extended by " + conf.getName());
}
}
}
}
- public void setMappingOverride(boolean override) {
- _mappingOverride = override;
- }
-
- public boolean isMappingOverride() {
- return _mappingOverride;
- }
+ public void setMappingOverride(boolean override) {
+ _mappingOverride = override;
+ }
+
+ public boolean isMappingOverride() {
+ return _mappingOverride;
+ }
public String getAttribute(String attName) {
return _resolvedRevId.getAttribute(attName);
@@ -488,53 +538,57 @@
return _resolvedRevId.getStandardAttributes();
}
- public ModuleDescriptorParser getParser() {
- return _parser;
- }
-
- public Resource getResource() {
- return _resource;
- }
-
- public void addExcludeRule(ExcludeRule rule) {
- _excludeRules .add(rule);
- }
-
- public boolean canExclude() {
- return !_excludeRules.isEmpty();
- }
+ public ModuleDescriptorParser getParser() {
+ return _parser;
+ }
+
+ public Resource getResource() {
+ return _resource;
+ }
+
+ public void addExcludeRule(ExcludeRule rule) {
+ _excludeRules.add(rule);
+ }
+
+ public boolean canExclude() {
+ return !_excludeRules.isEmpty();
+ }
+
/**
- * only works when namespace is properly set. The behaviour is not specified if namespace is not set
+ * only works when namespace is properly set. The behaviour is not specified if namespace is not
+ * set
*/
public boolean doesExclude(String[] moduleConfigurations, ArtifactId artifactId) {
if (_namespace != null) {
- artifactId = NameSpaceHelper.transform(artifactId, _namespace.getFromSystemTransformer());
+ artifactId = NameSpaceHelper.transform(artifactId, _namespace
+ .getFromSystemTransformer());
}
ExcludeRule[] rules = getExcludeRules(moduleConfigurations);
for (int i = 0; i < rules.length; i++) {
if (MatcherHelper.matches(rules[i].getMatcher(), rules[i].getId(), artifactId)) {
return true;
}
- }
+ }
return false;
}
+
public ExcludeRule[] getAllExcludeRules() {
- return (ExcludeRule[]) _excludeRules.toArray(new ExcludeRule[_excludeRules.size()]);
+ return (ExcludeRule[]) _excludeRules.toArray(new ExcludeRule[_excludeRules.size()]);
}
+
public ExcludeRule[] getExcludeRules(String[] moduleConfigurations) {
Set rules = new LinkedHashSet();
for (Iterator iter = _excludeRules.iterator(); iter.hasNext();) {
- ExcludeRule rule = (ExcludeRule) iter.next();
- String[] ruleConfs = rule.getConfigurations();
- if (containsAny(ruleConfs, moduleConfigurations)) {
- rules.add(rule);
- }
- }
+ ExcludeRule rule = (ExcludeRule) iter.next();
+ String[] ruleConfs = rule.getConfigurations();
+ if (containsAny(ruleConfs, moduleConfigurations)) {
+ rules.add(rule);
+ }
+ }
return (ExcludeRule[]) rules.toArray(new ExcludeRule[rules.size()]);
}
- private boolean containsAny(String[] arr1, String[] arr2) {
- return new ArrayList(Arrays.asList(arr1))
- .removeAll(Arrays.asList(arr2));
- }
+ private boolean containsAny(String[] arr1, String[] arr2) {
+ return new ArrayList(Arrays.asList(arr1)).removeAll(Arrays.asList(arr2));
+ }
}
Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/core/module/descriptor/DependencyArtifactDescriptor.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/core/module/descriptor/DependencyArtifactDescriptor.java?view=diff&rev=544459&r1=544458&r2=544459
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/core/module/descriptor/DependencyArtifactDescriptor.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/core/module/descriptor/DependencyArtifactDescriptor.java Tue Jun 5 05:02:27 2007
@@ -21,36 +21,42 @@
import org.apache.ivy.util.extendable.ExtendableItem;
-
/**
- * This describes an artifact that is asked for a dependency.
- *
- * It is used to define an (additional) artifact not declared
- * by a dependency module descriptor.
+ * This describes an artifact that is asked for a dependency. It is used to define an (additional)
+ * artifact not declared by a dependency module descriptor.
*/
public interface DependencyArtifactDescriptor extends ExtendableItem {
/**
* Returns the name of the artifact asked
+ *
* @return
*/
public String getName();
+
/**
* Returns the type of the artifact asked
+ *
* @return
*/
public String getType();
+
/**
* Returns the ext of the artifact asked
+ *
* @return
*/
public String getExt();
+
/**
* Returns the url to look this artifact at
+ *
* @return
*/
public URL getUrl();
+
/**
* Returns the configurations of the module in which the artifact is asked
+ *
* @return an array of configuration names in which the artifact is asked
*/
public String[] getConfigurations();
Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/core/module/descriptor/DependencyDescriptor.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/core/module/descriptor/DependencyDescriptor.java?view=diff&rev=544459&r1=544458&r2=544459
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/core/module/descriptor/DependencyDescriptor.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/core/module/descriptor/DependencyDescriptor.java Tue Jun 5 05:02:27 2007
@@ -23,56 +23,79 @@
import org.apache.ivy.plugins.namespace.Namespace;
import org.apache.ivy.util.extendable.ExtendableItem;
-
/**
*
*/
public interface DependencyDescriptor extends ExtendableItem {
ModuleId getDependencyId();
+
/**
- * Used to indicate that this revision must be used in case of conflicts, independently
- * of conflicts manager. This only works for direct dependencies, and not transitive ones.
- * @return true if this dependency should be used, false if conflicts manager
- * can do its work.
+ * Used to indicate that this revision must be used in case of conflicts, independently of
+ * conflicts manager. This only works for direct dependencies, and not transitive ones.
+ *
+ * @return true if this dependency should be used, false if conflicts manager can do its work.
*/
boolean isForce();
+
/**
- * Used to indicate that this dependency is a changing one.
- * A changing dependency in ivy means that the revision may have its artifacts modified
- * without revision change. When new artifacts are published a new ivy file should also
- * be published with a new publication date to indicate to ivy that artifacts have changed and that they
- * should be downloaded again.
+ * Used to indicate that this dependency is a changing one. A changing dependency in ivy means
+ * that the revision may have its artifacts modified without revision change. When new artifacts
+ * are published a new ivy file should also be published with a new publication date to indicate
+ * to ivy that artifacts have changed and that they should be downloaded again.
+ *
* @return true if this dependency is a changing one
*/
boolean isChanging();
+
boolean isTransitive();
+
ModuleRevisionId getParentRevisionId();
+
ModuleRevisionId getDependencyRevisionId();
+
String[] getModuleConfigurations();
+
String[] getDependencyConfigurations(String moduleConfiguration, String requestedConfiguration);
+
String[] getDependencyConfigurations(String moduleConfiguration);
+
String[] getDependencyConfigurations(String[] moduleConfigurations);
+
Namespace getNamespace();
+
DependencyArtifactDescriptor[] getAllDependencyArtifacts();
+
DependencyArtifactDescriptor[] getDependencyArtifacts(String moduleConfigurations);
+
DependencyArtifactDescriptor[] getDependencyArtifacts(String[] moduleConfigurations);
+
IncludeRule[] getAllIncludeRules();
+
IncludeRule[] getIncludeRules(String moduleConfigurations);
+
IncludeRule[] getIncludeRules(String[] moduleConfigurations);
+
ExcludeRule[] getAllExcludeRules();
+
ExcludeRule[] getExcludeRules(String moduleConfigurations);
+
ExcludeRule[] getExcludeRules(String[] moduleConfigurations);
+
/**
* Returns true if
+ *
* @param moduleConfigurations
* @param artifactId
* @return
*/
boolean doesExclude(String[] moduleConfigurations, ArtifactId artifactId);
+
/**
* Returns true if this descriptor contains any exclusion rule
+ *
* @return true if this descriptor contains any exclusion rule
*/
public boolean canExclude();
- DependencyDescriptor asSystem();
+
+ DependencyDescriptor asSystem();
}
Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/core/module/descriptor/ExcludeRule.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/core/module/descriptor/ExcludeRule.java?view=diff&rev=544459&r1=544458&r2=544459
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/core/module/descriptor/ExcludeRule.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/core/module/descriptor/ExcludeRule.java Tue Jun 5 05:02:27 2007
@@ -21,28 +21,29 @@
import org.apache.ivy.plugins.matcher.PatternMatcher;
import org.apache.ivy.util.extendable.ExtendableItem;
-
/**
- * This describes a rule of exclusion.
- *
- * It is used to resctrict the artifacts asked for a dependency,
+ * This describes a rule of exclusion. It is used to resctrict the artifacts asked for a dependency,
* by excluding a whole module or some artifacts of a dependency.
*/
public interface ExcludeRule extends ExtendableItem {
/**
* Returns the id of the described artifact, without revision information
+ *
* @return
*/
public ArtifactId getId();
+
/**
* Returns the configurations of the module in which the artifact is asked
+ *
* @return an array of configuration names in which the artifact is asked
*/
public String[] getConfigurations();
-
+
/**
* Returns the matcher to use to know if an artifact match the current descriptor
+ *
* @return
*/
public PatternMatcher getMatcher();
Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/core/module/descriptor/IncludeRule.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/core/module/descriptor/IncludeRule.java?view=diff&rev=544459&r1=544458&r2=544459
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/core/module/descriptor/IncludeRule.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/core/module/descriptor/IncludeRule.java Tue Jun 5 05:02:27 2007
@@ -22,26 +22,28 @@
import org.apache.ivy.util.extendable.ExtendableItem;
/**
- * This describes a rule of inclusion.
- *
- * It is used to resctrict the artifacts and modules asked for a dependency,
- * by including only modules and artifacts matching the rule
+ * This describes a rule of inclusion. It is used to resctrict the artifacts and modules asked for a
+ * dependency, by including only modules and artifacts matching the rule
*/
public interface IncludeRule extends ExtendableItem {
/**
* Returns the id of the described artifact, without revision information
+ *
* @return
*/
public ArtifactId getId();
+
/**
* Returns the configurations of the module in which the artifact is asked
+ *
* @return an array of configuration names in which the artifact is asked
*/
public String[] getConfigurations();
-
+
/**
* Returns the matcher to use to know if an artifact match the current descriptor
+ *
* @return
*/
public PatternMatcher getMatcher();
Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/core/module/descriptor/License.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/core/module/descriptor/License.java?view=diff&rev=544459&r1=544458&r2=544459
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/core/module/descriptor/License.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/core/module/descriptor/License.java Tue Jun 5 05:02:27 2007
@@ -19,7 +19,9 @@
public class License {
private String name;
+
private String url;
+
public License(String name, String url) {
this.name = name;
this.url = url;
@@ -28,9 +30,9 @@
public String getName() {
return name;
}
-
+
public String getUrl() {
return url;
}
-
+
}
Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/core/module/descriptor/MDArtifact.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/core/module/descriptor/MDArtifact.java?view=diff&rev=544459&r1=544458&r2=544459
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/core/module/descriptor/MDArtifact.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/core/module/descriptor/MDArtifact.java Tue Jun 5 05:02:27 2007
@@ -34,20 +34,29 @@
public static Artifact newIvyArtifact(ModuleDescriptor md) {
return new MDArtifact(md, "ivy", "ivy", "xml");
}
-
+
private ModuleDescriptor md;
+
private String name;
+
private String type;
+
private String ext;
+
private List confs = new ArrayList();
+
private ArtifactRevisionId arid;
+
private Map extraAttributes = null;
- private URL url;
+
+ private URL url;
public MDArtifact(ModuleDescriptor md, String name, String type, String ext) {
this(md, name, type, ext, null, null);
}
- public MDArtifact(ModuleDescriptor md, String name, String type, String ext, URL url, Map extraAttributes) {
+
+ public MDArtifact(ModuleDescriptor md, String name, String type, String ext, URL url,
+ Map extraAttributes) {
if (md == null) {
throw new NullPointerException("null module descriptor not allowed");
}
@@ -67,20 +76,22 @@
this.url = url;
this.extraAttributes = extraAttributes;
}
-
+
public ModuleRevisionId getModuleRevisionId() {
return md.getResolvedModuleRevisionId();
}
-
+
public Date getPublicationDate() {
return md.getResolvedPublicationDate();
}
+
public ArtifactRevisionId getId() {
if (arid == null) {
- arid = ArtifactRevisionId.newInstance(md.getResolvedModuleRevisionId(), name, type, ext, extraAttributes);
+ arid = ArtifactRevisionId.newInstance(md.getResolvedModuleRevisionId(), name, type,
+ ext, extraAttributes);
}
return arid;
- }
+ }
public String getName() {
return name;
@@ -101,9 +112,9 @@
public void addConfiguration(String conf) {
confs.add(conf);
}
-
- public URL getUrl() {
- return url;
- }
-
+
+ public URL getUrl() {
+ return url;
+ }
+
}
Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/core/module/descriptor/ModuleDescriptor.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/core/module/descriptor/ModuleDescriptor.java?view=diff&rev=544459&r1=544458&r2=544459
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/core/module/descriptor/ModuleDescriptor.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/core/module/descriptor/ModuleDescriptor.java Tue Jun 5 05:02:27 2007
@@ -31,81 +31,101 @@
import org.apache.ivy.plugins.version.VersionMatcher;
import org.apache.ivy.util.extendable.ExtendableItem;
-
/**
*
*/
public interface ModuleDescriptor extends ExtendableItem {
public static final String DEFAULT_CONFIGURATION = "default";
+
public static final String CALLER_ALL_CONFIGURATION = "all";
+
/**
- * Returns true if this descriptor is a default one, i.e.
- * one generated for a module not actually having one.
+ * Returns true if this descriptor is a default one, i.e. one generated for a module not
+ * actually having one.
+ *
* @return
*/
boolean isDefault();
+
ModuleRevisionId getModuleRevisionId();
+
/**
- * The module revision id returned here is the resolved one,
- * i.e. it is never a latest one. If the revision has not been
- * resolved, a null revision should be returned by getRevision()
- * of the returned ModuleRevisionId.
- * This revision must be the same as the module descriptor resolved
- * revision id unless no module descriptor is defined
+ * The module revision id returned here is the resolved one, i.e. it is never a latest one. If
+ * the revision has not been resolved, a null revision should be returned by getRevision() of
+ * the returned ModuleRevisionId. This revision must be the same as the module descriptor
+ * resolved revision id unless no module descriptor is defined
+ *
* @return
*/
ModuleRevisionId getResolvedModuleRevisionId();
+
/**
* This method update the resolved module revision id
+ *
* @param revId
*/
void setResolvedModuleRevisionId(ModuleRevisionId revId);
+
/**
* This method update the resolved publication date
+ *
* @param publicationDate
*/
void setResolvedPublicationDate(Date publicationDate);
-
+
String getStatus();
+
/**
* may be null if unknown in the descriptor itself
+ *
* @return
*/
Date getPublicationDate();
+
/**
- * the publication date of the module revision should be the date at which it has been published,
- * i.e. in general the date of any of its published artifacts, since all published artifact
- * of a module should follow the same publishing cycle.
- */
+ * the publication date of the module revision should be the date at which it has been
+ * published, i.e. in general the date of any of its published artifacts, since all published
+ * artifact of a module should follow the same publishing cycle.
+ */
Date getResolvedPublicationDate();
+
/**
- * Returns all the configurations declared by this module as an array.
- * This array is never empty (a 'default' conf is assumed when none is declared
- * in the ivy file)
+ * Returns all the configurations declared by this module as an array. This array is never empty
+ * (a 'default' conf is assumed when none is declared in the ivy file)
+ *
* @return all the configurations declared by this module as an array.
*/
Configuration[] getConfigurations();
+
String[] getConfigurationsNames();
+
String[] getPublicConfigurationsNames();
+
Artifact[] getArtifacts(String conf);
- Artifact[] getAllArtifacts();
-
- /** @retun The dependencies of the module. If there is no dependencies return an empty array (non null) */
+
+ Artifact[] getAllArtifacts();
+
+ /**
+ * @retun The dependencies of the module. If there is no dependencies return an empty array (non
+ * null)
+ */
DependencyDescriptor[] getDependencies();
-
+
/**
- * Returns true if the module described by this descriptor dependes directly upon the
- * given module descriptor
+ * Returns true if the module described by this descriptor dependes directly upon the given
+ * module descriptor
+ *
* @param md
* @return
*/
boolean dependsOn(VersionMatcher matcher, ModuleDescriptor md);
+
/**
* @param confName
* @return
*/
Configuration getConfiguration(String confName);
-
+
/**
* Returns the conflict manager to use for the given ModuleId
*
@@ -116,49 +136,63 @@
/**
* Returns the licenses of the module described by this descriptor
+ *
* @return
*/
License[] getLicenses();
-
+
String getHomePage();
+
long getLastModified();
-
+
+ /**
+ * Writes this module descriptor as an ivy file. If this descriptor was obtained through the
+ * parsing of an ivy file, it should keep the layout of the file the most possible similar to
+ * the original one.
+ *
+ * @param ivyFile
+ * the destination ivy file
+ */
+ void toIvyFile(File ivyFile) throws ParseException, IOException;
+
/**
- * Writes this module descriptor as an ivy file.
+ * The ModuleDescriptorParser used to parse this module descriptor, null is no parser was used.
*
- * If this descriptor was obtained through the parsing of an ivy file, it should
- * keep the layout of the file the most possible similar to the original one.
- * @param ivyFile the destination ivy file
- */
- void toIvyFile(File ivyFile) throws ParseException, IOException;
- /**
- * The ModuleDescriptorParser used to parse this module descriptor, null is no parser was used.
- * @return
- */
- ModuleDescriptorParser getParser();
- /**
- * The resource being the source of this module descriptor, null if no resource corresponds to this module descriptor
- * @return
- */
- Resource getResource();
+ * @return
+ */
+ ModuleDescriptorParser getParser();
+
+ /**
+ * The resource being the source of this module descriptor, null if no resource corresponds to
+ * this module descriptor
+ *
+ * @return
+ */
+ Resource getResource();
+
/**
* Returns true if this descriptor contains any exclusion rule
+ *
* @return true if this descriptor contains any exclusion rule
*/
- boolean canExclude();
- /**
- * Returns true if an exclude rule of this module attached to any of the given configurations
- * matches the given artifact id, and thus exclude it
- * @param moduleConfs
- * @param artifactId
- * @return
- */
- boolean doesExclude(String[] moduleConfs, ArtifactId artifactId);
- /**
- * Returns an array of all the exclude rules this module descriptor currently holds.
- * Module Descriptor exclude rules are used to exclude (usually transitive) dependencies
- * for the whole module.
- * @return an array of {@link ExcludeRule} this module descriptor holds
- */
- public ExcludeRule[] getAllExcludeRules();
+ boolean canExclude();
+
+ /**
+ * Returns true if an exclude rule of this module attached to any of the given configurations
+ * matches the given artifact id, and thus exclude it
+ *
+ * @param moduleConfs
+ * @param artifactId
+ * @return
+ */
+ boolean doesExclude(String[] moduleConfs, ArtifactId artifactId);
+
+ /**
+ * Returns an array of all the exclude rules this module descriptor currently holds. Module
+ * Descriptor exclude rules are used to exclude (usually transitive) dependencies for the whole
+ * module.
+ *
+ * @return an array of {@link ExcludeRule} this module descriptor holds
+ */
+ public ExcludeRule[] getAllExcludeRules();
}
Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/core/module/id/ArtifactId.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/core/module/id/ArtifactId.java?view=diff&rev=544459&r1=544458&r2=544459
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/core/module/id/ArtifactId.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/core/module/id/ArtifactId.java Tue Jun 5 05:02:27 2007
@@ -22,11 +22,13 @@
*/
public class ArtifactId {
private ModuleId mid;
+
private String name;
+
private String type;
+
private String ext;
-
-
+
/**
* @param mid
* @param name
@@ -38,18 +40,16 @@
this.type = type;
this.ext = ext;
}
-
+
public boolean equals(Object obj) {
- if (! (obj instanceof ArtifactId)) {
+ if (!(obj instanceof ArtifactId)) {
return false;
}
- ArtifactId aid = (ArtifactId)obj;
- return getModuleId().equals(aid.getModuleId())
- && getName().equals(aid.getName())
- && getExt().equals(aid.getExt())
- && getType().equals(aid.getType());
+ ArtifactId aid = (ArtifactId) obj;
+ return getModuleId().equals(aid.getModuleId()) && getName().equals(aid.getName())
+ && getExt().equals(aid.getExt()) && getType().equals(aid.getType());
}
-
+
public int hashCode() {
int hash = 17;
hash += getModuleId().hashCode() * 37;
@@ -57,29 +57,32 @@
hash += getType().hashCode() * 37;
return hash;
}
-
+
public String toString() {
- return getModuleId()+" "+getName()+"."+getType();
+ return getModuleId() + " " + getName() + "." + getType();
}
-
+
/**
* @return Returns the module id.
*/
public ModuleId getModuleId() {
return mid;
}
+
/**
* @return Returns the name.
*/
public String getName() {
return name;
}
+
/**
* @return Returns the type.
*/
public String getType() {
return type;
}
+
/**
* @return Returns the ext.
*/
Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/core/module/id/ArtifactRevisionId.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/core/module/id/ArtifactRevisionId.java?view=diff&rev=544459&r1=544458&r2=544459
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/core/module/id/ArtifactRevisionId.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/core/module/id/ArtifactRevisionId.java Tue Jun 5 05:02:27 2007
@@ -23,30 +23,32 @@
import org.apache.ivy.core.IvyPatternHelper;
import org.apache.ivy.util.extendable.UnmodifiableExtendableItem;
-
/**
* identifies an artifact in a particular module revision
*/
public class ArtifactRevisionId extends UnmodifiableExtendableItem {
- public static ArtifactRevisionId newInstance(ModuleRevisionId mrid, String name, String type, String ext) {
+ public static ArtifactRevisionId newInstance(ModuleRevisionId mrid, String name, String type,
+ String ext) {
return newInstance(mrid, name, type, ext, null);
}
-
- public static ArtifactRevisionId newInstance(ModuleRevisionId mrid, String name, String type, String ext, Map extraAttributes) {
- // we inject module extra attributes as extra attributes for the artifacts too
- if (extraAttributes == null) {
- extraAttributes = mrid.getExtraAttributes();
- } else {
- extraAttributes = new HashMap(extraAttributes);
- extraAttributes.putAll(mrid.getExtraAttributes());
- }
- return new ArtifactRevisionId(new ArtifactId(mrid.getModuleId(), name, type, ext), mrid, extraAttributes);
+
+ public static ArtifactRevisionId newInstance(ModuleRevisionId mrid, String name, String type,
+ String ext, Map extraAttributes) {
+ // we inject module extra attributes as extra attributes for the artifacts too
+ if (extraAttributes == null) {
+ extraAttributes = mrid.getExtraAttributes();
+ } else {
+ extraAttributes = new HashMap(extraAttributes);
+ extraAttributes.putAll(mrid.getExtraAttributes());
+ }
+ return new ArtifactRevisionId(new ArtifactId(mrid.getModuleId(), name, type, ext), mrid,
+ extraAttributes);
}
-
+
private ArtifactId _artifactId;
+
private ModuleRevisionId _mrid;
-
-
+
public ArtifactRevisionId(ArtifactId artifactId, ModuleRevisionId mrid) {
this(artifactId, mrid, null);
}
@@ -55,25 +57,26 @@
super(null, extraAttributes);
_artifactId = artifactId;
_mrid = mrid;
-
- setStandardAttribute(IvyPatternHelper.ORGANISATION_KEY, getModuleRevisionId().getOrganisation());
+
+ setStandardAttribute(IvyPatternHelper.ORGANISATION_KEY, getModuleRevisionId()
+ .getOrganisation());
setStandardAttribute(IvyPatternHelper.MODULE_KEY, getModuleRevisionId().getName());
setStandardAttribute(IvyPatternHelper.REVISION_KEY, getModuleRevisionId().getRevision());
setStandardAttribute(IvyPatternHelper.ARTIFACT_KEY, getName());
setStandardAttribute(IvyPatternHelper.TYPE_KEY, getType());
setStandardAttribute(IvyPatternHelper.EXT_KEY, getExt());
}
-
+
public boolean equals(Object obj) {
- if (! (obj instanceof ArtifactRevisionId)) {
+ if (!(obj instanceof ArtifactRevisionId)) {
return false;
}
- ArtifactRevisionId arid = (ArtifactRevisionId)obj;
- return getArtifactId().equals(arid.getArtifactId())
- && getModuleRevisionId().equals(arid.getModuleRevisionId())
- && getExtraAttributes().equals(arid.getExtraAttributes());
+ ArtifactRevisionId arid = (ArtifactRevisionId) obj;
+ return getArtifactId().equals(arid.getArtifactId())
+ && getModuleRevisionId().equals(arid.getModuleRevisionId())
+ && getExtraAttributes().equals(arid.getExtraAttributes());
}
-
+
public int hashCode() {
// WARN: uniqueness needs to be relatively strong here
int hash = 17;
@@ -82,18 +85,20 @@
hash += getExtraAttributes().hashCode() * 37;
return hash;
}
-
+
public String toString() {
- return "[ "+getModuleRevisionId().getOrganisation()+" | "+ getModuleRevisionId().getName()+" | "+getModuleRevisionId().getRevision()+" :: "+getName()+" . "+getExt()+" ( "+getType()+" ) ]";
+ return "[ " + getModuleRevisionId().getOrganisation() + " | "
+ + getModuleRevisionId().getName() + " | " + getModuleRevisionId().getRevision()
+ + " :: " + getName() + " . " + getExt() + " ( " + getType() + " ) ]";
}
-
+
/**
* @return Returns the artifactId.
*/
public ArtifactId getArtifactId() {
return _artifactId;
}
-
+
public ModuleRevisionId getModuleRevisionId() {
return _mrid;
}
@@ -101,20 +106,20 @@
public String getName() {
return _artifactId.getName();
}
-
+
public String getType() {
return _artifactId.getType();
}
-
+
public String getExt() {
return _artifactId.getExt();
}
-
+
/**
* @return Returns the revision.
*/
public String getRevision() {
return _mrid.getRevision();
}
-
+
}
Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/core/module/id/ModuleId.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/core/module/id/ModuleId.java?view=diff&rev=544459&r1=544458&r2=544459
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/core/module/id/ModuleId.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/core/module/id/ModuleId.java Tue Jun 5 05:02:27 2007
@@ -17,14 +17,16 @@
*/
package org.apache.ivy.core.module.id;
-
/**
*
*/
public class ModuleId implements Comparable {
static final String ENCODE_SEPARATOR = ":#@#:";
+
private String organisation;
+
private String name;
+
private int hash;
public ModuleId(String organisation, String name) {
@@ -33,42 +35,46 @@
}
this.organisation = organisation;
this.name = name;
- hash = _hashCode(); //stored for performance reasons, hashCode is very used in many maps
+ hash = _hashCode(); // stored for performance reasons, hashCode is very used in many maps
}
public String getName() {
return name;
}
+
public String getOrganisation() {
return organisation;
}
-
+
public boolean equals(Object obj) {
- if (! (obj instanceof ModuleId)) {
+ if (!(obj instanceof ModuleId)) {
return false;
}
- ModuleId other = (ModuleId)obj;
+ ModuleId other = (ModuleId) obj;
if (other.organisation == null) {
- return organisation == null && other.name.equals(name);
+ return organisation == null && other.name.equals(name);
} else {
- return other.organisation.equals(organisation) && other.name.equals(name);
+ return other.organisation.equals(organisation) && other.name.equals(name);
}
}
+
public int hashCode() {
return hash;
}
+
public int _hashCode() {
int hash = 31;
hash = hash * 13 + (organisation == null ? 0 : organisation.hashCode());
hash = hash * 13 + name.hashCode();
return hash;
}
+
public String toString() {
- return "[ "+ organisation +" | "+ name +" ]";
+ return "[ " + organisation + " | " + name + " ]";
}
public int compareTo(Object obj) {
- ModuleId that = (ModuleId)obj;
+ ModuleId that = (ModuleId) obj;
int result = organisation.compareTo(that.organisation);
if (result == 0) {
result = name.compareTo(that.name);
@@ -79,10 +85,11 @@
public String encodeToString() {
return getOrganisation() + ENCODE_SEPARATOR + getName();
}
+
public static ModuleId decode(String encoded) {
String[] parts = encoded.split(ENCODE_SEPARATOR);
if (parts.length != 2) {
- throw new IllegalArgumentException("badly encoded module id: '"+encoded+"'");
+ throw new IllegalArgumentException("badly encoded module id: '" + encoded + "'");
}
return new ModuleId(parts[0], parts[1]);
}