Revision 37583 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

View differences:

DefaultPackageInfo.java
52 52
 */
53 53
public class DefaultPackageInfo implements PackageInfo {
54 54

  
55
    private String code = null;
56
    private String name = null;
57
    private String description = null;
58
    private Version version = null;
59
    // private int build = 0;
60
    private boolean official;
61
    private List<File> auxFiles = null;
62
    private String antScript = null;
63
    private String type = "unknow";
55
	private String code = null;
56
	private String name = null;
57
	private String description = null;
58
	private Version version = null;
59
	// private int build = 0;
60
	private boolean official;
61
	private List<File> auxFiles = null;
62
	private String antScript = null;
63
	private String type = "unknow";
64 64

  
65
    private String state = STATE.DEVEL;
66
    private String operatingSystem = OS.ALL;
67
    private String architecture = ARCH.ALL;
68
    private String javaVM = JVM.J1_5;
65
	private String state = STATE.DEVEL;
66
	private String operatingSystem = OS.ALL;
67
	private String architecture = ARCH.ALL;
68
	private String javaVM = JVM.J1_5;
69 69

  
70
    private String owner = "";
71
    private URL sources = null;
72
    private String gvSIGVersion = "";
70
	private String owner = "";
71
	private URL sources = null;
72
	private String gvSIGVersion = "";
73 73

  
74
//    private URL defaultDownloadURL = null;
75
    private String defaultDownloadURL = null;
74
	// private URL defaultDownloadURL = null;
75
	private String defaultDownloadURL = null;
76 76

  
77
    private String modelVersion = "1.0.1";
78
    private Dependencies dependencies = null;
79
    // private Set<String> categories = null;
80
    private List<String> categories = null;
77
	private String modelVersion = "1.0.1";
78
	private Dependencies dependencies = null;
79
	// private Set<String> categories = null;
80
	private List<String> categories = null;
81 81

  
82
    private URL webURL = null;
82
	private URL webURL = null;
83 83

  
84
    public DefaultPackageInfo() {
85
        super();
86
        auxFiles = new ArrayList<File>();
87
        this.version = new DefaultVersion().parse("0.0.1");
88
        this.dependencies = new DefaultDependencies();
89
        this.categories = new ArrayList<String>();
90
    }
84
	public DefaultPackageInfo() {
85
		super();
86
		auxFiles = new ArrayList<File>();
87
		this.version = new DefaultVersion().parse("0.0.1");
88
		this.dependencies = new DefaultDependencies();
89
		this.categories = new ArrayList<String>();
90
	}
91 91

  
92
    public String getCode() {
93
        return code;
94
    }
92
	public String getCode() {
93
		return code;
94
	}
95 95

  
96
    public String getID() {
97
        String id =
98
            this.getCode() + "#" + this.getVersion() + "#" + this.getBuild()
99
                + "#" + this.getOperatingSystem() + "#"
100
                + this.getArchitecture();
101
        return id;
102
    }
96
	public String getID() {
97
		String id = this.getCode() + "#" + this.getVersion() + "#"
98
				+ this.getBuild() + "#" + this.getOperatingSystem() + "#"
99
				+ this.getArchitecture();
100
		return id;
101
	}
103 102

  
104
    public String getName() {
105
        return name;
106
    }
103
	public String getName() {
104
		return name;
105
	}
107 106

  
108
    public String getDescription() {
109
        return description;
110
    }
107
	public String getDescription() {
108
		return description;
109
	}
111 110

  
112
    public Version getVersion() {
113
        return version;
114
    }
111
	public Version getVersion() {
112
		return version;
113
	}
115 114

  
116
    public int getBuild() {
117
        return this.version.getBuild();
118
    }
115
	public int getBuild() {
116
		return this.version.getBuild();
117
	}
119 118

  
120
    public String getState() {
121
        return state;
122
    }
119
	public String getState() {
120
		return state;
121
	}
123 122

  
124
    public boolean isOfficial() {
125
        return official;
126
    }
123
	public boolean isOfficial() {
124
		return official;
125
	}
127 126

  
128
    public void setCode(String code) {
129
        this.code = code;
130
    }
127
	public void setCode(String code) {
128
		this.code = code;
129
	}
131 130

  
132
    public void setName(String name) {
133
        this.name = name;
134
    }
131
	public void setName(String name) {
132
		this.name = name;
133
	}
135 134

  
136
    public void setDescription(String description) {
137
        this.description = description;
138
    }
135
	public void setDescription(String description) {
136
		this.description = description;
137
	}
139 138

  
140
    public void setVersion(String version) {
141
        if (version == null) {
142
            return;
143
        }
144
        int prev = this.version.getBuild();
145
        this.version.parse(version);
146
        int curr = this.version.getBuild();
147
        if (prev != 0 && curr == 0) {
148
            this.version.setBuild(prev);
149
        }
150
    }
139
	public void setVersion(String version) {
140
		if (version == null) {
141
			return;
142
		}
143
		int prev = this.version.getBuild();
144
		this.version.parse(version);
145
		int curr = this.version.getBuild();
146
		if (prev != 0 && curr == 0) {
147
			this.version.setBuild(prev);
148
		}
149
	}
151 150

  
152
    public void setVersion(Version version) {
153
        try {
154
            int prev = this.version.getBuild();
155
            this.version = (Version) version.clone();
156
            int curr = this.version.getBuild();
157
            if (prev != 0 && curr == 0) {
158
                this.version.setBuild(prev);
159
            }
160
        } catch (CloneNotSupportedException e) {
161
            throw new RuntimeException(e);
162
        }
163
    }
151
	public void setVersion(Version version) {
152
		try {
153
			int prev = this.version.getBuild();
154
			this.version = (Version) version.clone();
155
			int curr = this.version.getBuild();
156
			if (prev != 0 && curr == 0) {
157
				this.version.setBuild(prev);
158
			}
159
		} catch (CloneNotSupportedException e) {
160
			throw new RuntimeException(e);
161
		}
162
	}
164 163

  
165
    public void setBuild(int build) {
166
        this.version.setBuild(build);
167
    }
164
	public void setBuild(int build) {
165
		this.version.setBuild(build);
166
	}
168 167

  
169
    public void setState(String state) {
170
        this.state = state;
171
    }
168
	public void setState(String state) {
169
		this.state = state;
170
	}
172 171

  
173
    public void setOfficial(boolean official) {
174
        this.official = official;
175
    }
172
	public void setOfficial(boolean official) {
173
		this.official = official;
174
	}
176 175

  
177
    public String getOperatingSystem() {
178
        return operatingSystem;
179
    }
176
	public String getOperatingSystem() {
177
		return operatingSystem;
178
	}
180 179

  
181
    public void setOperatingSystem(String operatingSystem) {
182
        this.operatingSystem = operatingSystem;
183
    }
180
	public void setOperatingSystem(String operatingSystem) {
181
		this.operatingSystem = operatingSystem;
182
	}
184 183

  
185
    public String getArchitecture() {
186
        return architecture;
187
    }
184
	public String getArchitecture() {
185
		return architecture;
186
	}
188 187

  
189
    public void setArchitecture(String architecture) {
190
        this.architecture = architecture;
191
    }
188
	public void setArchitecture(String architecture) {
189
		this.architecture = architecture;
190
	}
192 191

  
193
    public String getJavaVM() {
194
        return javaVM;
195
    }
192
	public String getJavaVM() {
193
		return javaVM;
194
	}
196 195

  
197
    public void setJavaVM(String javaVM) {
198
        this.javaVM = javaVM;
199
    }
196
	public void setJavaVM(String javaVM) {
197
		this.javaVM = javaVM;
198
	}
200 199

  
201
    public String getAntScript() {
202
        return antScript;
203
    }
200
	public String getAntScript() {
201
		return antScript;
202
	}
204 203

  
205
    public void setAntScript(String antScript) {
206
        this.antScript = antScript;
207
    }
204
	public void setAntScript(String antScript) {
205
		this.antScript = antScript;
206
	}
208 207

  
209
    public String getType() {
210
        return type;
211
    }
208
	public String getType() {
209
		return type;
210
	}
212 211

  
213
    public void setType(String type) {
214
        this.type = type;
215
    }
212
	public void setType(String type) {
213
		this.type = type;
214
	}
216 215

  
217
    public String getGvSIGVersion() {
218
        return gvSIGVersion;
219
    }
216
	public String getGvSIGVersion() {
217
		return gvSIGVersion;
218
	}
220 219

  
221
    public void setGvSIGVersion(String gvSIGVersion) {
222
        this.gvSIGVersion = gvSIGVersion;
223
    }
220
	public void setGvSIGVersion(String gvSIGVersion) {
221
		this.gvSIGVersion = gvSIGVersion;
222
	}
224 223

  
225
    public URL getDownloadURL() {
226
        URL url = null;
227
        try {
228
            url = new URL(defaultDownloadURL);
229
        } catch (MalformedURLException e) {
230
            // TODO Auto-generated catch block
231
            e.printStackTrace();
232
        }
233
        return url;
234
    }
235
    
236
    public String getDownloadURLAsString() {
237
        return this.defaultDownloadURL;
238
    }
224
	public URL getDownloadURL() {
225
		URL url = null;
226
		try {
227
			url = new URL(defaultDownloadURL);
228
		} catch (MalformedURLException e) {
229
			// TODO Auto-generated catch block
230
			e.printStackTrace();
231
		}
232
		return url;
233
	}
239 234

  
240
    public URL getDownloadURL(URL baseURL) {
241
        String URLString = baseURL.toString();
235
	public String getDownloadURLAsString() {
236
		return this.defaultDownloadURL;
237
	}
242 238

  
243
        if (!URLString.endsWith("/")) {
244
            URLString += "/";
245
        }
246
        URLString += ("dists/" + getGvSIGVersion() + "/" + "packages.gvspki");
247
        try {
248
            return new URL(URLString);
249
        } catch (MalformedURLException e) {
250
            // TODO Auto-generated catch block
251
            e.printStackTrace();
252
            return null;
253
        }
254
    }
239
	public URL getDownloadURL(URL baseURL) {
240
		String URLString = baseURL.toString();
255 241

  
256
    public void setDownloadURL(URL defaultDownloadURL) {
257
        this.defaultDownloadURL = defaultDownloadURL.toString();
258
    }
259
    
260
    public void setDownloadURL(String defaultDownloadURL) {
261
        this.defaultDownloadURL = defaultDownloadURL;
262
    }
242
		if (!URLString.endsWith("/")) {
243
			URLString += "/";
244
		}
245
		URLString += ("dists/" + getGvSIGVersion() + "/" + "packages.gvspki");
246
		try {
247
			return new URL(URLString);
248
		} catch (MalformedURLException e) {
249
			// TODO Auto-generated catch block
250
			e.printStackTrace();
251
			return null;
252
		}
253
	}
263 254

  
264
    public String getModelVersion() {
265
        return modelVersion;
266
    }
255
	public void setDownloadURL(URL defaultDownloadURL) {
256
		this.defaultDownloadURL = defaultDownloadURL.toString();
257
	}
267 258

  
268
    public void setModelVersion(String modelVersion) {
269
        this.modelVersion = modelVersion;
270
    }
259
	public void setDownloadURL(String defaultDownloadURL) {
260
		this.defaultDownloadURL = defaultDownloadURL;
261
	}
271 262

  
272
    public String getOwner() {
273
        return owner;
274
    }
263
	public String getModelVersion() {
264
		return modelVersion;
265
	}
275 266

  
276
    public void setOwner(String owner) {
277
        this.owner = owner;
278
    }
267
	public void setModelVersion(String modelVersion) {
268
		this.modelVersion = modelVersion;
269
	}
279 270

  
280
    public URL getSourcesURL() {
281
        return sources;
282
    }
271
	public String getOwner() {
272
		return owner;
273
	}
283 274

  
284
    public void setSourcesURL(URL sources) {
285
        this.sources = sources;
286
    }
275
	public void setOwner(String owner) {
276
		this.owner = owner;
277
	}
287 278

  
288
    @Override
289
    public String toString() {
290
        StringBuffer buffer = new StringBuffer(super.toString()).append(" (");
279
	public URL getSourcesURL() {
280
		return sources;
281
	}
291 282

  
292
        append(buffer, InstallerInfoTags.CODE, getCode());
293
        append(buffer, InstallerInfoTags.NAME, getName());
294
        append(buffer, InstallerInfoTags.DESCRIPTION, getDescription());
295
        append(buffer, InstallerInfoTags.GVSIG_VERSION, getGvSIGVersion());
296
        append(buffer, InstallerInfoTags.VERSION, getVersion());
297
        append(buffer, InstallerInfoTags.BUILD, getBuild());
298
        append(buffer, InstallerInfoTags.OS, getOperatingSystem());
299
        append(buffer, InstallerInfoTags.ARCHITECTURE, getArchitecture());
300
        append(buffer, InstallerInfoTags.JVM, getJavaVM());
301
        append(buffer, InstallerInfoTags.DOWNLOAD_URL, getDownloadURL());
302
        append(buffer, InstallerInfoTags.STATE, getState());
303
        append(buffer, InstallerInfoTags.OFFICIAL, isOfficial());
304
        append(buffer, InstallerInfoTags.TYPE, getType());
305
        append(buffer, InstallerInfoTags.MODEL_VERSION, getModelVersion());
306
        append(buffer, InstallerInfoTags.OWNER, getOwner());
307
        append(buffer, InstallerInfoTags.SOURCES_URL, getSourcesURL());
308
        append(buffer, InstallerInfoTags.DEPENDENCIES, getDependencies());
309
        append(buffer, InstallerInfoTags.WEB_URL, getWebURL());
310
        append(buffer, InstallerInfoTags.WEB_URL, getCategories());
283
	public void setSourcesURL(URL sources) {
284
		this.sources = sources;
285
	}
311 286

  
312
        return buffer.append(')').toString();
313
    }
287
	@Override
288
	public String toString() {
289
		StringBuffer buffer = new StringBuffer(super.toString()).append(" (");
314 290

  
315
    public String toStringCompact() {
316
        // type code version state os arch jvm dep
317
        return String
318
            .format(
319
                "%1$-8.8s %2$-40s %3$-20.20s %4$-5.5s %5$-5.5s %6$-6.6s %7$-5.5s %8$s",
320
                this.type, this.code, this.version, this.state,
321
                this.operatingSystem, this.architecture, this.javaVM,
322
                this.dependencies);
323
    }
291
		append(buffer, InstallerInfoTags.CODE, getCode());
292
		append(buffer, InstallerInfoTags.NAME, getName());
293
		append(buffer, InstallerInfoTags.DESCRIPTION, getDescription());
294
		append(buffer, InstallerInfoTags.GVSIG_VERSION, getGvSIGVersion());
295
		append(buffer, InstallerInfoTags.VERSION, getVersion());
296
		append(buffer, InstallerInfoTags.BUILD, getBuild());
297
		append(buffer, InstallerInfoTags.OS, getOperatingSystem());
298
		append(buffer, InstallerInfoTags.ARCHITECTURE, getArchitecture());
299
		append(buffer, InstallerInfoTags.JVM, getJavaVM());
300
		append(buffer, InstallerInfoTags.DOWNLOAD_URL, getDownloadURL());
301
		append(buffer, InstallerInfoTags.STATE, getState());
302
		append(buffer, InstallerInfoTags.OFFICIAL, isOfficial());
303
		append(buffer, InstallerInfoTags.TYPE, getType());
304
		append(buffer, InstallerInfoTags.MODEL_VERSION, getModelVersion());
305
		append(buffer, InstallerInfoTags.OWNER, getOwner());
306
		append(buffer, InstallerInfoTags.SOURCES_URL, getSourcesURL());
307
		append(buffer, InstallerInfoTags.DEPENDENCIES, getDependencies());
308
		append(buffer, InstallerInfoTags.WEB_URL, getWebURL());
309
		append(buffer, InstallerInfoTags.CATEGORIES, getCategories());
324 310

  
325
    private DefaultPackageInfo append(StringBuffer buffer, String key,
326
        Object value) {
327
        buffer.append("\n\t").append(key).append(": ").append(
328
            value == null ? "" : value);
329
        return this;
330
    }
311
		return buffer.append(')').toString();
312
	}
331 313

  
332
    @Override
333
    public Object clone() throws CloneNotSupportedException {
334
        DefaultPackageInfo clone = (DefaultPackageInfo) super.clone();
335
        clone.auxFiles = new ArrayList<File>(auxFiles);
336
        return clone;
337
    }
314
	public String toStringCompact() {
315
		// type code version state os arch jvm dep
316
		return String
317
				.format(
318
						"%1$-8.8s %2$-40s %3$-20.20s %4$-5.5s %5$-5.5s %6$-6.6s %7$-5.5s %8$s",
319
						this.type, this.code, this.version, this.state,
320
						this.operatingSystem, this.architecture, this.javaVM,
321
						this.dependencies);
322
	}
338 323

  
339
    public File downloadFile() throws InstallPackageServiceException {
340
        return this.downloadFile(null);
341
    }
324
	private DefaultPackageInfo append(StringBuffer buffer, String key,
325
			Object value) {
326
		buffer.append("\n\t").append(key).append(": ").append(
327
				value == null ? "" : value);
328
		return this;
329
	}
342 330

  
343
    public class FileDownloadException extends InstallPackageServiceException {
331
	@Override
332
	public Object clone() throws CloneNotSupportedException {
333
		DefaultPackageInfo clone = (DefaultPackageInfo) super.clone();
334
		clone.auxFiles = new ArrayList<File>(auxFiles);
335
		return clone;
336
	}
344 337

  
345
        private static final long serialVersionUID = 8640183295766490512L;
338
	public File downloadFile() throws InstallPackageServiceException {
339
		return this.downloadFile(null);
340
	}
346 341

  
347
        private static final String message = "File '%(url)s' download error";
342
	public class FileDownloadException extends InstallPackageServiceException {
348 343

  
349
        private static final String KEY = "_File_XurlX_download_error";
344
		private static final long serialVersionUID = 8640183295766490512L;
350 345

  
351
        public FileDownloadException(URL url, IOException e) {
352
            super(message, e, KEY, serialVersionUID);
353
            setValue("url", url.toString());
354
        }
346
		private static final String message = "File '%(url)s' download error";
355 347

  
356
    }
348
		private static final String KEY = "_File_XurlX_download_error";
357 349

  
358
    public File downloadFile(SimpleTaskStatus taskStatus)
359
        throws InstallPackageServiceException {
360
        Download download = new Download(taskStatus);
361
        try {
362
            return download.downloadFile(this.getDownloadURL(), null);
363
        } catch (IOException e) {
364
            throw new FileDownloadException(this.getDownloadURL(), e);
365
        }
366
    }
350
		public FileDownloadException(URL url, IOException e) {
351
			super(message, e, KEY, serialVersionUID);
352
			setValue("url", url.toString());
353
		}
367 354

  
368
    public void addFileToCopy(File file) {
369
        auxFiles.add(file);
370
    }
355
	}
371 356

  
372
    public File getFileToCopy(int i) {
373
        return auxFiles.get(i);
374
    }
357
	public File downloadFile(SimpleTaskStatus taskStatus)
358
			throws InstallPackageServiceException {
359
		Download download = new Download(taskStatus);
360
		try {
361
			return download.downloadFile(this.getDownloadURL(), null);
362
		} catch (IOException e) {
363
			throw new FileDownloadException(this.getDownloadURL(), e);
364
		}
365
	}
375 366

  
376
    public void removeFileToCopy(File file) {
377
        auxFiles.remove(file);
378
    }
367
	public void addFileToCopy(File file) {
368
		auxFiles.add(file);
369
	}
379 370

  
380
    public void clearFilesToCopy() {
381
        auxFiles.clear();
382
    }
371
	public File getFileToCopy(int i) {
372
		return auxFiles.get(i);
373
	}
383 374

  
384
    public List<File> getFilesToCopy() {
385
        return auxFiles;
386
    }
375
	public void removeFileToCopy(File file) {
376
		auxFiles.remove(file);
377
	}
387 378

  
388
    public boolean removeInstallFolder(File folder) {
389
        DeleteFile delete = new DeleteFile();
390
        boolean success = delete.delete(folder);
391
        setAntScript(null);
392
        clearFilesToCopy();
393
        return success;
394
    }
379
	public void clearFilesToCopy() {
380
		auxFiles.clear();
381
	}
395 382

  
396
    public boolean removeFilesFolder(File folder) {
397
        DeleteFile delete = new DeleteFile();
398
        return delete.delete(folder);
399
    }
383
	public List<File> getFilesToCopy() {
384
		return auxFiles;
385
	}
400 386

  
401
    public boolean matchID(String string) {
402
        String id = this.getID();
403
        String[] stringParts = string.split("#");
387
	public boolean removeInstallFolder(File folder) {
388
		DeleteFile delete = new DeleteFile();
389
		boolean success = delete.delete(folder);
390
		setAntScript(null);
391
		clearFilesToCopy();
392
		return success;
393
	}
404 394

  
405
        if (stringParts.length == 1) {
395
	public boolean removeFilesFolder(File folder) {
396
		DeleteFile delete = new DeleteFile();
397
		return delete.delete(folder);
398
	}
406 399

  
407
            if (stringParts[0].equals(this.getCode())) {
408
                return true;
409
            } else {
410
                return false;
411
            }
412
        } else {
413
            if (stringParts.length == 2) {
414
                if ((stringParts[0] + stringParts[1])
415
                    .equals((this.getCode() + this.getVersion()))) {
416
                    return true;
417
                } else {
418
                    return true;
419
                }
420
            } else {
421
                if (string.equals(id)) {
422
                    return true;
423
                } else {
424
                    return false;
425
                }
426
            }
427
        }
400
	public boolean matchID(String string) {
401
		String id = this.getID();
402
		String[] stringParts = string.split("#");
428 403

  
429
    }
404
		if (stringParts.length == 1) {
430 405

  
431
    public Dependencies getDependencies() {
432
        return this.dependencies;
433
    }
406
			if (stringParts[0].equals(this.getCode())) {
407
				return true;
408
			} else {
409
				return false;
410
			}
411
		} else {
412
			if (stringParts.length == 2) {
413
				if ((stringParts[0] + stringParts[1])
414
						.equals((this.getCode() + this.getVersion()))) {
415
					return true;
416
				} else {
417
					return true;
418
				}
419
			} else {
420
				if (string.equals(id)) {
421
					return true;
422
				} else {
423
					return false;
424
				}
425
			}
426
		}
434 427

  
435
    public void setDependencies(Dependencies dependencies) {
436
        this.dependencies = dependencies;
437
    }
428
	}
438 429

  
439
    public void setDependencies(String dependencies) {
440
        if (dependencies == null) {
441
            this.dependencies = null;
442
        } else {
443
            this.dependencies = new DefaultDependencies().parse(dependencies);
444
        }
445
    }
430
	public Dependencies getDependencies() {
431
		return this.dependencies;
432
	}
446 433

  
447
    public boolean equals(Object obj) {
448
        PackageInfo other;
449
        try {
450
            other = (PackageInfo) obj;
451
        } catch (Exception e) {
452
            return false;
453
        }
454
        if (!code.equalsIgnoreCase(other.getCode())) {
455
            return false;
456
        }
457
        if (!version.check("=", other.getVersion())) {
458
            return false;
459
        }
460
        if (!operatingSystem.equalsIgnoreCase(other.getOperatingSystem())) {
461
            return false;
462
        }
463
        if (!gvSIGVersion.equalsIgnoreCase(other.getGvSIGVersion())) {
464
            return false;
465
        }
466
        if (!state.equalsIgnoreCase(other.getState())) {
467
            return false;
468
        }
469
        if (!architecture.equalsIgnoreCase(other.getArchitecture())) {
470
            return false;
471
        }
472
        if (!javaVM.equalsIgnoreCase(other.getJavaVM())) {
473
            return false;
474
        }
475
        if (!type.equalsIgnoreCase(other.getType())) {
476
            return false;
477
        }
478
        if (official != other.isOfficial()) {
479
            return false;
480
        }
481
        return true;
482
    }
434
	public void setDependencies(Dependencies dependencies) {
435
		this.dependencies = dependencies;
436
	}
483 437

  
484
    public URL getWebURL() {
485
        return webURL;
486
    }
438
	public void setDependencies(String dependencies) {
439
		if (dependencies == null) {
440
			this.dependencies = null;
441
		} else {
442
			this.dependencies = new DefaultDependencies().parse(dependencies);
443
		}
444
	}
487 445

  
488
    public void setWebURL(URL webURL) {
489
        this.webURL = webURL;
490
    }
446
	public boolean equals(Object obj) {
447
		PackageInfo other;
448
		try {
449
			other = (PackageInfo) obj;
450
		} catch (Exception e) {
451
			return false;
452
		}
453
		if (!code.equalsIgnoreCase(other.getCode())) {
454
			return false;
455
		}
456
		if (!version.check("=", other.getVersion())) {
457
			return false;
458
		}
459
		if (!operatingSystem.equalsIgnoreCase(other.getOperatingSystem())) {
460
			return false;
461
		}
462
		if (!gvSIGVersion.equalsIgnoreCase(other.getGvSIGVersion())) {
463
			return false;
464
		}
465
		if (!state.equalsIgnoreCase(other.getState())) {
466
			return false;
467
		}
468
		if (!architecture.equalsIgnoreCase(other.getArchitecture())) {
469
			return false;
470
		}
471
		if (!javaVM.equalsIgnoreCase(other.getJavaVM())) {
472
			return false;
473
		}
474
		if (!type.equalsIgnoreCase(other.getType())) {
475
			return false;
476
		}
477
		if (official != other.isOfficial()) {
478
			return false;
479
		}
480
		return true;
481
	}
491 482

  
492
    public List<String> getCategories() {
493
        return this.categories;
494
    }
483
	public URL getWebURL() {
484
		return webURL;
485
	}
495 486

  
496
    public void setCategories(List<String> categoriesList) {
497
        for (int i = 0; i < categoriesList.size(); i++) {
498
            if (!this.categories.contains(categoriesList.get(i))) {
499
                this.categories.add(categoriesList.get(i));
500
            }
501
        }
502
    }
487
	public void setWebURL(URL webURL) {
488
		this.webURL = webURL;
489
	}
503 490

  
504
    public String getCategoriesAsString() {
505
        String categoriesString = "";
506
        for (int i = 0; i < this.categories.size(); i++) {
507
            categoriesString += this.categories.get(i) + ", ";
508
        }
509
        return categoriesString;
510
    }
491
	public List<String> getCategories() {
492
		return this.categories;
493
	}
511 494

  
512
    public void addCategoriesAsString(String categoriesString) {
513
        categoriesString.trim();
514
        String[] cadena = categoriesString.split(",");
495
	public void setCategories(List<String> categoriesList) {
496
		for (int i = 0; i < categoriesList.size(); i++) {
497
			if (!this.categories.contains(categoriesList.get(i))) {
498
				this.categories.add(categoriesList.get(i));
499
			}
500
		}
501
	}
515 502

  
516
        for (int i = 0; i < cadena.length; i++) {
517
            String trimCadena = cadena[i].trim();
518
            if ((!this.categories.contains(trimCadena)) && (trimCadena != "")) {
519
                this.categories.add(trimCadena);
520
            }
521
        }
503
	public String getCategoriesAsString() {
504
		String categoriesString = "";
505
		for (int i = 0; i < this.categories.size(); i++) {
506
			categoriesString += this.categories.get(i) + ", ";
507
		}
508
		return categoriesString;
509
	}
522 510

  
523
    }
511
	public void addCategoriesAsString(String categoriesString) {
512
		categoriesString.trim();
513
		String[] cadena = categoriesString.split(",");
524 514

  
515
		for (int i = 0; i < cadena.length; i++) {
516
			String trimCadena = cadena[i].trim();
517
			if ((!this.categories.contains(trimCadena)) && (trimCadena != "")) {
518
				this.categories.add(trimCadena);
519
			}
520
		}
521

  
522
	}
523

  
525 524
}

Also available in: Unified diff