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 org.w3c.dom.Node ; 28 import org.omg.CORBA.TypeCode ; 29 import org.omg.CORBA.Any ; 30 import org.omg.CORBA.TCKind ; 31 32 39 public class IdlWstring extends IdlNode implements IdlWritable { 40 protected IdlWstring() { 41 setUserObject(this); 42 type = "wstring"; 43 value = " "; 44 tc = orb.get_primitive_tc(TCKind.tk_wstring); 45 } 46 47 protected IdlWstring(Any any) { 48 this(); 49 setNode(any); 50 } 51 52 protected IdlWstring(TypeCode tc) { 53 this(); 54 setNode(tc); 55 } 56 57 protected void setNode(Any any) { 58 try { 59 setNode(any.type()); 60 setValue(any.create_input_stream().read_wstring()); 61 } catch (Exception e) { 62 e.printStackTrace(); 63 } 64 } 65 66 71 public Any toAny() { 72 try { 73 Any any = orb.create_any(); 74 org.omg.CORBA.portable.OutputStream out = any.create_output_stream(); 75 any.type (tc); 76 out.write_wstring(value); 77 any.read_value (out.create_input_stream(), tc); 78 return any; 79 } catch (Exception e) { 80 e.printStackTrace(); 81 } 82 return null; 83 } 84 85 90 public void setValue(String v) { 91 if (v == null) { 92 v = ""; 93 } 94 value = v; 95 } 96 97 102 public void write(org.omg.CORBA.portable.OutputStream os) { 103 os.write_wstring(value); 104 } 105 106 111 public void read(org.omg.CORBA.portable.InputStream is) { 112 value = is.read_wstring(); 113 } 114 115 117 124 public IdlWstring(String xml) { 125 this(XmlNode.getNode(xml)); 126 } 127 128 133 IdlWstring(Node n) { 134 this(); 135 if (n == null || !n.getNodeName().toUpperCase().equals("WSTRING")) { 136 throw new RuntimeException ("wstring expected"); 137 } 138 setValue(XmlNode.getText(n)); 139 } 140 141 146 public void write(IdlWriter w) { 147 w.write_wstring(value); 148 } 149 } | Popular Tags |