コード例 #1
0
  // Initializes components and anys representation
  // from the Any representation
  protected boolean initializeComponentsFromAny() {
    // This typeCode is of kind tk_sequence.
    TypeCode typeCode = any.type();
    int length;
    TypeCode contentType = getContentType();
    InputStream input;

    try {
      input = any.create_input_stream();
    } catch (BAD_OPERATION e) {
      return false;
    }

    length = input.read_long();
    components = new DynAny[length];
    anys = new Any[length];

    for (int i = 0; i < length; i++) {
      // _REVISIT_ Could use read_xxx_array() methods on InputStream for efficiency
      // but only for primitive types
      anys[i] = DynAnyUtil.extractAnyFromStream(contentType, input, orb);
      try {
        // Creates the appropriate subtype without copying the Any
        components[i] = DynAnyUtil.createMostDerivedDynAny(anys[i], orb, false);
      } catch (InconsistentTypeCode itc) { // impossible
      }
    }
    return true;
  }
コード例 #2
0
 public org.omg.DynamicAny.DynAny copy() {
   if (status == STATUS_DESTROYED) {
     throw wrapper.dynAnyDestroyed();
   }
   // The flag "true" indicates copying the Any value
   try {
     return DynAnyUtil.createMostDerivedDynAny(any, orb, true);
   } catch (InconsistentTypeCode ictc) {
     return null; // impossible
   }
 }
コード例 #3
0
 public org.omg.DynamicAny.DynAny get_dyn_any()
     throws org.omg.DynamicAny.DynAnyPackage.TypeMismatch,
         org.omg.DynamicAny.DynAnyPackage.InvalidValue {
   if (status == STATUS_DESTROYED) {
     throw wrapper.dynAnyDestroyed();
   }
   if (any.type().kind().value() != TCKind._tk_any) throw new TypeMismatch();
   // _REVISIT_ Copy value here?
   try {
     return DynAnyUtil.createMostDerivedDynAny(any.extract_any(), orb, true);
   } catch (InconsistentTypeCode ictc) {
     // The spec doesn't allow us to throw back this exception
     // incase the anys any if of type Principal, native or abstract interface.
     return null;
   }
 }
コード例 #4
0
 // Returns the most derived DynAny type based on the TypeCode.
 public org.omg.DynamicAny.DynAny create_dyn_any_from_type_code(org.omg.CORBA.TypeCode type)
     throws org.omg.DynamicAny.DynAnyFactoryPackage.InconsistentTypeCode {
   return DynAnyUtil.createMostDerivedDynAny(type, orb);
 }
コード例 #5
0
 // Returns the most derived DynAny type based on the Anys TypeCode.
 public org.omg.DynamicAny.DynAny create_dyn_any(org.omg.CORBA.Any any)
     throws org.omg.DynamicAny.DynAnyFactoryPackage.InconsistentTypeCode {
   return DynAnyUtil.createMostDerivedDynAny(any, orb, true);
 }