1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 package org.coach.idltree; 26 27 import javax.xml.parsers.DocumentBuilder ; 28 import javax.xml.parsers.DocumentBuilderFactory ; 29 import javax.xml.parsers.FactoryConfigurationError ; 30 import javax.xml.parsers.ParserConfigurationException ; 31 import org.xml.sax.SAXException ; 32 import org.xml.sax.SAXParseException ; 33 import org.xml.sax.InputSource ; 34 import org.w3c.dom.*; 35 import javax.swing.tree.*; 36 37 import java.util.*; 38 import java.io.*; 39 import java.lang.reflect.*; 40 41 public class XmlNode { 42 static org.objectweb.ccm.IDL3.Repository repository; 43 static org.objectweb.openccm.ir3.api.ComponentRepository repositoryRef; 44 static Hashtable repositoryCache = new Hashtable(); 45 static org.omg.CORBA.ORB orb = null; 46 47 static { 48 try { 49 if ( orb == null ){ 50 orb = org.objectweb.openccm.corba.TheORB.getORB(); 51 } 52 repositoryRef = 54 org.objectweb.openccm.ir3.api.ComponentRepositoryHelper.narrow( 55 org.objectweb.openccm.corba.TheInterfaceRepository.getRepository()); 56 57 repository = new org.objectweb.ccm.IDL3.Repository(repositoryRef.as_IDL2_repository()); 59 60 } catch (Throwable ex) { 61 ex.printStackTrace(); 62 } 63 } 64 65 public static void setOrb(org.omg.CORBA.ORB ob) { 66 orb = ob; 67 } 68 69 static Node getNode(String xml) { 70 Node node = null; 71 DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); 72 factory.setValidating(true); 73 try { 74 DocumentBuilder builder = factory.newDocumentBuilder(); 75 InputSource is = new InputSource (new StringReader(xml)); 76 is.setSystemId("file://" + System.getProperty("dsc.home") + "/etc/"); 77 node = builder.parse(is); 78 node.normalize(); 79 } catch (SAXParseException spe) { 80 throw new RuntimeException ("Xml parsing error, line " + spe.getLineNumber() + ", uri " + spe.getSystemId() + " " + spe.getMessage()); 81 } catch (Exception x) { 82 x.printStackTrace(); 83 } 84 return firstChildElement(node); 85 } 86 87 static String getId(Node n) { 88 return getAttribute(n, "id"); 89 } 90 91 static String getName(Node n) { 92 return getAttribute(n, "name"); 93 } 94 95 static int getLength(Node n) { 96 String a = getAttribute(n, "length"); 97 try { 98 return Integer.parseInt(a); 99 } catch (Exception e) { 100 throw new RuntimeException ("unable to read length attribute"); 101 } 102 } 103 104 static String getValue(Node n) { 105 return getAttribute(n, "value"); 106 } 107 108 113 static String [] getOperations(String id) { 114 String [] operations = new String [0]; 115 if (repositoryRef != null) { 116 try { 117 org.omg.CORBA.Contained c = lookup(id); 118 HashSet v = new HashSet(); 119 addOperations(v, id); 120 operations = new String [v.size()]; 121 v.toArray(operations); 122 } catch (Exception ex) { 123 System.err.println(ex.toString()); 124 } 125 } 126 return operations; 127 } 128 129 static void addOperations(HashSet v, String id) { 130 if (repositoryRef != null) { 131 try { 132 org.omg.CORBA.Contained c = lookup(id); 133 org.omg.CORBA.InterfaceDef interfaceDef = org.omg.CORBA.InterfaceDefHelper.narrow(c); 134 org.omg.CORBA.InterfaceDefPackage.FullInterfaceDescription desc = interfaceDef.describe_interface(); 135 for (int i = 0; i < desc.operations.length; i++) { 136 v.add(desc.operations[i].name); 137 } 138 for (int i = 0; i < desc.attributes.length; i++) { 139 v.add("_get_" + desc.attributes[i].name); 140 if (desc.attributes[i].mode == org.omg.CORBA.AttributeMode.ATTR_NORMAL) { 141 v.add("_set_" + desc.attributes[i].name); 142 } 143 } 144 for(int i = 0; i < desc.base_interfaces.length; i++) { 145 addOperations(v, desc.base_interfaces[i]); 146 } 147 } catch (Exception ex) { 148 System.err.println(ex.toString()); 149 } 150 } 151 } 152 153 static void addOperations(Hashtable v, String id) { 154 if (repositoryRef != null) { 155 try { 156 org.omg.CORBA.Contained c = lookup(id); 157 org.omg.CORBA.InterfaceDef interfaceDef = org.omg.CORBA.InterfaceDefHelper.narrow(c); 158 org.omg.CORBA.InterfaceDefPackage.FullInterfaceDescription desc = interfaceDef.describe_interface(); 159 for (int i = 0; i < desc.operations.length; i++) { 160 v.put(desc.operations[i].name, desc.operations[i]); 161 } 162 for (int i = 0; i < desc.attributes.length; i++) { 163 v.put("_get_" + desc.attributes[i].name, desc.attributes[i]); 164 if (desc.attributes[i].mode == org.omg.CORBA.AttributeMode.ATTR_NORMAL) { 165 v.put("_set_" + desc.attributes[i].name, desc.attributes[i]); 166 } 167 } 168 for(int i = 0; i < desc.base_interfaces.length; i++) { 169 addOperations(v, desc.base_interfaces[i]); 170 } 171 } catch (Exception ex) { 172 System.err.println(ex.toString()); 173 } 174 } 175 } 176 177 182 static String [] getParameterNames(String id, String name) { 183 String [] names = new String [0]; 184 if (repositoryRef != null) { 185 try { 186 Hashtable t = new Hashtable(); 187 addOperations(t, id); 188 Object desc = t.get(name); 189 if (desc == null) { 190 throw new RuntimeException ("no operation " + name + " found in interface " + id); 191 } 192 if (desc instanceof org.omg.CORBA.OperationDescription ) { 193 org.omg.CORBA.OperationDescription opDesc = (org.omg.CORBA.OperationDescription )desc; 194 names = new String [opDesc.parameters.length + 1]; 195 for (int j = 0; j < opDesc.parameters.length; j++) { 196 names[j] = opDesc.parameters[j].name; 197 } 198 if (opDesc.mode == org.omg.CORBA.OperationMode.OP_ONEWAY) { 199 names[names.length - 1] = "oneway"; 200 } else { 201 names[names.length - 1] = "return"; 202 } 203 } 204 if (desc instanceof org.omg.CORBA.AttributeDescription ) { 205 if (name.startsWith("_set_")) { 206 names = new String [] { 207 "val", 208 "return" 209 }; 210 } else { 211 names = new String [] { 212 "return" 213 }; 214 } 215 } 216 } catch (Exception ex) { 217 System.err.println(ex.toString()); 218 } 219 } 220 return names; 221 } 222 223 229 static String [] getParameterDirections(String id, String name) { 230 String [] directions = new String [0]; 231 if (repositoryRef != null) { 232 try { 233 Hashtable t = new Hashtable(); 234 addOperations(t, id); 235 Object desc = t.get(name); 236 if (desc == null) { 237 throw new RuntimeException ("no operation " + name + " found in interface " + id); 238 } 239 if (desc instanceof org.omg.CORBA.OperationDescription ) { 240 org.omg.CORBA.OperationDescription opDesc = (org.omg.CORBA.OperationDescription )desc; 241 directions = new String [opDesc.parameters.length + 1]; 242 for (int j = 0; j < opDesc.parameters.length; j++) { 243 directions[j] = parameterMode(opDesc.parameters[j].mode); 244 } 245 if (opDesc.mode == org.omg.CORBA.OperationMode.OP_ONEWAY) { 246 directions[directions.length - 1] = "oneway"; 247 } else { 248 directions[directions.length - 1] = "return"; 249 } 250 } 251 if (desc instanceof org.omg.CORBA.AttributeDescription ) { 252 if (name.startsWith("_set_")) { 253 directions = new String [] { 254 "in", 255 "return" 256 }; 257 } else { 258 directions = new String [] { 259 "return" 260 }; 261 } 262 } 263 } catch (Exception ex) { 264 System.err.println(ex.toString()); 265 } 266 } 267 268 return directions; 269 } 270 271 private static String parameterMode(org.omg.CORBA.ParameterMode m) { 272 if (m == org.omg.CORBA.ParameterMode.PARAM_IN) { 273 return "in"; 274 } 275 if (m == org.omg.CORBA.ParameterMode.PARAM_OUT) { 276 return "out"; 277 } 278 if (m == org.omg.CORBA.ParameterMode.PARAM_INOUT) { 279 return "inout"; 280 } 281 return ""; 282 } 283 284 291 static String [] getParameterTypes(String id, String name) { 292 String [] types = new String [0]; 293 if (repositoryRef != null) { 294 try { 295 Hashtable t = new Hashtable(); 296 addOperations(t, id); 297 Object desc = t.get(name); 298 if (desc == null) { 299 throw new RuntimeException ("no operation " + name + " found in interface " + id); 300 } 301 if (desc instanceof org.omg.CORBA.OperationDescription ) { 302 org.omg.CORBA.OperationDescription opDesc = (org.omg.CORBA.OperationDescription )desc; 303 types = new String [opDesc.parameters.length + 1]; 304 for (int j = 0; j < opDesc.parameters.length; j++) { 305 types[j] = parameterType(opDesc.parameters[j].type); 306 } 307 if (opDesc.mode == org.omg.CORBA.OperationMode.OP_ONEWAY) { 308 types[types.length - 1] = ""; 309 } else { 310 types[types.length - 1] = parameterType(opDesc.result); 311 } 312 } 313 if (desc instanceof org.omg.CORBA.AttributeDescription ) { 314 org.omg.CORBA.AttributeDescription attDesc = (org.omg.CORBA.AttributeDescription )desc; 315 if (name.startsWith("_set_")) { 316 types = new String [] { 317 parameterType(attDesc.type), 318 "void" 319 }; 320 } else { 321 types = new String [] { 322 parameterType(attDesc.type) 323 }; 324 } 325 } 326 } catch (Exception ex) { 327 System.err.println(ex.toString()); 328 } 329 } 330 return types; 331 } 332 333 static String [] getParameterExceptions(String id, String name) { 334 String [] exceptions = new String [0]; 335 if (repositoryRef != null) { 336 try { 337 Hashtable t = new Hashtable(); 338 addOperations(t, id); 339 Object desc = t.get(name); 340 if (desc == null) { 341 throw new RuntimeException ("no operation " + name + " found in interface " + id); 342 } 343 if (desc instanceof org.omg.CORBA.OperationDescription ) { 344 org.omg.CORBA.OperationDescription opDesc = (org.omg.CORBA.OperationDescription )desc; 345 exceptions = new String [opDesc.exceptions.length]; 346 for (int j = 0; j < opDesc.exceptions.length; j++) { 347 exceptions[j] = opDesc.exceptions[j].id; 348 } 349 } 350 } catch (Exception ex) { 351 System.err.println(ex.toString()); 352 } 353 } 354 355 return exceptions; 356 } 357 358 private static String parameterType(org.omg.CORBA.TypeCode tc) { 359 try { 360 switch (tc.kind().value()) { 361 case org.omg.CORBA.TCKind._tk_any: { 362 return "any"; 363 } 364 case org.omg.CORBA.TCKind._tk_octet: { 365 return "octet"; 366 } 367 case org.omg.CORBA.TCKind._tk_short: { 368 return "short"; 369 } 370 case org.omg.CORBA.TCKind._tk_ushort: { 371 return "ushort"; 372 } 373 case org.omg.CORBA.TCKind._tk_long: { 374 return "long"; 375 } 376 case org.omg.CORBA.TCKind._tk_ulong: { 377 return "ulong"; 378 } 379 case org.omg.CORBA.TCKind._tk_longlong: { 380 return "longlong"; 381 } 382 case org.omg.CORBA.TCKind._tk_ulonglong: { 383 return "ulonglong"; 384 } 385 case org.omg.CORBA.TCKind._tk_float: { 386 return "float"; 387 } 388 case org.omg.CORBA.TCKind._tk_double: { 389 return "double"; 390 } 391 case org.omg.CORBA.TCKind._tk_longdouble: { 392 return "longdouble"; 393 } 394 case org.omg.CORBA.TCKind._tk_boolean: { 395 return "boolean"; 396 } 397 case org.omg.CORBA.TCKind._tk_char: { 398 return "char"; 399 } 400 case org.omg.CORBA.TCKind._tk_wchar: { 401 return "wchar"; 402 } 403 case org.omg.CORBA.TCKind._tk_string: { 404 return "string"; 405 } 406 case org.omg.CORBA.TCKind._tk_wstring: { 407 return "wstring"; 408 } 409 case org.omg.CORBA.TCKind._tk_void: { 410 return "void"; 411 } 412 case org.omg.CORBA.TCKind._tk_null: { 413 return "null"; 414 } 415 default: { 416 return tc.id(); 417 } 418 } 419 } catch (Exception e) { 420 e.printStackTrace(); 421 } 422 return null; 423 } 424 425 429 static String idToType(String id) { 430 String javaName = ""; 431 if (id.indexOf(":") > 0) { 433 id = id.substring(id.indexOf(":") + 1, id.lastIndexOf(":")); 434 } 435 if (id.indexOf(".") > 0) { 436 String pragma = id.substring(0, id.indexOf("/")); 438 String [] el = splitName(pragma, "."); 439 String prefix = el[el.length - 1]; 440 for (int i = el.length - 2; i >= 0; i--) { 441 prefix += "." + el[i]; 442 } 443 javaName = prefix + id.substring(id.indexOf("/")).replace('/', '.'); 444 } else { 445 javaName = id.replace('/', '.'); 446 } 447 if (javaName.equals("org.omg.CORBA.Object")) { 448 javaName = "object"; 449 } 450 return javaName; 451 } 452 453 static String [] splitName(String name, String separator) { 454 if (name == null) { 455 return new String [0]; 456 } 457 StringTokenizer st = new StringTokenizer(name, separator); 458 Vector v = new Vector(); 459 if (name.startsWith(separator)) { 460 v.addElement(""); 461 } 462 while (st.hasMoreTokens()) { 463 v.addElement(st.nextToken()); 464 } 465 String [] s = new String [v.size()]; 466 v.copyInto(s); 467 return s; 468 } 469 470 static String getText(Node domNode) { 471 String text = ""; 472 NodeList list = domNode.getChildNodes(); 473 int items = list.getLength(); 474 for (int i = 0; i < items; i++) { 475 if (list.item(i).getNodeType() == Node.TEXT_NODE) { 476 text = list.item(i).getNodeValue().trim(); 477 if (!text.equals("")) { 478 return list.item(i).getNodeValue().trim(); 479 } 480 } 481 } 482 return text; 483 } 484 485 static String getAttribute(Node domNode, String name) { 486 NamedNodeMap map = domNode.getAttributes(); 487 Node attr = map.getNamedItem(name); 488 if (attr != null) { 489 return attr.getNodeValue(); 490 } else { 491 return ""; 492 } 493 } 494 495 static Node nextElement(Node n) { 496 if (n != null) { 497 n = n.getNextSibling(); 498 while (n != null && n.getNodeType() != Node.ELEMENT_NODE) { 499 n = n.getNextSibling(); 500 } 501 } 502 return n; 503 } 504 505 static Node firstElement(Node n) { 506 while (n != null && n.getNodeType() != Node.ELEMENT_NODE) { 507 System.out.println("" + n.getNodeType() + " " + n.getNodeName()); 508 n = n.getNextSibling(); 509 } 510 return n; 511 } 512 513 static Node firstChildElement(Node n) { 514 NodeList list = n.getChildNodes(); 515 int items = list.getLength(); 516 for (int i = 0; i < items; i++) { 517 if (list.item(i).getNodeType() == Node.ELEMENT_NODE) { 518 return list.item(i); 519 } 520 } 521 return null; 522 } 523 524 static Node[] childElements(Node n) { 525 Vector v = new Vector(); 526 NodeList list = n.getChildNodes(); 527 int items = list.getLength(); 528 for (int i = 0; i < items; i++) { 529 if (list.item(i).getNodeType() == Node.ELEMENT_NODE) { 530 v.add(list.item(i)); 531 } 532 } 533 Node[] nn = new Node[v.size()]; 534 v.toArray(nn); 535 return nn; 536 } 537 538 static org.omg.CORBA.Contained lookup(String id) { 539 org.omg.CORBA.Contained c = (org.omg.CORBA.Contained )repositoryCache.get(id); 540 if (c == null) { 541 c = repositoryRef.lookup_id(id); 543 if (c == null) { 544 javax.swing.JOptionPane.showMessageDialog(null, id + " not found in InterfaceRepository.\nUse ir3_feed to populate the InterfaceRepository with the proper idl files"); 545 return null; 546 } 547 repositoryCache.put(id, c); 548 } 549 return c; 550 } 551 552 static public org.omg.CORBA.TypeCode type(String id) { 553 org.omg.CORBA.TypeCode tc = null; 554 String type = idToType(id); 555 Integer index = (Integer )table.get(type.toLowerCase()); 556 557 if (index == null) { 558 try { 559 org.omg.CORBA.Contained c = lookup(id); 560 if (c == null) { 561 throw new RuntimeException (id + " not found in InterfaceRepository.\nUse ir3_feed to populate the InterfaceRepository with the proper idl files"); 562 } 563 try { 564 org.omg.CORBA.IDLType idlType = org.omg.CORBA.IDLTypeHelper.narrow(c); 565 tc = idlType.type(); 566 return tc; 567 } catch (Exception e1) { 568 } 569 org.omg.CORBA.ExceptionDef idlType = org.omg.CORBA.ExceptionDefHelper.narrow(c); 570 tc = idlType.type(); 571 return tc; 572 } catch (Exception ex) { 573 ex.printStackTrace(); 574 } 575 } else { 576 switch (index.intValue()) { 577 case 0: return orb.get_primitive_tc(org.omg.CORBA.TCKind.tk_boolean); 578 case 1: return orb.get_primitive_tc(org.omg.CORBA.TCKind.tk_octet); 579 case 2: return orb.get_primitive_tc(org.omg.CORBA.TCKind.tk_short); 580 case 3: return orb.get_primitive_tc(org.omg.CORBA.TCKind.tk_ushort); 581 case 4: return orb.get_primitive_tc(org.omg.CORBA.TCKind.tk_long); 582 case 5: return orb.get_primitive_tc(org.omg.CORBA.TCKind.tk_ulong); 583 case 6: return orb.get_primitive_tc(org.omg.CORBA.TCKind.tk_longlong); 584 case 7: return orb.get_primitive_tc(org.omg.CORBA.TCKind.tk_ulonglong); 585 case 8: return orb.get_primitive_tc(org.omg.CORBA.TCKind.tk_float); 586 case 9: return orb.get_primitive_tc(org.omg.CORBA.TCKind.tk_double); 587 case 10: return orb.get_primitive_tc(org.omg.CORBA.TCKind.tk_longdouble); 588 case 11: return orb.get_primitive_tc(org.omg.CORBA.TCKind.tk_char); 589 case 12: return orb.get_primitive_tc(org.omg.CORBA.TCKind.tk_wchar); 590 case 13: return orb.get_primitive_tc(org.omg.CORBA.TCKind.tk_string); 591 case 14: return orb.get_primitive_tc(org.omg.CORBA.TCKind.tk_wstring); 592 case 15: return orb.get_primitive_tc(org.omg.CORBA.TCKind.tk_objref); 593 case 17: return orb.get_primitive_tc(org.omg.CORBA.TCKind.tk_fixed); 594 case 18: return orb.get_primitive_tc(org.omg.CORBA.TCKind.tk_any); 595 case 24: return orb.get_primitive_tc(org.omg.CORBA.TCKind.tk_void); 596 } 597 } 598 return tc; 600 } 601 602 609 static IdlNode getIdlNode(String id) { 610 if (id == null) { 611 throw new RuntimeException ("invalid id"); 612 } 613 614 String type = idToType(id); 615 Integer index = (Integer )table.get(type.toLowerCase()); 616 617 if (index == null) { 618 try { 620 return IdlNode.create(XmlNode.type(id)); 621 } catch (Exception e) { 622 e.printStackTrace(); 623 return null; 624 } 625 } 626 627 switch (index.intValue()) { 628 case 0: return new IdlBoolean(); 629 case 1: return new IdlOctet(); 630 case 2: return new IdlShort(); 631 case 3: return new IdlUshort(); 632 case 4: return new IdlLong(); 633 case 5: return new IdlUlong(); 634 case 6: return new IdlLonglong(); 635 case 7: return new IdlUlonglong(); 636 case 8: return new IdlFloat(); 637 case 9: return new IdlDouble(); 638 case 10: return new IdlLongdouble(); 639 case 11: return new IdlChar(); 640 case 12: return new IdlWchar(); 641 case 13: return new IdlString(); 642 case 14: return new IdlWstring(); 643 case 15: return new IdlObject(); 644 case 17: return new IdlFixed(); 645 case 18: return new IdlAny(); 646 default: return null; 647 } 648 } 649 650 static public IdlNode getIdlNodeXml(String xml) { 651 return getIdlNodeXml(null, xml); 652 } 653 654 static IdlNode getIdlNodeXml(org.omg.CORBA.TypeCode tc, String xml) { 655 return getIdlNode(tc, getNode(xml)); 656 } 657 658 static IdlNode getIdlNode(Node node) { 659 return getIdlNode(null, node); 660 } 661 662 static IdlNode getIdlNode(org.omg.CORBA.TypeCode tc, Node node) { 663 if (node == null) { 664 throw new RuntimeException ("empty node"); 665 } 666 667 String kind = node.getNodeName().toLowerCase().trim(); 668 if (kind.equals("idlxml")) { 669 node = firstChildElement(node); 670 kind = node.getNodeName().toLowerCase().trim(); 671 } 672 Integer index = (Integer )table.get(kind); 673 674 if (index == null) { 675 throw new RuntimeException ("invalid node: " + kind); 676 } 677 678 switch (index.intValue()) { 679 case 0: return new IdlBoolean(node); 680 case 1: return new IdlOctet(node); 681 case 2: return new IdlShort(node); 682 case 3: return new IdlUshort(node); 683 case 4: return new IdlLong(node); 684 case 5: return new IdlUlong(node); 685 case 6: return new IdlLonglong(node); 686 case 7: return new IdlUlonglong(node); 687 case 8: return new IdlFloat(node); 688 case 9: return new IdlDouble(node); 689 case 10: return new IdlLongdouble(node); 690 case 11: return new IdlChar(node); 691 case 12: return new IdlWchar(node); 692 case 13: return new IdlString(node); 693 case 14: return new IdlWstring(node); 694 case 15: return new IdlObject(node); 695 case 16: return new IdlInterface(node); 696 case 17: return new IdlFixed(node); 697 case 18: return new IdlAny(node); 698 case 19: return new IdlEnum(node); 699 case 20: return new IdlStruct(node); 700 case 21: return new IdlUnion(node); 701 case 22: return new IdlSequence(tc, node); 702 case 23: return new IdlArray(tc, node); 703 case 25: return new IdlOperation(node); 704 case 26: return new IdlReply(node); 705 case 27: return new IdlException(node); 706 default: return null; 707 } 708 } 709 710 711 static private final java.util.Hashtable table = new java.util.Hashtable (); 712 static { 713 table.put("boolean", new Integer (0)); 714 table.put("octet", new Integer (1)); 715 table.put("short", new Integer (2)); 716 table.put("ushort", new Integer (3)); 717 table.put("unsigned short", new Integer (3)); 718 table.put("long", new Integer (4)); 719 table.put("ulong", new Integer (5)); 720 table.put("unsigned long", new Integer (5)); 721 table.put("longlong", new Integer (6)); 722 table.put("long long", new Integer (6)); 723 table.put("ulonglong", new Integer (7)); 724 table.put("unsigned long long", new Integer (7)); 725 table.put("float", new Integer (8)); 726 table.put("double", new Integer (9)); 727 table.put("longdouble", new Integer (10)); 728 table.put("long double", new Integer (10)); 729 table.put("char", new Integer (11)); 730 table.put("wchar", new Integer (12)); 731 table.put("string", new Integer (13)); 732 table.put("wstring", new Integer (14)); 733 table.put("object", new Integer (15)); 734 table.put("interface", new Integer (16)); 735 table.put("fixed", new Integer (17)); 736 table.put("any", new Integer (18)); 737 table.put("enum", new Integer (19)); 738 table.put("struct", new Integer (20)); 739 table.put("union", new Integer (21)); 740 table.put("sequence", new Integer (22)); 741 table.put("array", new Integer (23)); 742 table.put("void", new Integer (24)); 743 table.put("operation", new Integer (25)); 744 table.put("reply", new Integer (26)); 745 table.put("exception", new Integer (27)); 746 table.put("idlxml", new Integer (28)); 747 } 748 749 static String replaceAll(String source, String what, String into) { 750 int index = source.indexOf(what); 751 if (index == -1) return source; 752 String s1 = source.substring(0, index); 753 String s2 = source.substring(index + what.length(), source.length()); 754 return s1 + into + replaceAll(s2, what, into); 755 } 756 757 public static void write(IdlNode n, IdlWriter w) { 758 if (n instanceof IdlObject) { 759 w.write_Object(n.getValue()); 760 return; 761 } 762 if (n instanceof IdlInterface) { 763 w.write_interface(((IdlSequence)n).getId(), n.getValue()); 764 return; 765 } 766 if (n instanceof IdlComponent) { 767 w.write_interface(((IdlComponent)n).getId(), n.getValue()); 768 return; 769 } 770 if (n instanceof IdlValue) { 771 IdlValue.write((IdlValue)n, w); 772 return; 773 } 774 if (n instanceof IdlSequence) { 775 IdlSequence.write((IdlSequence)n, w); 776 return; 777 } 778 if (n instanceof IdlStruct) { 779 IdlStruct.write((IdlStruct)n, w); 780 return; 781 } 782 if (n instanceof IdlException) { 783 IdlException.write((IdlException)n, w); 784 return; 785 } 786 if (n instanceof IdlUnion) { 787 IdlUnion.write((IdlUnion)n, w); 788 return; 789 } 790 if (n instanceof IdlArray) { 791 IdlArray.write((IdlArray)n, w); 792 return; 793 } 794 if (n instanceof IdlOperation) { 795 IdlOperation.write((IdlOperation)n, w); 796 return; 797 } 798 if (n instanceof IdlParameter) { 799 IdlParameter.write((IdlParameter)n, w); 800 return; 801 } 802 if (n instanceof IdlReply) { 803 IdlReply.write((IdlReply)n, w); 804 return; 805 } 806 if (n instanceof IdlAny) { 807 IdlAny.write((IdlAny)n, w); 808 return; 809 } 810 if (n instanceof IdlEnum) { 811 w.write_enum(n.getId(), n.getValue()); 812 return; 813 } 814 if (n instanceof IdlBoolean) { 815 w.write_boolean(n.getValue()); 816 return; 817 } 818 if (n instanceof IdlOctet) { 819 w.write_octet(n.getValue()); 820 return; 821 } 822 if (n instanceof IdlShort) { 823 w.write_short(n.getValue()); 824 return; 825 } 826 if (n instanceof IdlUshort) { 827 w.write_ushort(n.getValue()); 828 return; 829 } 830 if (n instanceof IdlLong) { 831 w.write_long(n.getValue()); 832 return; 833 } 834 if (n instanceof IdlUlong) { 835 w.write_ulong(n.getValue()); 836 return; 837 } 838 if (n instanceof IdlLonglong) { 839 w.write_longlong(n.getValue()); 840 return; 841 } 842 if (n instanceof IdlUlonglong) { 843 w.write_ulonglong(n.getValue()); 844 return; 845 } 846 if (n instanceof IdlChar) { 847 w.write_char(n.getValue()); 848 return; 849 } 850 if (n instanceof IdlWchar) { 851 w.write_wchar(n.getValue()); 852 return; 853 } 854 if (n instanceof IdlString) { 855 w.write_string(n.getValue()); 856 return; 857 } 858 if (n instanceof IdlWstring) { 859 w.write_wstring(n.getValue()); 860 return; 861 } 862 if (n instanceof IdlFloat) { 863 w.write_float(n.getValue()); 864 return; 865 } 866 if (n instanceof IdlDouble) { 867 w.write_double(n.getValue()); 868 return; 869 } 870 if (n instanceof IdlLongdouble) { 871 w.write_longdouble(n.getValue()); 872 return; 873 } 874 if (n instanceof IdlFixed) { 875 w.write_fixed(n.getValue()); 876 return; 877 } 878 } 879 } | Popular Tags |