1 6 package fr.jayasoft.ivy; 7 8 import java.net.URL ; 9 import java.util.ArrayList ; 10 import java.util.Collection ; 11 12 import fr.jayasoft.ivy.matcher.PatternMatcher; 13 14 public class DefaultDependencyArtifactDescriptor implements DependencyArtifactDescriptor { 15 16 private DefaultDependencyDescriptor _dd; 17 private ArtifactId _id; 18 private Collection _confs = new ArrayList (); 19 private boolean _includes; 20 private PatternMatcher _patternMatcher; 21 private URL _url; 22 23 24 25 public DefaultDependencyArtifactDescriptor(DefaultDependencyDescriptor dd, 26 String name, String type, String ext, boolean includes, PatternMatcher matcher) { 27 this(dd, name, type, ext, null, includes, matcher); 28 } 29 35 public DefaultDependencyArtifactDescriptor(DefaultDependencyDescriptor dd, 36 String name, String type, String ext, URL url, boolean includes, PatternMatcher matcher) { 37 if (dd == null) { 38 throw new NullPointerException ("dependency descriptor must not be null"); 39 } 40 if (name == null) { 41 throw new NullPointerException ("name must not be null"); 42 } 43 if (type == null) { 44 throw new NullPointerException ("type must not be null"); 45 } 46 _dd = dd; 47 _id = new ArtifactId(dd.getDependencyId(), name, type, ext); 48 _includes = includes; 49 _url = url; 50 _patternMatcher = matcher; 51 } 52 53 public DefaultDependencyArtifactDescriptor(DefaultDependencyDescriptor dd, ArtifactId aid, boolean includes, PatternMatcher matcher) { 54 if (dd == null) { 55 throw new NullPointerException ("dependency descriptor must not be null"); 56 } 57 _dd = dd; 58 _id = aid; 59 _includes = includes; 60 _patternMatcher = matcher; 61 } 62 63 public boolean equals(Object obj) { 64 if (!(obj instanceof DependencyArtifactDescriptor)) { 65 return false; 66 } 67 DependencyArtifactDescriptor dad = (DependencyArtifactDescriptor)obj; 68 return getId().equals(dad.getId()); 69 } 70 71 public int hashCode() { 72 return getId().hashCode(); 73 } 74 75 80 public void addConfiguration(String conf) { 81 _confs.add(conf); 82 if (_includes) { 83 _dd.addDependencyArtifactIncludes(conf, this); 84 } else { 85 _dd.addDependencyArtifactExcludes(conf, this); 86 } 87 } 88 89 public DependencyDescriptor getDependency() { 90 return _dd; 91 } 92 93 public ArtifactId getId() { 94 return _id; 95 } 96 97 public String getName() { 98 return _id.getName(); 99 } 100 101 public String getType() { 102 return _id.getType(); 103 } 104 public String getExt() { 105 return _id.getExt(); 106 } 107 108 public String [] getConfigurations() { 109 return (String [])_confs.toArray(new String [_confs.size()]); 110 } 111 112 public PatternMatcher getMatcher() { 113 return _patternMatcher; 114 } 115 116 public URL getUrl() { 117 return _url; 118 } 119 120 public String toString() { 121 return (_includes?"I":"E")+":"+_id+"("+_confs+")"+(_url==null?"":_url.toString()); 122 } 123 } 124 | Popular Tags |