1 package org.jacorb.orb.dynany; 2 3 22 23 import java.util.*; 24 25 import org.omg.DynamicAny.*; 26 import org.omg.CORBA.TCKind ; 27 import org.omg.DynamicAny.DynAnyFactoryPackage.InconsistentTypeCode ; 28 29 import org.jacorb.orb.TypeCode; 30 31 36 37 public class DynAnyFactoryImpl 38 extends org.omg.CORBA.LocalObject 39 implements org.omg.DynamicAny.DynAnyFactory 40 { 41 org.omg.CORBA.ORB orb; 42 43 public DynAnyFactoryImpl( org.omg.CORBA.ORB orb ) 44 { 45 this.orb = orb; 46 } 48 49 public org.omg.DynamicAny.DynAny create_dyn_any( org.omg.CORBA.Any value ) 50 throws InconsistentTypeCode 51 { 52 try 53 { 54 org.omg.DynamicAny.DynAny dynAny = 55 create_dyn_any_from_type_code( value.type() ); 56 dynAny.from_any( value ); 57 return dynAny; 58 } 59 catch( org.omg.DynamicAny.DynAnyPackage.InvalidValue iv ) 60 { 61 iv.printStackTrace(); 62 } 63 catch( org.omg.DynamicAny.DynAnyPackage.TypeMismatch itc ) 64 { 65 itc.printStackTrace(); 66 } 67 throw new InconsistentTypeCode (); 68 } 69 70 71 public org.omg.DynamicAny.DynAny create_dyn_any_from_type_code( org.omg.CORBA.TypeCode type ) 72 throws InconsistentTypeCode 73 { 74 type = TypeCode.originalType( type ); 75 76 try 77 { 78 switch( type.kind().value() ) 79 { 80 case org.omg.CORBA.TCKind._tk_null: 81 case org.omg.CORBA.TCKind._tk_void: 82 case org.omg.CORBA.TCKind._tk_short: 83 case org.omg.CORBA.TCKind._tk_long: 84 case org.omg.CORBA.TCKind._tk_ushort: 85 case org.omg.CORBA.TCKind._tk_ulong: 86 case org.omg.CORBA.TCKind._tk_float: 87 case org.omg.CORBA.TCKind._tk_double: 88 case org.omg.CORBA.TCKind._tk_boolean: 89 case org.omg.CORBA.TCKind._tk_char: 90 case org.omg.CORBA.TCKind._tk_octet: 91 case org.omg.CORBA.TCKind._tk_any: 92 case org.omg.CORBA.TCKind._tk_TypeCode: 93 case org.omg.CORBA.TCKind._tk_objref: 94 case org.omg.CORBA.TCKind._tk_string: 95 case org.omg.CORBA.TCKind._tk_longlong: 96 case org.omg.CORBA.TCKind._tk_ulonglong: 97 case org.omg.CORBA.TCKind._tk_wchar: 98 case org.omg.CORBA.TCKind._tk_wstring: 99 { 100 return new DynAny( this , type, orb ) ; 101 } 102 case org.omg.CORBA.TCKind._tk_fixed: 103 { 104 return new DynFixed( this , type ) ; 105 } 106 case org.omg.CORBA.TCKind._tk_except: 107 case org.omg.CORBA.TCKind._tk_struct: 108 { 109 return new DynStruct( this , type, orb ) ; 110 } 111 case org.omg.CORBA.TCKind._tk_enum: 112 { 113 return new DynEnum( this , type, orb ) ; 114 } 115 case org.omg.CORBA.TCKind._tk_array: 116 { 117 return new DynArray( this , type, orb ) ; 118 } 119 case org.omg.CORBA.TCKind._tk_sequence: 120 { 121 return new DynSequence( this , type, orb ) ; 122 } 123 case org.omg.CORBA.TCKind._tk_union: 124 { 125 return new DynUnion( this , type, orb ) ; 126 } 127 default: 128 throw new InconsistentTypeCode (); 129 } 130 } 131 catch( org.omg.DynamicAny.DynAnyPackage.InvalidValue iv ) 132 { 133 iv.printStackTrace(); 134 } 135 catch( org.omg.DynamicAny.DynAnyPackage.TypeMismatch itc ) 136 { 137 throw new InconsistentTypeCode (); 138 } 139 return null; 140 } 141 } 142 143 144 145 146 147 | Popular Tags |