1 22 package org.jboss.mx.loading; 23 24 import java.util.*; 25 26 39 public class MBeanElement 40 { 41 43 45 49 public final static String MLET_DELEGATE_TO_CLR = "delegateToCLR"; 50 51 57 private Map properties = new HashMap(2); 58 59 62 private String code = null; 63 64 67 private String object = null; 68 69 72 private String name = null; 73 74 77 private String codebase = null; 78 79 82 private ArrayList archives = new ArrayList(); 83 84 87 private ArrayList versions = new ArrayList(); 88 89 92 private ArrayList argTypes = new ArrayList(); 93 94 97 private ArrayList argValues = new ArrayList(); 98 99 100 102 107 public String getCode() 108 { 109 return code; 110 } 111 112 119 public String getObject() 120 { 121 return object; 122 } 123 124 129 public String getName() 130 { 131 return name; 132 } 133 134 139 public List getArchives() 140 { 141 return archives; 142 } 143 144 149 public List getVersions() 150 { 151 return versions; 152 } 153 154 159 public String getCodebase() 160 { 161 return codebase; 162 } 163 164 170 public void setCode(String code) 171 { 172 this.code = trim(code); 173 if (this.code.endsWith(".class")) 174 this.code = this.code.substring(0, this.code.length() - 6); 175 } 176 177 184 public void setObject(String object) 185 { 186 this.object = trim(object); 187 } 188 189 195 public void setName(String name) 196 { 197 this.name = trim(name); 198 } 199 200 206 public void setCodebase(String url) 207 { 208 this.codebase = trim(url); 209 } 210 211 public void setArchive(String archive) 212 { 213 archive = trim(archive); 214 StringTokenizer tokenizer = new StringTokenizer(archive, " ,"); 215 216 while (tokenizer.hasMoreTokens()) 217 archives.add(tokenizer.nextToken()); 218 } 219 220 public void setVersion(String version) 221 { 222 version = trim(version); 223 StringTokenizer tokenizer = new StringTokenizer(version, " ,"); 224 225 while (tokenizer.hasMoreTokens()) 226 versions.add(tokenizer.nextToken()); 227 } 228 229 public void addArg(String type, String value) 230 { 231 argTypes.add(trim(type)); 232 argValues.add(trim(value)); 233 } 234 235 public String [] getConstructorTypes() 236 { 237 return (String [])argTypes.toArray(new String [0]); 238 } 239 240 public String [] getConstructorValues() 241 { 242 return (String [])argValues.toArray(new String [0]); 243 } 244 245 private String trim(String str) 247 { 248 if (str == null) 249 return str; 250 251 if (str.startsWith("=")) 253 str = str.substring(1, str.length()); 254 255 if (str.startsWith("\"") && str.endsWith("\"")) 256 return str.substring(1, str.length() - 1); 257 else 258 return str; 259 } 260 261 public void setProperty(String key, Object value) 262 { 263 if (key == null || key.equals("")) 264 throw new IllegalArgumentException ("null or empty string keys not allowed"); 265 if (value == null) 266 throw new IllegalArgumentException ("null values not allowed"); 267 268 properties.put(key, value); 269 } 270 271 public Object getProperty(String key) 272 { 273 return properties.get(key); 274 } 275 276 } 277 278 279 280 281 | Popular Tags |