1
2
3
4
5
6 package org.repoweb.pom;
7 import java.util.ArrayList;
8 import java.util.List;
9 /***
10 * Describe a project dependency.
11 */
12 public class Dependency implements ArtifactInfo {
13 private String _artifactId;
14 private String _groupId;
15 private String _version;
16 private String _url;
17 private List _properties;
18 private String _jar;
19 private String _type;
20
21 public Dependency() {}
22
23
24 public Dependency(String groupId, String artifactId, String version) {
25 this._groupId = groupId;
26 this._artifactId = artifactId;
27 this._version = version;
28 }
29
30 public String getArtifactId() {
31 return _artifactId;
32 }
33
34
35 public void setArtifactId(String artifactId) {
36 _artifactId = artifactId;
37 }
38
39
40 public String getGroupId() {
41 return _groupId;
42 }
43
44
45 public void setGroupId(String groupId) {
46 _groupId = groupId;
47 }
48
49
50 public String getVersion() {
51 return _version;
52 }
53
54
55 public boolean isOverridden() {
56 return getJar() != null;
57 }
58
59
60 public void setVersion(String version) {
61 _version = version;
62 }
63
64
65 public String getUrl() {
66 return _url;
67 }
68
69
70 public void setUrl(String url) {
71 _url = url;
72 }
73
74
75 public List getProperties() {
76 return _properties;
77 }
78
79
80 public void setProperties(List properties) {
81 _properties = properties;
82 }
83
84
85 public void addProperty(String id, String value) {
86 if (_properties == null) {
87 _properties = new ArrayList();
88 }
89 _properties.add(new Property(id, value));
90 }
91
92
93 public String getType() {
94 if (_type != null) {
95 return _type;
96 }
97 else {
98 return "jar";
99 }
100 }
101
102
103 public String getFileName() {
104 if (isOverridden()) {
105 return getJar();
106 }
107 else {
108 return getArtifactId() + "-" + getVersion() + "."
109 + (getType() != null ? getType() : "jar");
110 }
111 }
112
113
114 public String getJar() {
115 return _jar;
116 }
117
118
119 public void setJar(String jar) {
120 _jar = jar;
121 }
122
123
124 public void setType(String type) {
125 _type = type;
126 }
127
128
129 public boolean isDefaultType() {
130 return "jar".equals(getType());
131 }
132 }