1 package org.coach.idltree; 2 3 import org.w3c.dom.Node ; 4 import javax.swing.tree.*; 5 6 import java.util.*; 7 import java.io.*; 8 import java.lang.reflect.*; 9 import org.omg.CORBA.ORB ; 10 import org.omg.CORBA.TypeCode ; 11 import org.omg.CORBA.Any ; 12 import org.omg.CORBA.TCKind ; 13 import org.coach.util.IorPrinter; 14 15 public class IdlComponent extends IdlInterface implements IdlWritable { 16 protected String [] facets; 17 18 protected IdlComponent() { 19 setUserObject(this); 20 type = "Component"; 21 value = "null"; 22 tc = orb.get_primitive_tc(TCKind.tk_objref); 23 } 24 25 protected IdlComponent(Any any) { 26 this(); 27 setNode(any.type()); 28 setNode(any); 29 } 30 31 protected IdlComponent(TypeCode tc) { 32 this(); 33 setNode(tc); 34 } 35 36 41 public void setValue(String v) { 42 if (v.toUpperCase().equals("NULL")) { 43 value = "null"; 44 id = ""; 45 } else { 46 int idx = v.indexOf("IOR:"); 47 if (idx < 0) { 48 throw new RuntimeException ("value is not an IOR: " + v); 49 } 50 value = v.substring(idx); 51 try { 52 IorPrinter iorPrinter = new IorPrinter(value); 53 id = iorPrinter.getTypeId(); 54 } catch (Exception e) { 55 id = ""; 56 } 57 } 58 } 59 60 62 74 public IdlComponent(String xml) { 75 this(XmlNode.getNode(xml)); 76 } 77 78 83 IdlComponent(Node n) { 84 this(); 85 try { 86 if (n == null || !n.getNodeName().toUpperCase().equals("COMPONENT")) { 87 throw new RuntimeException ("component expected"); 88 } 89 setNode(XmlNode.type(XmlNode.getId(n))); 90 setValue(XmlNode.getText(n)); 91 operations = XmlNode.getOperations(id); 92 } catch (Exception e) { 93 throw new RuntimeException (e.toString()); 94 } 95 } 96 97 public IdlComponent(String id, boolean dummy) { 98 this(); 99 try { 100 this.id = id; 101 setNode(XmlNode.type(id)); 102 operations = XmlNode.getOperations(id); 103 } catch (Exception e) { 104 e.printStackTrace(); 105 } 106 } 107 108 public String [] getFacets() { 109 return facets; 110 } 111 112 113 118 public void write(IdlWriter w) { 119 w.write_component(id, value); 120 } 121 } | Popular Tags |