1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package net.sourceforge.javadpkg.impl;
20
21 import java.util.ArrayList;
22 import java.util.List;
23
24 import net.sourceforge.javadpkg.SymbolsEntry;
25 import net.sourceforge.javadpkg.control.PackageDependency;
26 import net.sourceforge.javadpkg.control.PackageVersion;
27
28
29
30
31
32
33
34
35
36
37 public class SymbolsEntryImpl implements SymbolsEntry {
38
39
40
41 private String libraryName;
42
43 private String dependencyValue;
44
45 private PackageDependency dependency;
46
47
48 private String alternativeDependencyValue;
49
50 private List<Symbol> symbols;
51
52 private PackageDependency buildDependsPackage;
53
54
55
56
57
58
59
60
61
62
63
64
65 private SymbolsEntryImpl(String libraryName) {
66 super();
67
68 if (libraryName == null)
69 throw new IllegalArgumentException("Argument libraryName is null.");
70
71 this.libraryName = libraryName;
72 this.dependencyValue = null;
73 this.dependency = null;
74
75 this.alternativeDependencyValue = null;
76 this.symbols = new ArrayList<>();
77 }
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92 public SymbolsEntryImpl(String libraryName, String dependencyValue) {
93 this(libraryName);
94
95 if (dependencyValue == null)
96 throw new IllegalArgumentException("Argument dependencyValue is null.");
97
98 this.dependencyValue = dependencyValue;
99 }
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114 public SymbolsEntryImpl(String libraryName, PackageDependency dependency) {
115 this(libraryName);
116
117 if (dependency == null)
118 throw new IllegalArgumentException("Argument dependency is null.");
119
120 this.dependency = dependency;
121 }
122
123
124
125
126
127
128
129
130
131
132 public void setAlternativeDependencyValue(String alternativeDependencyValue) {
133 this.alternativeDependencyValue = alternativeDependencyValue;
134 }
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149 public void addSymbol(String name, String version, PackageVersion upstreamVersion) {
150 Symbol symbol;
151
152
153 if (name == null)
154 throw new IllegalArgumentException("Argument name is null.");
155 if (version == null)
156 throw new IllegalArgumentException("Argument version is null.");
157 if (upstreamVersion == null)
158 throw new IllegalArgumentException("Argument upstreamVersion is null.");
159
160 symbol = new Symbol(name, version, upstreamVersion);
161 this.symbols.add(symbol);
162 }
163
164
165
166
167
168
169
170
171
172
173 public void setBuildDependsPackage(PackageDependency buildDependsPackage) {
174 this.buildDependsPackage = buildDependsPackage;
175 }
176
177
178 @Override
179 public String getText() {
180 StringBuilder sb;
181
182
183 sb = new StringBuilder();
184 sb.append(this.libraryName);
185 sb.append(' ');
186 if (this.dependency == null)
187 sb.append(this.dependencyValue);
188 else {
189
190 }
191 if (this.alternativeDependencyValue != null) {
192 sb.append("\n| ");
193 sb.append(this.alternativeDependencyValue);
194 }
195 if (this.symbols.isEmpty())
196 sb.append('\n');
197 else {
198 for (Symbol symbol : this.symbols) {
199 sb.append("\n ");
200 sb.append(symbol.getName());
201 sb.append('@');
202 sb.append(symbol.getVersion());
203 sb.append(' ');
204 sb.append(symbol.getUpstreamVersion().getText());
205 }
206 }
207 if (this.buildDependsPackage != null) {
208
209 }
210 return sb.toString();
211 }
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230 private class Symbol {
231
232
233
234 private String name;
235
236 private String version;
237
238 private PackageVersion upstreamVersion;
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253 public Symbol(String name, String version, PackageVersion upstreamVersion) {
254 super();
255
256 this.name = name;
257 this.version = version;
258 this.upstreamVersion = upstreamVersion;
259 }
260
261
262
263
264
265
266
267
268
269 public String getName() {
270 return this.name;
271 }
272
273
274
275
276
277
278
279
280
281 public String getVersion() {
282 return this.version;
283 }
284
285
286
287
288
289
290
291
292
293 public PackageVersion getUpstreamVersion() {
294 return this.upstreamVersion;
295 }
296
297
298 }
299
300
301 }