1 2 5 14 package org.jacorb.trading.db.pse.offers; 15 16 17 import org.omg.CORBA.*; 18 import jtport.ORBLayer; 19 20 21 24 public class TypeCodeValue 25 { 26 private int m_kind; 29 private String m_id; 30 private String m_name; 31 private int m_length; 32 private TypeCodeValue m_content; 33 private java.lang.Object m_arg; 34 private transient TypeCode m_typeCode; 35 36 37 private TypeCodeValue() 38 { 39 } 40 41 42 public TypeCodeValue(TypeCode tc) 43 { 44 setValue(tc); 45 } 46 47 48 public TypeCode getValue() 49 { 50 TypeCode result = m_typeCode; 51 52 if (result == null) { 53 ORB orb = ORBLayer.instance().getORB(); 54 55 switch (m_kind) { 56 case TCKind._tk_null: 58 case TCKind._tk_void: 59 case TCKind._tk_short: 60 case TCKind._tk_ushort: 61 case TCKind._tk_long: 62 case TCKind._tk_ulong: 63 case TCKind._tk_float: 64 case TCKind._tk_double: 65 case TCKind._tk_boolean: 66 case TCKind._tk_char: 67 case TCKind._tk_octet: 68 case TCKind._tk_any: 69 case TCKind._tk_TypeCode: 70 case TCKind._tk_Principal: 71 result = orb.get_primitive_tc(TCKind.from_int(m_kind)); 72 break; 73 74 case TCKind._tk_string: 75 result = orb.create_string_tc(m_length); 76 break; 77 78 case TCKind._tk_sequence: 79 result = orb.create_sequence_tc(m_length, m_content.getValue()); 80 break; 81 82 case TCKind._tk_array: 83 result = orb.create_array_tc(m_length, m_content.getValue()); 84 break; 85 86 case TCKind._tk_alias: 87 result = orb.create_alias_tc(m_id, m_name, m_content.getValue()); 88 break; 89 90 case TCKind._tk_objref: 91 result = orb.create_interface_tc(m_id, m_name); 92 break; 93 94 case TCKind._tk_longlong: 95 case TCKind._tk_ulonglong: 96 case TCKind._tk_longdouble: 97 case TCKind._tk_wstring: 98 case TCKind._tk_wchar: 99 case TCKind._tk_fixed: 100 case TCKind._tk_except: 101 case TCKind._tk_struct: 102 case TCKind._tk_union: 103 throw new RuntimeException ("Unsupported type"); 104 105 default: 106 throw new RuntimeException ("Unexpected type"); 107 } 108 109 m_typeCode = result; 111 } 112 113 return result; 114 } 115 116 117 protected void setValue(TypeCode tc) 118 { 119 TCKind kind = tc.kind(); 120 121 m_kind = kind.value(); 123 m_id = null; 124 m_name = null; 125 m_length = 0; 126 m_content = null; 127 m_arg = null; 128 m_typeCode = tc; 129 130 131 try { 132 switch (kind.value()) { 133 case TCKind._tk_null: 135 case TCKind._tk_void: 136 case TCKind._tk_short: 137 case TCKind._tk_ushort: 138 case TCKind._tk_long: 139 case TCKind._tk_ulong: 140 case TCKind._tk_float: 141 case TCKind._tk_double: 142 case TCKind._tk_boolean: 143 case TCKind._tk_char: 144 case TCKind._tk_octet: 145 case TCKind._tk_any: 146 case TCKind._tk_TypeCode: 147 case TCKind._tk_Principal: 148 break; 150 151 case TCKind._tk_string: 152 m_length = tc.length(); 153 break; 154 155 case TCKind._tk_sequence: 156 m_length = tc.length(); 157 m_content = new TypeCodeValue(tc.content_type()); 158 break; 159 160 case TCKind._tk_array: 161 m_length = tc.length(); 162 m_content = new TypeCodeValue(tc.content_type()); 163 break; 164 165 case TCKind._tk_alias: 166 m_id = tc.id(); 167 m_name = tc.name(); 168 m_content = new TypeCodeValue(tc.content_type()); 169 break; 170 171 case TCKind._tk_objref: 172 m_id = tc.id(); 173 m_name = tc.name(); 174 break; 175 176 case TCKind._tk_longlong: 177 case TCKind._tk_ulonglong: 178 case TCKind._tk_longdouble: 179 case TCKind._tk_wstring: 180 case TCKind._tk_wchar: 181 case TCKind._tk_fixed: 182 case TCKind._tk_except: 183 case TCKind._tk_struct: 184 case TCKind._tk_union: 185 throw new RuntimeException ("Unsupported type"); 186 187 default: 188 throw new RuntimeException ("Unexpected type"); 189 } 190 } 191 catch (org.omg.CORBA.TypeCodePackage.BadKind e) { 192 throw new RuntimeException (e.getMessage()); 193 } 194 } 195 196 197 198 public void postInitializeContents() 199 { 200 m_typeCode = null; 201 } 202 203 204 205 public void preClearContents() 206 { 207 m_typeCode = null; 208 } 209 210 211 309 } 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 | Popular Tags |