- Timestamp:
- Apr 7, 2011 7:02:29 PM (14 years ago)
- Branches:
- axis_example, compt_changes, info-ops, master
- Children:
- 50b2af2
- Parents:
- 3c159d0
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
axis/ParseTopdl.java
r3c159d0 rc6f04f7 1 1 // WSDL generated classes 2 2 import edu.isi.www.fedd_types.*; 3 import edu.isi.www.fedd_wsdl.*;4 3 import edu.isi.www.topdl.*; 5 4 … … 19 18 protected class TopdlHandler extends DefaultHandler { 20 19 protected String topName; 20 21 // Topology parameters 21 22 protected TopologyType topo; 22 23 protected ElementType element; … … 26 27 protected OtherType other; 27 28 29 // Many elements have a name 28 30 protected String name; 29 31 32 // CPU parameters 30 33 protected String type; 31 34 protected int ncpus; 35 36 // Operatingsystem parameters 37 protected String version; 38 protected String distribution; 39 protected String distributionversion; 40 41 // Software parameters 42 protected String install; 43 protected String location; 44 45 // Storage parameters 46 protected double amount; 47 protected PersistenceType persistence; 48 49 // Interface Parameters 50 protected Vector<String> ifsubs; 51 protected edu.isi.www.topdl.CapacityType cap; 52 protected LatencyType lat; 53 54 // Capacity parameters 55 protected double rate; 56 protected edu.isi.www.topdl.KindType kind; 57 58 // Latency parameters (shares kind) 59 protected double time; 60 61 // Testbed parameters (shares interfaces, type) 62 protected String uri; 63 64 // Segment parameters (shares interfaces, type, uri) 65 protected IDType id; 66 // IDType parameters 67 protected byte[] uuid; 68 protected byte[] fedid; 69 protected String id_uri; 70 protected String localname; 71 protected String kerberosUsername; 72 protected boolean inID; 73 74 // Attribute parameters 32 75 protected String aname; 33 76 protected String aval; … … 37 80 protected Vector<AttributeType> attrs; 38 81 protected Vector<CpuType> cpus; 39 82 protected Vector<OperatingsystemType> oses; 83 protected Vector<SoftwareType> software; 84 protected Vector<StorageType> storage; 85 protected Vector<InterfaceType> interfaces; 86 87 protected Set<String> attrElements; 88 protected Stack<Vector<AttributeType>> attrStack; 40 89 protected char[] c; 41 90 … … 50 99 51 100 type = null; 52 name = aname = aval = null; 101 name = null; 102 ncpus = 1; 103 104 version = distribution = distributionversion = null; 105 106 install = location = null; 107 108 amount = 0.0; 109 persistence = null; 110 111 ifsubs = new Vector<String>(); 112 cap = null; 113 lat = null; 114 115 rate = 0.0; 116 kind = null; 117 118 time = 0.0; 119 120 uri = null; 121 122 id = null; 123 124 uuid = fedid = null; 125 id_uri = localname = kerberosUsername = null; 126 inID = false; 127 128 aname = aval = null; 53 129 54 130 elements = new Vector<ElementType>(); 55 131 subs = new Vector<SubstrateType>(); 56 132 attrs = new Vector<AttributeType>(); 133 oses = new Vector<OperatingsystemType>(); 134 software = new Vector<SoftwareType>(); 135 storage = new Vector<StorageType>(); 136 interfaces = new Vector<InterfaceType>(); 137 138 attrElements = new TreeSet<String>(); 139 for (String e : new String[] { 140 topName, "computer", "cpu", "os", "software", "storage", 141 "interface", "segment", "testbed", "other", "substrates" 142 }) attrElements.add(e); 143 144 attrStack = new Stack<Vector<AttributeType>>(); 57 145 c = new char[0]; 58 146 } … … 62 150 63 151 c = new char[0]; 152 if ( attrElements.contains(qn) ) { 153 attrStack.push(attrs); 154 attrs = new Vector<AttributeType>(); 155 } 156 if (qn.equals("id")) inID = true; 157 if (qn.equals("cpu")) { 158 String n = a.getValue("count"); 159 if ( n != null) ncpus = Integer.valueOf(n); 160 else ncpus = 1; 161 } 64 162 } 65 163 … … 74 172 elements = new Vector<ElementType>(); 75 173 subs = new Vector<SubstrateType>(); 76 attrs = new Vector<AttributeType>();174 attrs = attrStack.pop(); 77 175 } 78 176 else if (qn.equals("element")) { … … 86 184 comp = new ComputerType(name, 87 185 cpus.toArray(new CpuType[cpus.size()]), 88 null, null, null, null, null); 186 oses.toArray(new OperatingsystemType[oses.size()]), 187 software.toArray(new SoftwareType[software.size()]), 188 storage.toArray(new StorageType[storage.size()]), 189 interfaces.toArray( 190 new InterfaceType[interfaces.size()]), 191 attrs.toArray(new AttributeType[attrs.size()])); 89 192 name = null; 90 193 cpus = new Vector<CpuType>(); 91 } 92 else if (qn.equals("testbed")) { 93 tb = new TestbedType(null, null, null, null); 94 } 95 else if (qn.equals("segment")) { 96 seg = new SegmentType(null, null, null, null, null); 97 } 98 else if (qn.equals("other")) { 99 other = new OtherType(null, null); 194 oses = new Vector<OperatingsystemType>(); 195 software = new Vector<SoftwareType>(); 196 storage = new Vector<StorageType>(); 197 interfaces = new Vector<InterfaceType>(); 198 attrs = attrStack.pop(); 100 199 } 101 200 else if (qn.equals("cpu")) { 102 201 cpus.add(new CpuType(type, 103 attrs.toArray(new AttributeType[attrs.size()]), 1));202 attrs.toArray(new AttributeType[attrs.size()]), ncpus)); 104 203 type = null; 105 attrs = new Vector<AttributeType>(); 106 } 107 else if (qn.equals("type")) { type = new String(c); } 204 attrs = attrStack.pop(); 205 ncpus = 1; 206 } 207 else if (qn.equals("type")) { type = new String(c).trim(); } 208 else if (qn.equals("os")) { 209 oses.add(new OperatingsystemType(name, version, 210 distribution, distributionversion, 211 attrs.toArray(new AttributeType[attrs.size()]))); 212 name = version = distribution = distributionversion = null; 213 attrs = attrStack.pop(); 214 } 215 else if ( qn.equals("version")) { version = new String(c).trim(); } 216 else if ( qn.equals("distribution")) { 217 distribution = new String(c).trim(); 218 } 219 else if ( qn.equals("distributionversion")) { 220 distributionversion = new String(c).trim(); 221 } 222 else if (qn.equals("software")) { 223 software.add(new SoftwareType(location, install, 224 attrs.toArray(new AttributeType[attrs.size()]))); 225 location = install = null; 226 attrs = attrStack.pop(); 227 } 228 else if ( qn.equals("location")) { 229 location = new String(c).trim(); 230 } 231 else if ( qn.equals("install")) { install = new String(c).trim(); } 232 else if (qn.equals("storage")) { 233 storage.add(new StorageType(amount, persistence, 234 attrs.toArray(new AttributeType[attrs.size()]))); 235 amount = 0.0; 236 persistence = null; 237 attrs = attrStack.pop(); 238 } 239 else if ( qn.equals("amount")) { 240 amount = Double.valueOf(new String(c)); 241 } 242 else if ( qn.equals("persistence")) { 243 persistence = PersistenceType.fromValue(new String(c)); 244 } 245 else if (qn.equals("interface")) { 246 interfaces.add(new InterfaceType( 247 ifsubs.toArray(new String[ifsubs.size()]), 248 name, 249 cap, lat, 250 attrs.toArray(new AttributeType[attrs.size()]))); 251 ifsubs = new Vector<String>(); 252 cap = null; 253 lat = null; 254 attrs = attrStack.pop(); 255 } 256 else if (qn.equals("substrate")) { 257 ifsubs.add(new String(c).trim()); 258 } 259 else if (qn.equals("capacity")) { 260 cap = new edu.isi.www.topdl.CapacityType(rate, kind); 261 rate = 0.0; 262 kind = null; 263 } 264 else if ( qn.equals("rate")) { 265 rate = Double.valueOf(new String(c)); 266 } 267 else if ( qn.equals("kind")) { 268 kind = edu.isi.www.topdl.KindType.fromValue(new String(c)); 269 } 270 else if (qn.equals("latency")) { 271 lat = new LatencyType(time, kind); 272 time = 0.0; 273 kind = null; 274 } 275 else if ( qn.equals("time")) { 276 time = Double.valueOf(new String(c)); 277 } 278 else if (qn.equals("testbed")) { 279 tb = new TestbedType(uri, type, 280 interfaces.toArray( 281 new InterfaceType[interfaces.size()]), 282 attrs.toArray(new AttributeType[attrs.size()])); 283 uri = type = null; 284 interfaces = new Vector<InterfaceType>(); 285 attrs = attrStack.pop(); 286 } 287 else if (qn.equals("uri")) { 288 if (inID) id_uri = new String(c).trim(); 289 else uri = new String(c).trim(); 290 } 291 else if (qn.equals("segment")) { 292 seg = new SegmentType(id, type, uri, 293 interfaces.toArray( 294 new InterfaceType[interfaces.size()]), 295 attrs.toArray(new AttributeType[attrs.size()])); 296 id = null; 297 type = uri = null; 298 interfaces = new Vector<InterfaceType>(); 299 attrs = attrStack.pop(); 300 } 301 else if (qn.equals("id")) { 302 id = new IDType(uuid, fedid, id_uri, localname, 303 kerberosUsername); 304 uuid = null; 305 fedid = null; 306 id_uri = null; 307 localname = null; 308 kerberosUsername = null; 309 inID = false; 310 } 311 else if (qn.equals("uuid")) { 312 uuid = new String(c).trim().getBytes(); 313 } 314 else if (qn.equals("fedid")) { 315 fedid = new String(c).trim().getBytes(); 316 } 317 else if (qn.equals("localname")) { 318 localname = new String(c).trim(); 319 } 320 else if (qn.equals("kerberosUsername")) { 321 kerberosUsername = new String(c).trim(); 322 } 323 else if (qn.equals("other")) { 324 other = new OtherType( 325 interfaces.toArray( 326 new InterfaceType[interfaces.size()]), 327 attrs.toArray(new AttributeType[attrs.size()])); 328 interfaces = new Vector<InterfaceType>(); 329 attrs = attrStack.pop(); 330 } 331 else if (qn.equals("substrates")) { 332 subs.add(new SubstrateType(name, cap, lat, 333 attrs.toArray(new AttributeType[attrs.size()]))); 334 name = null; 335 cap = null; 336 lat = null; 337 attrs = attrStack.pop(); 338 } 108 339 else if (qn.equals("attribute")) { 109 340 if ( aname != null && aval != null ) { … … 111 342 aname = aval = null; 112 343 } 113 else { aname = new String(c) ; }114 } 115 else if ( qn.equals("value")) { aval = new String(c) ; }116 else if ( qn.equals("name")) { name = new String(c) ; }344 else { aname = new String(c).trim(); } 345 } 346 else if ( qn.equals("value")) { aval = new String(c).trim(); } 347 else if ( qn.equals("name")) { name = new String(c).trim(); } 117 348 118 349 c = new char[0]; 350 } 351 352 /** 353 * Collect text. 354 */ 355 public void characters(char[] ch, int s, int l) { 356 char[] nc = new char[c.length + l]; 357 System.arraycopy(c, 0, nc, 0, c.length); 358 System.arraycopy(ch, s, nc, c.length, l); 359 c = nc; 119 360 } 120 361 }
Note: See TracChangeset
for help on using the changeset viewer.