1 7 8 package javax.management.loading; 9 10 11 13 import java.net.URL ; 14 import java.net.MalformedURLException ; 15 import java.util.Map ; 16 17 114 class MLetContent { 115 116 117 122 private Map attributes; 123 124 128 private URL documentURL; 129 130 134 private URL baseURL; 135 136 137 144 public MLetContent(URL url, Map attributes) { 145 this.documentURL = url; 146 this.attributes = attributes; 147 148 String att = (String )getParameter("codebase"); 151 if (att != null) { 152 if (!att.endsWith("/")) { 153 att += "/"; 154 } 155 try { 156 baseURL = new URL (documentURL, att); 157 } catch (MalformedURLException e) { 158 } 160 } 161 if (baseURL == null) { 162 String file = documentURL.getFile(); 163 int i = file.lastIndexOf('/'); 164 if (i > 0 && i < file.length() - 1) { 165 try { 166 baseURL = new URL (documentURL, file.substring(0, i + 1)); 167 } catch (MalformedURLException e) { 168 } 170 } 171 } 172 if (baseURL == null) 173 baseURL = documentURL; 174 175 } 176 177 180 185 public Map getAttributes() { 186 return attributes; 187 } 188 189 193 public URL getDocumentBase() { 194 return documentURL; 195 } 196 197 201 public URL getCodeBase() { 202 return baseURL; 203 } 204 205 210 public String getJarFiles() { 211 return (String )getParameter("archive"); 212 } 213 214 220 public String getCode() { 221 return (String )getParameter("code"); 222 } 223 224 230 public String getSerializedObject() { 231 return (String )getParameter("object"); 232 } 233 234 240 public String getName() { 241 return (String )getParameter("name"); 242 } 243 244 245 251 public String getVersion() { 252 return (String )getParameter("version"); 253 } 254 255 263 public Object getParameter(String name) { 264 return (Object ) attributes.get(name.toLowerCase()); 265 } 266 267 } 268 | Popular Tags |