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 IdlLonglong extends IdlNode implements IdlWritable { 40 protected IdlLonglong() { 41 setUserObject(this); 42 type = "longlong"; 43 value = "0"; 44 tc = orb.get_primitive_tc(TCKind.tk_longlong); 45 } 46 47 protected IdlLonglong(Any any) { 48 this(); 49 setNode(any); 50 } 51 52 protected IdlLonglong(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_longlong(); 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_longlong(Long.parseLong(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 86 91 public void setValue(String v) { 92 try { 93 Long.parseLong(v); 94 value = v; 95 } catch (NumberFormatException e) { 96 throw new RuntimeException (e.toString()); 97 } 98 } 99 100 105 public void write(org.omg.CORBA.portable.OutputStream os) { 106 try { 107 os.write_longlong(Long.parseLong(value)); 108 } catch (Exception e) { 109 e.printStackTrace(); 110 } 111 } 112 113 118 public void read(org.omg.CORBA.portable.InputStream is) { 119 value = "" + is.read_longlong(); 120 } 121 122 124 131 public IdlLonglong(String xml) { 132 this(XmlNode.getNode(xml)); 133 } 134 135 140 IdlLonglong(Node n) { 141 this(); 142 if (n == null || !n.getNodeName().toUpperCase().equals("LONGLONG")) { 143 throw new RuntimeException ("longlong expected"); 144 } 145 setValue(XmlNode.getText(n)); 146 } 147 148 153 public void write(IdlWriter w) { 154 w.write_longlong(value); 155 } 156 } | Popular Tags |