return AnyImpl.extractAnyFromStream(memberType, input, orb);
}
// Creates a default Any of the given type.
static Any createDefaultAnyOfType(TypeCode typeCode, ORB orb) {
ORBUtilSystemException wrapper = ORBUtilSystemException.get( orb,
CORBALogDomains.RPC_PRESENTATION ) ;
Any returnValue = orb.create_any();
// The spec for DynAny differs from Any on initialization via type code:
// - false for boolean
// - zero for numeric types
// - zero for types octet, char, and wchar
// - the empty string for string and wstring
// - nil for object references
// - a type code with a TCKind value of tk_null for type codes
// - for Any values, an Any containing a type code with a TCKind value of tk_null
// type and no value
switch (typeCode.kind().value()) {
case TCKind._tk_boolean:
// false for boolean
returnValue.insert_boolean(false);
break;
case TCKind._tk_short:
// zero for numeric types
returnValue.insert_short((short)0);
break;
case TCKind._tk_ushort:
// zero for numeric types
returnValue.insert_ushort((short)0);
break;
case TCKind._tk_long:
// zero for numeric types
returnValue.insert_long(0);
break;
case TCKind._tk_ulong:
// zero for numeric types
returnValue.insert_ulong(0);
break;
case TCKind._tk_longlong:
// zero for numeric types
returnValue.insert_longlong((long)0);
break;
case TCKind._tk_ulonglong:
// zero for numeric types
returnValue.insert_ulonglong((long)0);
break;
case TCKind._tk_float:
// zero for numeric types
returnValue.insert_float((float)0.0);
break;
case TCKind._tk_double:
// zero for numeric types
returnValue.insert_double((double)0.0);
break;
case TCKind._tk_octet:
// zero for types octet, char, and wchar
returnValue.insert_octet((byte)0);
break;
case TCKind._tk_char:
// zero for types octet, char, and wchar
returnValue.insert_char((char)0);
break;
case TCKind._tk_wchar:
// zero for types octet, char, and wchar
returnValue.insert_wchar((char)0);
break;
case TCKind._tk_string:
// the empty string for string and wstring
// Make sure that type code for bounded strings gets respected
returnValue.type(typeCode);
// Doesn't erase the type of bounded string
returnValue.insert_string("");
break;
case TCKind._tk_wstring:
// the empty string for string and wstring
// Make sure that type code for bounded strings gets respected
returnValue.type(typeCode);
// Doesn't erase the type of bounded string
returnValue.insert_wstring("");
break;
case TCKind._tk_objref:
// nil for object references
returnValue.insert_Object(null);
break;
case TCKind._tk_TypeCode:
// a type code with a TCKind value of tk_null for type codes
// We can reuse the type code that's already in the any.
returnValue.insert_TypeCode(returnValue.type());
break;
case TCKind._tk_any:
// for Any values, an Any containing a type code with a TCKind value
// of tk_null type and no value.
// This is exactly what the default AnyImpl constructor provides.
// _REVISIT_ Note that this inner Any is considered uninitialized.
returnValue.insert_any(orb.create_any());
break;
case TCKind._tk_struct:
case TCKind._tk_union:
case TCKind._tk_enum:
case TCKind._tk_sequence:
case TCKind._tk_array:
case TCKind._tk_except:
case TCKind._tk_value:
case TCKind._tk_value_box:
// There are no default value for complex types since there is no
// concept of a hierarchy of Anys. Only DynAnys can be arrange in
// a hierarchy to mirror the TypeCode hierarchy.
// See DynAnyConstructedImpl.initializeComponentsFromTypeCode()
// on how this DynAny hierarchy is created from TypeCodes.
returnValue.type(typeCode);
break;
case TCKind._tk_fixed:
returnValue.insert_fixed(new BigDecimal("0.0"), typeCode);
break;
case TCKind._tk_native:
case TCKind._tk_alias:
case TCKind._tk_void:
case TCKind._tk_Principal:
case TCKind._tk_abstract_interface:
returnValue.type(typeCode);
break;
case TCKind._tk_null:
// Any is already initialized to null
break;
case TCKind._tk_longdouble:
// Unspecified for Java
throw wrapper.tkLongDoubleNotSupported() ;
default:
throw wrapper.typecodeNotSupported() ;
}
return returnValue;
}