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 IdlWchar extends IdlNode implements IdlWritable { 40 protected IdlWchar() { 41 setUserObject(this); 42 type = "wchar"; 43 value = " "; 44 tc = orb.get_primitive_tc(TCKind.tk_wchar); 45 } 46 47 protected IdlWchar(Any any) { 48 this(); 49 setNode(any); 50 } 51 52 protected IdlWchar(TypeCode tc) { 53 this(); 54 setNode(tc); 55 } 56 57 protected void setNode(Any any) { 58 try { 59 setNode(any.type()); 60 value = "" + any.create_input_stream().read_wchar(); 61 } catch (Exception e) { 62 e.printStackTrace(); 63 } 64 } 65 66 public void setValue(String v) { 67 if (v == null || v.equals("")) { 68 value = " "; 69 } else { 70 value = v; 71 } 72 } 73 74 79 public Any toAny() { 80 try { 81 Any any = orb.create_any(); 82 org.omg.CORBA.portable.OutputStream out = any.create_output_stream(); 83 any.type(tc); 84 out.write_wchar(value.charAt(0)); 85 any.read_value(out.create_input_stream(), tc); 86 return any; 87 } catch (Exception e) { 88 e.printStackTrace(); 89 } 90 return null; 91 } 92 93 98 public void write(org.omg.CORBA.portable.OutputStream os) { 99 os.write_wchar(value.charAt(0)); 100 } 101 102 107 public void read(org.omg.CORBA.portable.InputStream is) { 108 value = "" + is.read_wchar(); 109 } 110 111 113 120 public IdlWchar(String xml) { 121 this(XmlNode.getNode(xml)); 122 } 123 124 129 IdlWchar(Node n) { 130 this(); 131 if (n == null || !n.getNodeName().toUpperCase().equals("WCHAR")) { 132 throw new RuntimeException ("wchar expected"); 133 } 134 setValue(XmlNode.getText(n)); 135 } 136 137 142 public void write(IdlWriter w) { 143 w.write_wchar(value); 144 } 145 } | Popular Tags |