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 IdlLongdouble extends IdlNode implements IdlWritable { 40 protected IdlLongdouble() { 41 setUserObject(this); 42 type = "longdouble"; 43 value = "0.0"; 44 tc = orb.get_primitive_tc(org.omg.CORBA.TCKind.tk_longdouble); 45 } 46 47 protected IdlLongdouble(Any any) { 48 this(); 49 setNode(any); 50 } 51 52 protected IdlLongdouble(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_double(); 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_double(Double.parseDouble(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 write(org.omg.CORBA.portable.OutputStream os) { 91 try { 92 os.write_double(Double.parseDouble(value)); 93 } catch (Exception e) { 94 e.printStackTrace(); 95 } 96 } 97 98 103 public void read(org.omg.CORBA.portable.InputStream is) { 104 value = "" + is.read_double(); 105 } 106 107 112 public void setValue(String v) { 113 try { 114 Double.parseDouble(v); 115 value = v; 116 } catch (NumberFormatException e) { 117 throw new RuntimeException (e.toString()); 118 } 119 } 120 121 123 130 public IdlLongdouble(String xml) { 131 this(XmlNode.getNode(xml)); 132 } 133 134 139 IdlLongdouble(Node n) { 140 this(); 141 if (n == null || !n.getNodeName().toUpperCase().equals("LONGDOUBLE")) { 142 throw new RuntimeException ("longdouble expected"); 143 } 144 setValue(XmlNode.getText(n)); 145 } 146 147 152 public void write(IdlWriter w) { 153 w.write_longdouble(value); 154 } 155 } | Popular Tags |