1 7 8 package com.sun.corba.se.impl.dynamicany; 9 10 import org.omg.CORBA.TypeCode ; 11 import org.omg.CORBA.Any ; 12 import org.omg.CORBA.BAD_OPERATION ; 13 import org.omg.CORBA.TypeCodePackage.BadKind ; 14 import org.omg.CORBA.TypeCodePackage.Bounds ; 15 import org.omg.CORBA.portable.InputStream ; 16 import org.omg.DynamicAny.*; 17 import org.omg.DynamicAny.DynAnyPackage.TypeMismatch ; 18 import org.omg.DynamicAny.DynAnyPackage.InvalidValue ; 19 import org.omg.DynamicAny.DynAnyFactoryPackage.InconsistentTypeCode ; 20 21 import com.sun.corba.se.spi.orb.ORB ; 22 import com.sun.corba.se.spi.logging.CORBALogDomains ; 23 import com.sun.corba.se.impl.logging.ORBUtilSystemException ; 24 25 public class DynArrayImpl extends DynAnyCollectionImpl implements DynArray 26 { 27 31 private DynArrayImpl() { 32 this(null, (Any )null, false); 33 } 34 35 protected DynArrayImpl(ORB orb, Any any, boolean copyValue) { 36 super(orb, any, copyValue); 37 } 38 39 protected DynArrayImpl(ORB orb, TypeCode typeCode) { 40 super(orb, typeCode); 41 } 42 43 protected boolean initializeComponentsFromAny() { 46 TypeCode typeCode = any.type(); 48 int length = getBound(); 49 TypeCode contentType = getContentType(); 50 InputStream input; 51 52 try { 53 input = any.create_input_stream(); 54 } catch (BAD_OPERATION e) { 55 return false; 56 } 57 58 components = new DynAny[length]; 59 anys = new Any [length]; 60 61 for (int i=0; i<length; i++) { 62 anys[i] = DynAnyUtil.extractAnyFromStream(contentType, input, orb); 65 try { 66 components[i] = DynAnyUtil.createMostDerivedDynAny(anys[i], orb, false); 68 } catch (InconsistentTypeCode itc) { } 70 } 71 return true; 72 } 73 74 protected boolean initializeComponentsFromTypeCode() { 79 TypeCode typeCode = any.type(); 81 int length = getBound(); 82 TypeCode contentType = getContentType(); 83 84 components = new DynAny[length]; 85 anys = new Any [length]; 86 87 for (int i=0; i<length; i++) { 88 createDefaultComponentAt(i, contentType); 89 } 90 return true; 91 } 92 93 97 108 109 113 protected void checkValue(Object [] value) 114 throws org.omg.DynamicAny.DynAnyPackage.InvalidValue  115 { 116 if (value == null || value.length != getBound()) { 117 throw new InvalidValue (); 118 } 119 } 120 } 121 | Popular Tags |