Revision 36114 branches/v2_0_0_prep/extensions/org.gvsig.installer/org.gvsig.installer.lib/org.gvsig.installer.lib.impl/src/main/java/org/gvsig/installer/lib/impl/DefaultPackageInfo.java
DefaultPackageInfo.java | ||
---|---|---|
55 | 55 |
private String name = null; |
56 | 56 |
private String description = null; |
57 | 57 |
private Version version = null; |
58 |
// private int build = 0;
|
|
58 |
// private int build = 0;
|
|
59 | 59 |
private boolean official; |
60 | 60 |
private List<File> auxFiles = null; |
61 | 61 |
private String antScript = null; |
... | ... | |
68 | 68 |
|
69 | 69 |
private String owner = ""; |
70 | 70 |
private URL sources = null; |
71 |
private String gvSIGVersion="";
|
|
71 |
private String gvSIGVersion = "";
|
|
72 | 72 |
|
73 | 73 |
private URL defaultDownloadURL = null; |
74 | 74 |
|
... | ... | |
129 | 129 |
} |
130 | 130 |
|
131 | 131 |
public void setVersion(String version) { |
132 |
int prev = this.version.getBuild();
|
|
132 |
int prev = this.version.getBuild();
|
|
133 | 133 |
this.version.parse(version); |
134 |
int curr = this.version.getBuild();
|
|
135 |
if (prev!=0 && curr==0){
|
|
136 |
this.version.setBuild(prev);
|
|
137 |
}
|
|
134 |
int curr = this.version.getBuild();
|
|
135 |
if (prev != 0 && curr == 0) {
|
|
136 |
this.version.setBuild(prev);
|
|
137 |
}
|
|
138 | 138 |
} |
139 | 139 |
|
140 | 140 |
public void setVersion(Version version) { |
141 | 141 |
try { |
142 |
int prev = this.version.getBuild();
|
|
143 |
this.version = (Version) version.clone();
|
|
144 |
int curr = this.version.getBuild();
|
|
145 |
if (prev!=0 && curr==0){
|
|
146 |
this.version.setBuild(prev);
|
|
147 |
}
|
|
148 |
} catch (CloneNotSupportedException e) {
|
|
149 |
throw new RuntimeException(e);
|
|
150 |
}
|
|
142 |
int prev = this.version.getBuild();
|
|
143 |
this.version = (Version) version.clone();
|
|
144 |
int curr = this.version.getBuild();
|
|
145 |
if (prev != 0 && curr == 0) {
|
|
146 |
this.version.setBuild(prev);
|
|
147 |
}
|
|
148 |
} catch (CloneNotSupportedException e) {
|
|
149 |
throw new RuntimeException(e);
|
|
150 |
}
|
|
151 | 151 |
} |
152 | 152 |
|
153 | 153 |
public void setBuild(int build) { |
154 |
this.version.setBuild(build);
|
|
154 |
this.version.setBuild(build);
|
|
155 | 155 |
} |
156 | 156 |
|
157 | 157 |
public void setState(String state) { |
... | ... | |
225 | 225 |
public void setModelVersion(String modelVersion) { |
226 | 226 |
this.modelVersion = modelVersion; |
227 | 227 |
} |
228 |
|
|
228 |
|
|
229 | 229 |
public String getOwner() { |
230 | 230 |
return owner; |
231 | 231 |
} |
... | ... | |
263 | 263 |
append(buffer, InstallerInfoTags.OWNER, getOwner()); |
264 | 264 |
append(buffer, InstallerInfoTags.SOURCES_URL, getSourcesURL()); |
265 | 265 |
append(buffer, InstallerInfoTags.DEPENDENCIES, getDependencies()); |
266 |
|
|
267 |
|
|
266 |
|
|
268 | 267 |
return buffer.append(')').toString(); |
269 | 268 |
} |
270 | 269 |
|
271 | 270 |
public String toStringCompact() { |
272 |
// type code version state os arch jvm dep |
|
273 |
return String.format("%1$-8.8s %2$-40s %3$-20.20s %4$-5.5s %5$-5.5s %6$-6.6s %7$-5.5s %8$s", |
|
274 |
this.type, |
|
275 |
this.code, |
|
276 |
this.version, |
|
277 |
this.state, |
|
278 |
this.operatingSystem, |
|
279 |
this.architecture, |
|
280 |
this.javaVM, |
|
281 |
this.dependencies |
|
282 |
); |
|
271 |
// type code version state os arch jvm dep |
|
272 |
return String |
|
273 |
.format( |
|
274 |
"%1$-8.8s %2$-40s %3$-20.20s %4$-5.5s %5$-5.5s %6$-6.6s %7$-5.5s %8$s", |
|
275 |
this.type, this.code, this.version, this.state, |
|
276 |
this.operatingSystem, this.architecture, this.javaVM, |
|
277 |
this.dependencies); |
|
283 | 278 |
} |
284 |
|
|
279 |
|
|
285 | 280 |
private DefaultPackageInfo append(StringBuffer buffer, String key, |
286 | 281 |
Object value) { |
287 | 282 |
buffer.append("\n\t").append(key).append(": ").append( |
... | ... | |
321 | 316 |
try { |
322 | 317 |
return download.downloadFile(this.getDownloadURL(), null); |
323 | 318 |
} catch (IOException e) { |
324 |
throw new FileDownloadException(this.getDownloadURL(), e);
|
|
319 |
throw new FileDownloadException(this.getDownloadURL(), e);
|
|
325 | 320 |
} |
326 | 321 |
} |
327 |
|
|
322 |
|
|
328 | 323 |
public void addFileToCopy(File file) { |
329 | 324 |
auxFiles.add(file); |
330 | 325 |
} |
331 |
|
|
326 |
|
|
332 | 327 |
public File getFileToCopy(int i) { |
333 | 328 |
return auxFiles.get(i); |
334 | 329 |
} |
335 |
|
|
330 |
|
|
336 | 331 |
public void removeFileToCopy(File file) { |
337 |
auxFiles.remove(file);
|
|
332 |
auxFiles.remove(file); |
|
338 | 333 |
} |
339 | 334 |
|
340 | 335 |
public void clearFilesToCopy() { |
... | ... | |
357 | 352 |
DeleteFile delete = new DeleteFile(); |
358 | 353 |
return delete.delete(folder); |
359 | 354 |
} |
360 |
|
|
355 |
|
|
361 | 356 |
public boolean matchID(String string) { |
362 |
String code = this.getID();
|
|
357 |
String id = this.getID();
|
|
363 | 358 |
String[] stringParts = string.split("#"); |
364 | 359 |
|
365 |
if (stringParts[0] == code) { |
|
366 |
return true; |
|
367 |
} else |
|
368 |
if (stringParts[0] + "#" + stringParts[1] == code) { |
|
360 |
if (stringParts.length == 1) { |
|
361 |
|
|
362 |
if (stringParts[0].equals(this.getCode())) { |
|
369 | 363 |
return true; |
370 |
} else |
|
371 |
if (string == code) { |
|
364 |
} else { |
|
365 |
return false; |
|
366 |
} |
|
367 |
} else { |
|
368 |
if (stringParts.length == 2) { |
|
369 |
if ((stringParts[0] + stringParts[1]).equals((this.getCode() |
|
370 |
+ this.getVersion()))) { |
|
372 | 371 |
return true; |
373 |
} else |
|
372 |
} else { |
|
373 |
return true; |
|
374 |
} |
|
375 |
} else { |
|
376 |
if (string.equals(id)) { |
|
377 |
return true; |
|
378 |
} else { |
|
374 | 379 |
return false; |
380 |
} |
|
381 |
} |
|
382 |
} |
|
375 | 383 |
|
376 | 384 |
} |
377 |
|
|
378 |
public Dependencies getDependencies() { |
|
379 |
return this.dependencies; |
|
380 |
} |
|
381 |
|
|
382 |
public void setDependencies(Dependencies dependencies) { |
|
383 |
this.dependencies = dependencies; |
|
384 |
} |
|
385 | 385 |
|
386 |
public void setDependencies(String dependencies) { |
|
387 |
if( dependencies == null ) { |
|
388 |
this.dependencies = null; |
|
389 |
} else { |
|
390 |
this.dependencies = new DefaultDependencies().parse(dependencies); |
|
391 |
} |
|
392 |
} |
|
386 |
public Dependencies getDependencies() { |
|
387 |
return this.dependencies; |
|
388 |
} |
|
393 | 389 |
|
394 |
public boolean equals(Object obj) { |
|
395 |
PackageInfo other; |
|
396 |
try { |
|
397 |
other = (PackageInfo) obj; |
|
398 |
} catch(Exception e) { |
|
399 |
return false; |
|
400 |
} |
|
401 |
if( !code.equalsIgnoreCase(other.getCode())) { |
|
402 |
return false; |
|
403 |
} |
|
404 |
if( !version.check("=", other.getVersion())) { |
|
405 |
return false; |
|
406 |
} |
|
407 |
if( !operatingSystem.equalsIgnoreCase(other.getOperatingSystem())) { |
|
408 |
return false; |
|
409 |
} |
|
410 |
if( !gvSIGVersion.equalsIgnoreCase(other.getGvSIGVersion())) { |
|
411 |
return false; |
|
412 |
} |
|
413 |
if( !state.equalsIgnoreCase(other.getState())) { |
|
414 |
return false; |
|
415 |
} |
|
416 |
if( !architecture.equalsIgnoreCase(other.getArchitecture())) { |
|
417 |
return false; |
|
418 |
} |
|
419 |
if( !javaVM.equalsIgnoreCase(other.getJavaVM())) { |
|
420 |
return false; |
|
421 |
} |
|
422 |
if( !type.equalsIgnoreCase(other.getType())) { |
|
423 |
return false; |
|
424 |
} |
|
425 |
if( official!=other.isOfficial()) { |
|
426 |
return false; |
|
427 |
} |
|
428 |
return true; |
|
429 |
} |
|
390 |
public void setDependencies(Dependencies dependencies) { |
|
391 |
this.dependencies = dependencies; |
|
392 |
} |
|
430 | 393 |
|
431 |
|
|
432 |
|
|
394 |
public void setDependencies(String dependencies) { |
|
395 |
if (dependencies == null) { |
|
396 |
this.dependencies = null; |
|
397 |
} else { |
|
398 |
this.dependencies = new DefaultDependencies().parse(dependencies); |
|
399 |
} |
|
400 |
} |
|
401 |
|
|
402 |
public boolean equals(Object obj) { |
|
403 |
PackageInfo other; |
|
404 |
try { |
|
405 |
other = (PackageInfo) obj; |
|
406 |
} catch (Exception e) { |
|
407 |
return false; |
|
408 |
} |
|
409 |
if (!code.equalsIgnoreCase(other.getCode())) { |
|
410 |
return false; |
|
411 |
} |
|
412 |
if (!version.check("=", other.getVersion())) { |
|
413 |
return false; |
|
414 |
} |
|
415 |
if (!operatingSystem.equalsIgnoreCase(other.getOperatingSystem())) { |
|
416 |
return false; |
|
417 |
} |
|
418 |
if (!gvSIGVersion.equalsIgnoreCase(other.getGvSIGVersion())) { |
|
419 |
return false; |
|
420 |
} |
|
421 |
if (!state.equalsIgnoreCase(other.getState())) { |
|
422 |
return false; |
|
423 |
} |
|
424 |
if (!architecture.equalsIgnoreCase(other.getArchitecture())) { |
|
425 |
return false; |
|
426 |
} |
|
427 |
if (!javaVM.equalsIgnoreCase(other.getJavaVM())) { |
|
428 |
return false; |
|
429 |
} |
|
430 |
if (!type.equalsIgnoreCase(other.getType())) { |
|
431 |
return false; |
|
432 |
} |
|
433 |
if (official != other.isOfficial()) { |
|
434 |
return false; |
|
435 |
} |
|
436 |
return true; |
|
437 |
} |
|
438 |
|
|
433 | 439 |
} |
Also available in: Unified diff