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 40 public class IdlBoolean extends IdlNode implements IdlWritable { 41 protected IdlBoolean() { 42 setUserObject(this); 43 type = "boolean"; 44 value = "FALSE"; 45 tc = orb.get_primitive_tc(TCKind.tk_boolean); 46 } 47 48 protected IdlBoolean(Any any) { 49 this(); 50 setNode(any); 51 } 52 53 protected IdlBoolean(TypeCode tc) { 54 this(); 55 setNode(tc); 56 } 57 58 protected void setNode(Any any) { 59 try { 60 setNode(any.type()); 61 value = ("" + any.create_input_stream().read_boolean()).toUpperCase(); 62 } catch (Exception e) { 63 e.printStackTrace(); 64 } 65 } 66 67 72 public Any toAny() { 73 try { 74 Any any = orb.create_any(); 75 org.omg.CORBA.portable.OutputStream out = any.create_output_stream(); 76 any.type(tc); 77 out.write_boolean(value.equals("TRUE") ? true : false); 78 any.read_value(out.create_input_stream(), tc); 79 return any; 80 } catch (Exception e) { 81 e.printStackTrace(); 82 } 83 return null; 84 } 85 86 91 public void write(org.omg.CORBA.portable.OutputStream os) { 92 try { 93 os.write_boolean(value.equals("TRUE") ? true : false); 94 } catch (Exception e) { 95 e.printStackTrace(); 96 } 97 } 98 99 104 public void read(org.omg.CORBA.portable.InputStream is) { 105 value = ("" + is.read_boolean()).toUpperCase(); 106 } 107 108 110 120 public IdlBoolean(String xml) { 121 this(XmlNode.getNode(xml)); 122 } 123 124 IdlBoolean(Node n) { 125 this(); 126 127 if (n == null || !n.getNodeName().toUpperCase().equals("BOOLEAN")) { 128 throw new RuntimeException ("boolean expected"); 129 } 130 setValue(XmlNode.getText(n).toUpperCase()); 131 } 132 133 138 public void write(IdlWriter w) { 139 w.write_boolean(value); 140 } 141 } | Popular Tags |