1 12 package org.eclipse.update.core.model; 13 14 import java.net.MalformedURLException ; 15 import java.net.URL ; 16 17 import org.eclipse.update.core.Site; 18 import org.eclipse.update.internal.core.UpdateCore; 19 import org.eclipse.update.internal.core.UpdateManagerUtils; 20 21 37 public class FeatureReferenceModel extends ModelObject { 38 39 private String type; 40 private URL url; 41 private String urlString; 42 private String featureId; 43 private String featureVersion; 44 private SiteModel site; 45 private String label; 46 private String localizedLabel; 47 48 private URL bundleURL; 50 private URL base; 51 private boolean resolved = false; 52 private String os; 53 private String ws; 54 private String nl; 55 private String arch; 56 private String patch; 57 58 63 public FeatureReferenceModel() { 64 super(); 65 } 66 67 71 public FeatureReferenceModel(FeatureReferenceModel ref) { 72 setFeatureIdentifier(ref.getFeatureIdentifier()); 73 setFeatureVersion(ref.getFeatureVersion()); 74 setType(ref.getType()); 75 setSiteModel(ref.getSiteModel()); 76 setLabel(ref.getLabel()); 77 setWS(ref.getWS()); 78 setOS(ref.getOS()); 79 setArch(ref.getOSArch()); 80 setNL(ref.getNL()); 81 } 82 83 91 public boolean equals(Object object) { 92 93 if (object == null) 94 return false; 95 if (getURL() == null) 96 return false; 97 98 if (!(object instanceof FeatureReferenceModel)) 99 return false; 100 101 FeatureReferenceModel f = (FeatureReferenceModel) object; 102 103 return UpdateManagerUtils.sameURL(getURL(), f.getURL()); 104 } 105 106 113 public String getType() { 114 return type; 115 } 116 117 123 public SiteModel getSiteModel() { 124 return site; 125 } 126 127 133 public String getURLString() { 134 return urlString; 135 } 136 137 143 public URL getURL() { 144 delayedResolve(); 145 return url; 146 } 147 148 155 public String getFeatureIdentifier() { 156 return featureId; 157 } 158 159 166 public String getFeatureVersion() { 167 return featureVersion; 168 } 169 170 177 public void setType(String type) { 178 assertIsWriteable(); 179 this.type = type; 180 } 181 182 189 public void setSiteModel(SiteModel site) { 190 assertIsWriteable(); 191 this.site = site; 192 } 193 194 201 public void setURLString(String urlString) { 202 assertIsWriteable(); 203 this.urlString = urlString; 204 this.url = null; 205 } 206 207 214 public void setFeatureIdentifier(String featureId) { 215 assertIsWriteable(); 216 this.featureId = featureId; 217 } 218 219 226 public void setFeatureVersion(String featureVersion) { 227 assertIsWriteable(); 228 this.featureVersion = featureVersion; 229 } 230 231 243 public void resolve(URL base,URL bundleURL) throws MalformedURLException { 244 this.base = base; 245 this.bundleURL = bundleURL; 246 } 247 248 private void delayedResolve() { 249 250 if (resolved) 252 return; 253 254 localizedLabel = resolveNLString(bundleURL, label); 256 try { 257 url = resolveURL(base, bundleURL, urlString); 258 resolved = true; 259 } catch (MalformedURLException e){ 260 UpdateCore.warn("",e); } 262 } 263 264 267 public String toString() { 268 StringBuffer buffer = new StringBuffer (); 269 buffer.append(getClass().toString() + " :"); buffer.append(" at "); if (url != null) 272 buffer.append(url.toExternalForm()); 273 return buffer.toString(); 274 } 275 276 279 protected String getPropertyName() { 280 return Site.SITE_FILE; 281 } 282 283 290 public String getLabel() { 291 delayedResolve(); 292 if (localizedLabel != null) 293 return localizedLabel; 294 else 295 return label; 296 } 297 298 304 public String getLabelNonLocalized() { 305 return label; 306 } 307 308 312 public void setLabel(String label) { 313 this.label = label; 314 } 315 316 322 public String getOS() { 323 return os; 324 } 325 326 327 333 public String getWS() { 334 return ws; 335 } 336 337 338 344 public String getOSArch() { 345 return arch; 346 } 347 348 349 355 public String getNL() { 356 return nl; 357 } 358 359 366 public void setOS(String os) { 367 assertIsWriteable(); 368 this.os = os; 369 } 370 371 372 379 public void setWS(String ws) { 380 assertIsWriteable(); 381 this.ws = ws; 382 } 383 384 385 392 public void setNL(String nl) { 393 assertIsWriteable(); 394 this.nl = nl; 395 } 396 397 398 405 public void setArch(String arch) { 406 assertIsWriteable(); 407 this.arch = arch; 408 } 409 410 413 public String getPatch() { 414 return patch; 415 } 416 417 418 421 public void setPatch(String patch) { 422 this.patch = patch; 423 } 424 425 } 426 | Popular Tags |