1 7 8 package com.sun.corba.se.impl.dynamicany; 9 10 import org.omg.CORBA.TypeCode ; 11 import org.omg.CORBA.TCKind ; 12 import org.omg.CORBA.Any ; 13 import org.omg.CORBA.TypeCodePackage.BadKind ; 14 import org.omg.CORBA.TypeCodePackage.Bounds ; 15 import org.omg.DynamicAny.*; 16 import org.omg.DynamicAny.DynAnyPackage.TypeMismatch ; 17 import org.omg.DynamicAny.DynAnyPackage.InvalidValue ; 18 import org.omg.DynamicAny.DynAnyFactoryPackage.InconsistentTypeCode ; 19 20 import com.sun.corba.se.spi.orb.ORB ; 21 import com.sun.corba.se.spi.logging.CORBALogDomains ; 22 import com.sun.corba.se.impl.logging.ORBUtilSystemException ; 23 24 public class DynValueBoxImpl extends DynValueCommonImpl implements DynValueBox 25 { 26 30 private DynValueBoxImpl() { 31 this(null, (Any )null, false); 32 } 33 34 protected DynValueBoxImpl(ORB orb, Any any, boolean copyValue) { 35 super(orb, any, copyValue); 36 } 37 38 protected DynValueBoxImpl(ORB orb, TypeCode typeCode) { 39 super(orb, typeCode); 40 } 41 42 46 public Any get_boxed_value() 47 throws org.omg.DynamicAny.DynAnyPackage.InvalidValue 48 { 49 if (isNull) { 50 throw new InvalidValue (); 51 } 52 checkInitAny(); 53 return any; 54 } 55 56 public void set_boxed_value(org.omg.CORBA.Any boxed) 57 throws org.omg.DynamicAny.DynAnyPackage.TypeMismatch 58 { 59 if ( ! isNull && ! boxed.type().equal(this.type())) { 60 throw new TypeMismatch (); 61 } 62 clearData(); 63 any = boxed; 64 representations = REPRESENTATION_ANY; 65 index = 0; 66 isNull = false; 67 } 68 69 public DynAny get_boxed_value_as_dyn_any() 70 throws org.omg.DynamicAny.DynAnyPackage.InvalidValue 71 { 72 if (isNull) { 73 throw new InvalidValue (); 74 } 75 checkInitComponents(); 76 return components[0]; 77 } 78 79 public void set_boxed_value_as_dyn_any(DynAny boxed) 80 throws org.omg.DynamicAny.DynAnyPackage.TypeMismatch 81 { 82 if ( ! isNull && ! boxed.type().equal(this.type())) { 83 throw new TypeMismatch (); 84 } 85 clearData(); 86 components = new DynAny[] {boxed}; 87 representations = REPRESENTATION_COMPONENTS; 88 index = 0; 89 isNull = false; 90 } 91 92 protected boolean initializeComponentsFromAny() { 93 try { 94 components = new DynAny[] {DynAnyUtil.createMostDerivedDynAny(any, orb, false)}; 95 } catch (InconsistentTypeCode ictc) { 96 return false; } 98 return true; 99 } 100 101 protected boolean initializeComponentsFromTypeCode() { 102 try { 103 any = DynAnyUtil.createDefaultAnyOfType(any.type(), orb); 104 components = new DynAny[] {DynAnyUtil.createMostDerivedDynAny(any, orb, false)}; 105 } catch (InconsistentTypeCode ictc) { 106 return false; } 108 return true; 109 } 110 111 protected boolean initializeAnyFromComponents() { 112 any = getAny(components[0]); 113 return true; 114 } 115 } 116 | Popular Tags |