1 11 package org.eclipse.update.core.model; 12 13 import java.net.MalformedURLException ; 14 import java.net.URL ; 15 16 import org.eclipse.update.core.IURLEntry; 17 import org.eclipse.update.internal.core.UpdateCore; 18 19 35 36 public class URLEntryModel extends ModelObject { 37 38 private String annotation; 39 private String localizedAnnotation; 40 private String urlString; 41 private URL url; 42 43 private int type = IURLEntry.UPDATE_SITE; 44 45 private URL bundleURL; 47 private URL base; 48 private boolean resolved=false; 49 50 55 public URLEntryModel() { 56 super(); 57 } 58 59 66 public String getAnnotation() { 67 delayedResolve(); 68 if (localizedAnnotation != null) 69 return localizedAnnotation; 70 else 71 return annotation; 72 } 73 74 80 public String getAnnotationNonLocalized() { 81 return annotation; 82 } 83 84 90 public String getURLString() { 91 delayedResolve(); 92 return urlString; 93 } 94 95 101 public URL getURL() { 102 delayedResolve(); 103 return url; 104 } 105 106 113 public void setAnnotation(String annotation) { 114 assertIsWriteable(); 115 this.annotation = annotation; 116 this.localizedAnnotation = null; 117 } 118 119 126 public void setURLString(String urlString) { 127 assertIsWriteable(); 128 this.urlString = urlString; 129 this.url = null; 130 } 131 132 144 public void resolve(URL base, URL bundleURL) throws MalformedURLException { 145 this.base = base; 146 this.bundleURL = bundleURL; 147 } 148 149 150 private void delayedResolve() { 151 152 if (resolved)return; 154 155 resolved= true; 156 localizedAnnotation = resolveNLString(bundleURL, annotation); 158 try { 159 url = resolveURL(base,bundleURL, urlString); 160 } catch (MalformedURLException e){ 161 UpdateCore.warn("",e); } 163 } 164 165 170 public int getType() { 171 return type; 172 } 173 174 178 public void setType(int i) { 179 type = i; 180 } 181 } 182 | Popular Tags |