FileDocCategorySizeDatePackage
AnyImpl.javaAPI DocJava SE 5 API39817Fri Aug 26 14:54:18 BST 2005com.sun.corba.se.impl.corba

AnyImpl

public class AnyImpl extends org.omg.CORBA.Any

Fields Summary
private TypeCodeImpl
typeCode
protected com.sun.corba.se.spi.orb.ORB
orb
private com.sun.corba.se.impl.logging.ORBUtilSystemException
wrapper
private com.sun.corba.se.impl.encoding.CDRInputStream
stream
private long
value
private Object
object
private boolean
isInitialized
private static final int
DEFAULT_BUFFER_SIZE
static boolean[]
isStreamed
Constructors Summary
public AnyImpl(com.sun.corba.se.spi.orb.ORB orb)
A constructor that sets the Any to contain a null. It also marks the value as being invalid so that extractions throw an exception until an insertion has been performed.

	this.orb = orb;
	wrapper = ORBUtilSystemException.get( (com.sun.corba.se.spi.orb.ORB)orb,
	    CORBALogDomains.RPC_PRESENTATION ) ;

	typeCode = orb.get_primitive_tc(TCKind._tk_null);
	stream = null;
	object = null;
	value = 0;
        // null is a valid value
        isInitialized = true;
    
public AnyImpl(com.sun.corba.se.spi.orb.ORB orb, org.omg.CORBA.Any obj)

	this(orb);

	if ((obj instanceof AnyImpl)) {
	    AnyImpl objImpl = (AnyImpl)obj;
	    typeCode = objImpl.typeCode;
	    value = objImpl.value;
	    object = objImpl.object;
            isInitialized = objImpl.isInitialized;

	    if (objImpl.stream != null)
		stream = objImpl.stream.dup();

	} else {
	    read_value(obj.create_input_stream(), obj.type());
	}
    
Methods Summary
private voidcheckExtractBadOperation(int expected)

	if (!isInitialized)
	    throw wrapper.extractNotInitialized() ;

	int tc = realType().kind().value() ;
	if (tc != expected) {
	    String tcName = getTCKindName( tc ) ;
	    String expectedName = getTCKindName( expected ) ;
	    throw wrapper.extractWrongType( expectedName, tcName ) ;
	}
    
private voidcheckExtractBadOperationList(int[] expected)

	if (!isInitialized)
	    throw wrapper.extractNotInitialized() ;

	int tc = realType().kind().value() ;
	for (int ctr=0; ctr<expected.length; ctr++)
	    if (tc == expected[ctr])
		return ;

	List list = new ArrayList() ;
	for (int ctr=0; ctr<expected.length; ctr++)
	    list.add( getTCKindName( expected[ctr] ) ) ;

	String tcName = getTCKindName( tc ) ;
	throw wrapper.extractWrongTypeList( list, tcName ) ;
    
static com.sun.corba.se.impl.corba.AnyImplconvertToNative(com.sun.corba.se.spi.orb.ORB orb, org.omg.CORBA.Any any)


          
        if (any instanceof AnyImpl) {
            return (AnyImpl)any;
        } else {
            AnyImpl anyImpl = new AnyImpl(orb, any);
            anyImpl.typeCode = TypeCodeImpl.convertToNative(orb, anyImpl.typeCode);
            return anyImpl;
        }
    
public org.omg.CORBA.TypeCodecreateTypeCodeForClass(java.lang.Class c, com.sun.corba.se.spi.orb.ORB tcORB)
Utility method for insert_Value and Util.writeAny. The ORB passed in should have the desired ORBVersion. It is used to generate the type codes.

	// Look in the cache first
	TypeCodeImpl classTC = tcORB.getTypeCodeForClass(c);
	if (classTC != null)
	    return classTC;

	// All cases need to be able to create repository IDs.
	//
	// See bug 4391648 for more info about the tcORB in this
	// case.
	RepositoryIdStrings repStrs 
	    = RepositoryIdFactory.getRepIdStringsFactory(tcORB);


	// Assertion: c instanceof Serializable?

	if ( c.isArray() ) {
	    // Arrays - may recurse for multi-dimensional arrays
	    Class componentClass = c.getComponentType();
	    TypeCode embeddedType;
	    if ( componentClass.isPrimitive() ) {
		embeddedType = getPrimitiveTypeCodeForClass(componentClass,
							    tcORB);
	    } else {
		embeddedType = createTypeCodeForClass (componentClass,
						       tcORB);
	    }
	    TypeCode t = tcORB.create_sequence_tc (0, embeddedType);

	    String id = repStrs.createForJavaType(c);

	    return tcORB.create_value_box_tc (id, "Sequence", t);
	} else if ( c == java.lang.String.class ) {
	    // Strings
	    TypeCode t = tcORB.create_string_tc (0);

	    String id = repStrs.createForJavaType(c);

	    return tcORB.create_value_box_tc (id, "StringValue", t);
	}

	// Anything else
	// We know that this is a TypeCodeImpl since it is our ORB
	classTC = (TypeCodeImpl)ValueUtility.createTypeCodeForClass(
	    tcORB, c, ORBUtility.createValueHandler(tcORB));
	// Intruct classTC to store its buffer
	classTC.setCaching(true);
	// Update the cache
	tcORB.setTypeCodeForClass(c, classTC);
	return classTC;
    
public org.omg.CORBA.portable.InputStreamcreate_input_stream()
returns an input stream that an Any value can be marshaled out of.

result
the InputStream to marshal value of Any out of.

	//
	// We create a new InputStream so that multiple threads can call here
	// and read the streams in parallel without thread safety problems.
	//
	//debug.log ("create_input_stream");
	if (AnyImpl.isStreamed[realType().kind().value()]) {
	    return stream.dup();
	} else {
	    OutputStream os = (OutputStream)orb.create_output_stream();
	    TCUtility.marshalIn(os, realType(), value, object);

	    return os.create_input_stream();
	}
    
public org.omg.CORBA.portable.OutputStreamcreate_output_stream()
returns an output stream that an Any value can be marshaled into.

result
the OutputStream to marshal value of Any into

	//debug.log ("create_output_stream");
	return new AnyOutputStream(orb);
    
public booleanequal(org.omg.CORBA.Any otherAny)
checks for equality between Anys.

param
otherAny the Any to be compared with.
result
true if the Anys are equal, false otherwise.

	//debug.log ("equal");

	if (otherAny == this)
	    return true;

	// first check for typecode equality.
	// note that this will take aliases into account
	if (!typeCode.equal(otherAny.type()))
	    return false;

	// Resolve aliases here
	TypeCode realType = realType();

	// _REVISIT_ Possible optimization for the case where
	// otherAny is a AnyImpl and the endianesses match.
	// Need implementation of CDRInputStream.equals()
	// For now we disable this to encourage testing the generic,
	// unoptimized code below.
	// Unfortunately this generic code needs to copy the whole stream
	// at least once.
	//    if (AnyImpl.isStreamed[realType.kind().value()]) {
	//        if (otherAny instanceof AnyImpl) {
	//            return ((AnyImpl)otherAny).stream.equals(stream);
	//        }
	//    }
	switch (realType.kind().value()) {
	    // handle primitive types
	    case TCKind._tk_null:
	    case TCKind._tk_void:
		return true;
	    case TCKind._tk_short:
		return (extract_short() == otherAny.extract_short());
	    case TCKind._tk_long:
		return (extract_long() == otherAny.extract_long());
	    case TCKind._tk_ushort:
		return (extract_ushort() == otherAny.extract_ushort());
	    case TCKind._tk_ulong:
		return (extract_ulong() == otherAny.extract_ulong());
	    case TCKind._tk_float:
		return (extract_float() == otherAny.extract_float());
	    case TCKind._tk_double:
		return (extract_double() == otherAny.extract_double());
	    case TCKind._tk_boolean:
		return (extract_boolean() == otherAny.extract_boolean());
	    case TCKind._tk_char:
		return (extract_char() == otherAny.extract_char());
	    case TCKind._tk_wchar:
		return (extract_wchar() == otherAny.extract_wchar());
	    case TCKind._tk_octet:
		return (extract_octet() == otherAny.extract_octet());
	    case TCKind._tk_any:
		return extract_any().equal(otherAny.extract_any());
	    case TCKind._tk_TypeCode:
		return extract_TypeCode().equal(otherAny.extract_TypeCode());
	    case TCKind._tk_string:
		return extract_string().equals(otherAny.extract_string());
	    case TCKind._tk_wstring:
		return (extract_wstring().equals(otherAny.extract_wstring()));
	    case TCKind._tk_longlong:
		return (extract_longlong() == otherAny.extract_longlong());
	    case TCKind._tk_ulonglong:
		return (extract_ulonglong() == otherAny.extract_ulonglong());

	    case TCKind._tk_objref:
		return (extract_Object().equals(otherAny.extract_Object()));
	    case TCKind._tk_Principal:
		return (extract_Principal().equals(otherAny.extract_Principal()));

	    case TCKind._tk_enum:
		return (extract_long() == otherAny.extract_long());
	    case TCKind._tk_fixed:
		return (extract_fixed().compareTo(otherAny.extract_fixed()) == 0);
	    case TCKind._tk_except:
	    case TCKind._tk_struct:
	    case TCKind._tk_union:
	    case TCKind._tk_sequence:
	    case TCKind._tk_array:
		InputStream copyOfMyStream = this.create_input_stream();
		InputStream copyOfOtherStream = otherAny.create_input_stream();
		return equalMember(realType, copyOfMyStream, copyOfOtherStream);

	    // Too complicated to handle value types the way we handle
	    // other complex types above. Don't try to decompose it here
	    // for faster comparison, just use Object.equals().
	    case TCKind._tk_value:
	    case TCKind._tk_value_box:
		return extract_Value().equals(otherAny.extract_Value());

	    case TCKind._tk_alias:
		throw wrapper.errorResolvingAlias() ;

	    case TCKind._tk_longdouble:
		// Unspecified for Java
		throw wrapper.tkLongDoubleNotSupported() ;

	    default:
		throw wrapper.typecodeNotSupported() ;
	}
    
private booleanequalMember(org.omg.CORBA.TypeCode memberType, org.omg.CORBA.portable.InputStream myStream, org.omg.CORBA.portable.InputStream otherStream)

	// Resolve aliases here
	TypeCode realType = realType(memberType);

	try {
	    switch (realType.kind().value()) {
		// handle primitive types
		case TCKind._tk_null:
		case TCKind._tk_void:
		    return true;
		case TCKind._tk_short:
		    return (myStream.read_short() == otherStream.read_short());
		case TCKind._tk_long:
		    return (myStream.read_long() == otherStream.read_long());
		case TCKind._tk_ushort:
		    return (myStream.read_ushort() == otherStream.read_ushort());
		case TCKind._tk_ulong:
		    return (myStream.read_ulong() == otherStream.read_ulong());
		case TCKind._tk_float:
		    return (myStream.read_float() == otherStream.read_float());
		case TCKind._tk_double:
		    return (myStream.read_double() == otherStream.read_double());
		case TCKind._tk_boolean:
		    return (myStream.read_boolean() == otherStream.read_boolean());
		case TCKind._tk_char:
		    return (myStream.read_char() == otherStream.read_char());
		case TCKind._tk_wchar:
		    return (myStream.read_wchar() == otherStream.read_wchar());
		case TCKind._tk_octet:
		    return (myStream.read_octet() == otherStream.read_octet());
		case TCKind._tk_any:
		    return myStream.read_any().equal(otherStream.read_any());
		case TCKind._tk_TypeCode:
		    return myStream.read_TypeCode().equal(otherStream.read_TypeCode());
		case TCKind._tk_string:
		    return myStream.read_string().equals(otherStream.read_string());
		case TCKind._tk_wstring:
		    return (myStream.read_wstring().equals(otherStream.read_wstring()));
		case TCKind._tk_longlong:
		    return (myStream.read_longlong() == otherStream.read_longlong());
		case TCKind._tk_ulonglong:
		    return (myStream.read_ulonglong() == otherStream.read_ulonglong());

		case TCKind._tk_objref:
		    return (myStream.read_Object().equals(otherStream.read_Object()));
		case TCKind._tk_Principal:
		    return (myStream.read_Principal().equals(otherStream.read_Principal()));

		case TCKind._tk_enum:
		    return (myStream.read_long() == otherStream.read_long());
		case TCKind._tk_fixed:
		    return (myStream.read_fixed().compareTo(otherStream.read_fixed()) == 0);
		case TCKind._tk_except:
		case TCKind._tk_struct: {
		    int length = realType.member_count();
		    for (int i=0; i<length; i++) {
			if ( ! equalMember(realType.member_type(i), myStream, otherStream)) {
			    return false;
			}
		    }
		    return true;
		}
		case TCKind._tk_union: {
		    Any myDiscriminator = orb.create_any();
		    Any otherDiscriminator = orb.create_any();
		    myDiscriminator.read_value(myStream, realType.discriminator_type());
		    otherDiscriminator.read_value(otherStream, realType.discriminator_type());

		    if ( ! myDiscriminator.equal(otherDiscriminator)) {
			return false;
		    }
		    TypeCodeImpl realTypeCodeImpl = TypeCodeImpl.convertToNative(orb, realType);
		    int memberIndex = realTypeCodeImpl.currentUnionMemberIndex(myDiscriminator);
		    if (memberIndex == -1)
			throw wrapper.unionDiscriminatorError() ;

		    if ( ! equalMember(realType.member_type(memberIndex), myStream, otherStream)) {
			return false;
		    }
		    return true;
		}
		case TCKind._tk_sequence: {
		    int length = myStream.read_long();
		    otherStream.read_long(); // just so that the two stream are in sync
		    for (int i=0; i<length; i++) {
			if ( ! equalMember(realType.content_type(), myStream, otherStream)) {
			    return false;
			}
		    }
		    return true;
		}
		case TCKind._tk_array: {
		    int length = realType.member_count();
		    for (int i=0; i<length; i++) {
			if ( ! equalMember(realType.content_type(), myStream, otherStream)) {
			    return false;
			}
		    }
		    return true;
		}

		// Too complicated to handle value types the way we handle
		// other complex types above. Don't try to decompose it here
		// for faster comparison, just use Object.equals().
		case TCKind._tk_value:
		case TCKind._tk_value_box:
		    org.omg.CORBA_2_3.portable.InputStream mine =
			(org.omg.CORBA_2_3.portable.InputStream)myStream;
		    org.omg.CORBA_2_3.portable.InputStream other =
			(org.omg.CORBA_2_3.portable.InputStream)otherStream;
		    return mine.read_value().equals(other.read_value());

		case TCKind._tk_alias:
		    // error resolving alias above
		    throw wrapper.errorResolvingAlias() ;

		case TCKind._tk_longdouble:
		    throw wrapper.tkLongDoubleNotSupported() ;

		default:
		    throw wrapper.typecodeNotSupported() ;
	    }
	} catch (BadKind badKind) { // impossible
	    throw wrapper.badkindCannotOccur() ;
	} catch (Bounds bounds) { // impossible
	    throw wrapper.boundsCannotOccur() ;
	}
    
public org.omg.CORBA.AnyextractAny(org.omg.CORBA.TypeCode memberType, com.sun.corba.se.spi.orb.ORB orb)

        Any returnValue = orb.create_any();
        OutputStream out = returnValue.create_output_stream();
        TypeCodeImpl.convertToNative(orb, memberType).copy((InputStream)stream, out);
        returnValue.read_value(out.create_input_stream(), memberType);
        return returnValue;
    
public static org.omg.CORBA.AnyextractAnyFromStream(org.omg.CORBA.TypeCode memberType, org.omg.CORBA.portable.InputStream input, com.sun.corba.se.spi.orb.ORB orb)

        Any returnValue = orb.create_any();
        OutputStream out = returnValue.create_output_stream();
        TypeCodeImpl.convertToNative(orb, memberType).copy(input, out);
        returnValue.read_value(out.create_input_stream(), memberType);
        return returnValue;
    
public org.omg.CORBA.Objectextract_Object()
See the description of the general Any operations.

	//debug.log ("extract_Object");
	if (!isInitialized)
	    throw wrapper.extractNotInitialized() ;

	// Check if the object contained here is of the type in typeCode
	org.omg.CORBA.Object obj = null;
	try {
	    obj = (org.omg.CORBA.Object) object;
	    if (typeCode.id().equals("IDL:omg.org/CORBA/Object:1.0") || obj._is_a(typeCode.id())) {
		return obj;
	    } else {
		throw wrapper.extractObjectIncompatible() ;
	    }
	} catch ( Exception ex ) {
	    throw wrapper.extractObjectFailed(ex);
	}
    
public org.omg.CORBA.Principalextract_Principal()

deprecated

	checkExtractBadOperation( TCKind._tk_Principal ) ;
	return (Principal)object;
    
public org.omg.CORBA.portable.Streamableextract_Streamable()

	//debug.log( "extract_Streamable" ) ;
	return (Streamable)object;
    
public org.omg.CORBA.TypeCodeextract_TypeCode()
See the description of the general Any operations.

	//debug.log ("extract_TypeCode");
	checkExtractBadOperation( TCKind._tk_TypeCode ) ;
	return (TypeCode)object;
    
public java.io.Serializableextract_Value()
Note that the Serializable really should be an IDLEntity of some kind. It shouldn't just be an RMI-IIOP type. Currently, we accept and will produce RMI repIds with the latest calculations if given a non-IDLEntity Serializable.

	//debug.log ("extract_Value");
	checkExtractBadOperationList( new int[] { TCKind._tk_value, 
	    TCKind._tk_value_box, TCKind._tk_abstract_interface } ) ;
	return (Serializable)object;
    
public org.omg.CORBA.Anyextract_any()
See the description of the general Any operations.

	//debug.log ("extract_any");
	checkExtractBadOperation( TCKind._tk_any ) ;
	return (Any)object;
    
public booleanextract_boolean()
See the description of the general Any operations.

	//debug.log ("extract_boolean");
	checkExtractBadOperation( TCKind._tk_boolean ) ;
	return (value == 0)? false: true;
    
public charextract_char()
See the description of the general Any operations.

	//debug.log ("extract_char");
	checkExtractBadOperation( TCKind._tk_char ) ;
	return (char)value;
    
public doubleextract_double()
See the description of the general Any operations.

	//debug.log ("extract_double");
	checkExtractBadOperation( TCKind._tk_double ) ;
	return Double.longBitsToDouble(value);
    
public java.math.BigDecimalextract_fixed()

	checkExtractBadOperation( TCKind._tk_fixed ) ;
	return (BigDecimal)object;
    
public floatextract_float()
See the description of the general Any operations.

	//debug.log ("extract_float");
	checkExtractBadOperation( TCKind._tk_float ) ;
	return Float.intBitsToFloat((int)value);
    
public intextract_long()
See the description of the general Any operations.

	//debug.log ("extract_long");
	checkExtractBadOperationList( new int[] { TCKind._tk_long, TCKind._tk_enum } ) ;
	return (int)value;
    
public longextract_longlong()
See the description of the general Any operations.

	//debug.log ("extract_longlong");
	checkExtractBadOperation( TCKind._tk_longlong ) ;
	return value;
    
public byteextract_octet()
See the description of the general Any operations.

	//debug.log ("extract_octet");
	checkExtractBadOperation( TCKind._tk_octet ) ;
	return (byte)value;
    
public shortextract_short()
See the description of the general Any operations.

	//debug.log ("extract_short");
	checkExtractBadOperation( TCKind._tk_short ) ;
	return (short)value;
    
public java.lang.Stringextract_string()
See the description of the general Any operations.

	//debug.log ("extract_string");
	checkExtractBadOperation( TCKind._tk_string ) ;
	return (String)object;
    
public intextract_ulong()
See the description of the general Any operations.

	//debug.log ("extract_ulong");
	checkExtractBadOperation( TCKind._tk_ulong ) ;
	return (int)value;
    
public longextract_ulonglong()
See the description of the general Any operations.

	//debug.log ("extract_ulonglong");
	checkExtractBadOperation( TCKind._tk_ulonglong ) ;
	return value;
    
public shortextract_ushort()
See the description of the general Any operations.

	//debug.log ("extract_ushort");
	checkExtractBadOperation( TCKind._tk_ushort ) ;
	return (short)value;
    
public charextract_wchar()
See the description of the general Any operations.

	//debug.log ("extract_wchar");
	checkExtractBadOperation( TCKind._tk_wchar ) ;
	return (char)value;
    
public java.lang.Stringextract_wstring()
See the description of the general Any operations.

	//debug.log ("extract_wstring");
	checkExtractBadOperation( TCKind._tk_wstring ) ;
	return (String)object;
    
private org.omg.CORBA.TypeCodegetPrimitiveTypeCodeForClass(java.lang.Class c, com.sun.corba.se.spi.orb.ORB tcORB)
It looks like this was copied from io.ValueUtility at some point. It's used by createTypeCodeForClass. The tcORB passed in should have the desired ORB version, and is used to create the type codes.

	//debug.log ("getPrimitiveTypeCodeForClass");

	if (c == Integer.TYPE) {
	    return tcORB.get_primitive_tc (TCKind.tk_long);
	} else if (c == Byte.TYPE) {
	    return tcORB.get_primitive_tc (TCKind.tk_octet);
	} else if (c == Long.TYPE) {
	    return tcORB.get_primitive_tc (TCKind.tk_longlong);
	} else if (c == Float.TYPE) {
	    return tcORB.get_primitive_tc (TCKind.tk_float);
	} else if (c == Double.TYPE) {
	    return tcORB.get_primitive_tc (TCKind.tk_double);
	} else if (c == Short.TYPE) {
	    return tcORB.get_primitive_tc (TCKind.tk_short);
	} else if (c == Character.TYPE) {
	    // For Merlin or later JDKs, or for foreign ORBs,
	    // we correctly say that a Java char maps to a
	    // CORBA wchar.  For backwards compatibility
	    // with our older ORBs, we say it maps to a
	    // CORBA char.  This is only used in RMI-IIOP
	    // in our javax.rmi.CORBA.Util delegate's
	    // writeAny method.  In Java IDL, there's no way
	    // to know the ORB version that the Any will be
	    // sent out with -- it could be different than
	    // the one used to create the Any -- so we use the
	    // most recent version (see insert_Value).
	    if (ORBVersionFactory.getFOREIGN().compareTo(tcORB.getORBVersion()) == 0 ||
		ORBVersionFactory.getNEWER().compareTo(tcORB.getORBVersion()) <= 0)
		return tcORB.get_primitive_tc(TCKind.tk_wchar);
	    else
		return tcORB.get_primitive_tc(TCKind.tk_char);
	} else if (c == Boolean.TYPE) {
	    return tcORB.get_primitive_tc (TCKind.tk_boolean);
	} else {
	    // _REVISIT_ Not sure if this is right.
	    return tcORB.get_primitive_tc (TCKind.tk_any);
	}
    
private java.lang.StringgetTCKindName(int tc)

	if ((tc >= 0) && (tc < TypeCodeImpl.kindNames.length))
	    return TypeCodeImpl.kindNames[tc] ;
	else
	    return "UNKNOWN(" + tc + ")" ;
    
public voidinsert_Object(org.omg.CORBA.Object o)
See the description of the general Any operations.

	//debug.log ("insert_Object");
	if ( o == null ) {
	    typeCode = orb.get_primitive_tc(TCKind._tk_objref);
	} else {
	    if (StubAdapter.isStub(o)) {
		String[] ids = StubAdapter.getTypeIds( o ) ;
		typeCode = new TypeCodeImpl(orb, TCKind._tk_objref, ids[0], "");
	    } else {
		throw wrapper.badInsertobjParam( 
		    CompletionStatus.COMPLETED_MAYBE, o.getClass().getName() ) ;
	    }
	}
	
	object = o;
	isInitialized = true;
    
public voidinsert_Object(org.omg.CORBA.Object o, org.omg.CORBA.TypeCode tc)
A variant of the insertion operation that takes a typecode argument as well.

	//debug.log ("insert_Object2");
	try {
	    if ( tc.id().equals("IDL:omg.org/CORBA/Object:1.0") || o._is_a(tc.id()) )
		{
		    typeCode = TypeCodeImpl.convertToNative(orb, tc);
		    object = o;
		}
	    else {
		throw wrapper.insertObjectIncompatible() ;
	    }
	} catch ( Exception ex ) {
	    throw wrapper.insertObjectFailed(ex) ;
	}
	isInitialized = true;
    
public voidinsert_Principal(org.omg.CORBA.Principal p)

deprecated

	typeCode = orb.get_primitive_tc(TCKind._tk_Principal);
	object = p;
	isInitialized = true;
    
public voidinsert_Streamable(org.omg.CORBA.portable.Streamable s)
takes a streamable and inserts its reference into the any

param
s the streamable to insert

	//debug.log ("insert_Streamable");
	typeCode = TypeCodeImpl.convertToNative(orb, s._type());
	object = s;
	isInitialized = true;
    
public voidinsert_TypeCode(org.omg.CORBA.TypeCode tc)
See the description of the general Any operations.

	//debug.log ("insert_TypeCode");
	typeCode = orb.get_primitive_tc(TCKind._tk_TypeCode);
	object = tc;
	isInitialized = true;
    
public voidinsert_Value(java.io.Serializable v)

	//debug.log ("insert_Value");
	object = v;

	TypeCode tc;

	if ( v == null ) {
	    tc = orb.get_primitive_tc (TCKind.tk_value);
	} else {
	    // See note in getPrimitiveTypeCodeForClass.  We
	    // have to use the latest type code fixes in this
	    // case since there is no way to know what ORB will
	    // actually send this Any.  In RMI-IIOP, when using
	    // Util.writeAny, we can do the versioning correctly,
	    // and use the insert_Value(Serializable, TypeCode)
	    // method.
	    //
	    // The ORB singleton uses the latest version.
	    tc = createTypeCodeForClass (v.getClass(), (ORB)ORB.init());
	}

	typeCode = TypeCodeImpl.convertToNative(orb, tc);
	isInitialized = true;
    
public voidinsert_Value(java.io.Serializable v, org.omg.CORBA.TypeCode t)

	//debug.log ("insert_Value2");
	object = v;
	typeCode = TypeCodeImpl.convertToNative(orb, t);
	isInitialized = true;
    
public voidinsert_any(org.omg.CORBA.Any a)
See the description of the general Any operations.

	//debug.log ("insert_any");
	typeCode = orb.get_primitive_tc(TCKind._tk_any);
	object = a;
	stream = null;
	isInitialized = true;
    
public voidinsert_boolean(boolean b)
See the description of the general Any operations.

	//debug.log ("insert_boolean");
	typeCode = orb.get_primitive_tc(TCKind._tk_boolean);
	value = (b)? 1:0;
	isInitialized = true;
    
public voidinsert_char(char c)
See the description of the general Any operations.

	//debug.log ("insert_char");
	typeCode = orb.get_primitive_tc(TCKind._tk_char);
	value = c;
	isInitialized = true;
    
public voidinsert_double(double d)
See the description of the general Any operations.

	//debug.log ("insert_double");
	typeCode = orb.get_primitive_tc(TCKind._tk_double);
	value = Double.doubleToLongBits(d);
	isInitialized = true;
    
public voidinsert_fixed(java.math.BigDecimal value)

	typeCode = TypeCodeImpl.convertToNative(orb,
	    orb.create_fixed_tc(TypeCodeImpl.digits(value), TypeCodeImpl.scale(value)));
	object = value;
	isInitialized = true;
    
public voidinsert_fixed(java.math.BigDecimal value, org.omg.CORBA.TypeCode type)

	try {
	    if (TypeCodeImpl.digits(value) > type.fixed_digits() ||
		TypeCodeImpl.scale(value) > type.fixed_scale())
	    {
		throw wrapper.fixedNotMatch() ;
	    }
	} catch (org.omg.CORBA.TypeCodePackage.BadKind bk) {
	    // type isn't even of kind fixed
	    throw wrapper.fixedBadTypecode( bk ) ;
	}
	typeCode = TypeCodeImpl.convertToNative(orb, type);
	object = value;
	isInitialized = true;
    
public voidinsert_float(float f)
See the description of the general Any operations.

	//debug.log ("insert_float");
	typeCode = orb.get_primitive_tc(TCKind._tk_float);
	value = Float.floatToIntBits(f);
	isInitialized = true;
    
public voidinsert_long(int l)
See the description of the general Any operations.

	//debug.log ("insert_long");
	// A long value is applicable to enums as well, so don't erase the enum type code
	// in case it was initialized that way before.
	int kind = realType().kind().value();
	if (kind != TCKind._tk_long && kind != TCKind._tk_enum) {
	    typeCode = orb.get_primitive_tc(TCKind._tk_long);
	}
	value = l;
	isInitialized = true;
    
public voidinsert_longlong(long l)
See the description of the general Any operations.

	//debug.log ("insert_longlong");
	typeCode = orb.get_primitive_tc(TCKind._tk_longlong);
	value = l;
	isInitialized = true;
    
public voidinsert_octet(byte b)
See the description of the general Any operations.

	//debug.log ("insert_octet");
	typeCode = orb.get_primitive_tc(TCKind._tk_octet);
	value = b;
	isInitialized = true;
    
public voidinsert_short(short s)
See the description of the general Any operations.

	//debug.log ("insert_short");
	typeCode = orb.get_primitive_tc(TCKind._tk_short);
	value = s;
	isInitialized = true;
    
public voidinsert_string(java.lang.String s)
See the description of the general Any operations.

	//debug.log ("insert_string");
	// Make sure type code information for bounded strings is not erased
	if (typeCode.kind() == TCKind.tk_string) {
	    int length = 0;
	    try { 
		length = typeCode.length(); 
	    } catch (BadKind bad) {
		throw wrapper.badkindCannotOccur() ;
	    }

	    // Check if bounded strings length is not exceeded
	    if (length != 0 && s != null && s.length() > length) {
		throw wrapper.badStringBounds( new Integer(s.length()),
		    new Integer(length) ) ;
	    }
	} else {
	    typeCode = orb.get_primitive_tc(TCKind._tk_string);
	}
	object = s;
	isInitialized = true;
    
public voidinsert_ulong(int l)
See the description of the general Any operations.

	//debug.log ("insert_ulong");
	typeCode = orb.get_primitive_tc(TCKind._tk_ulong);
	value = l;
	isInitialized = true;
    
public voidinsert_ulonglong(long l)
See the description of the general Any operations.

	//debug.log ("insert_ulonglong");
	typeCode = orb.get_primitive_tc(TCKind._tk_ulonglong);
	value = l;
	isInitialized = true;
    
public voidinsert_ushort(short s)
See the description of the general Any operations.

	//debug.log ("insert_ushort");
	typeCode = orb.get_primitive_tc(TCKind._tk_ushort);
	value = s;
	isInitialized = true;
    
public voidinsert_wchar(char c)
See the description of the general Any operations.

	//debug.log ("insert_wchar");
	typeCode = orb.get_primitive_tc(TCKind._tk_wchar);
	value = c;
	isInitialized = true;
    
public voidinsert_wstring(java.lang.String s)
See the description of the general Any operations.

	//debug.log ("insert_wstring");
	// Make sure type code information for bounded strings is not erased
	if (typeCode.kind() == TCKind.tk_wstring) {
	    int length = 0;
	    try { 
		length = typeCode.length(); 
	    } catch (BadKind bad) {
		throw wrapper.badkindCannotOccur() ;
	    }

	    // Check if bounded strings length is not exceeded
	    if (length != 0 && s != null && s.length() > length) {
		throw wrapper.badStringBounds( new Integer(s.length()),
		    new Integer(length) ) ;
	    }
	} else {
	    typeCode = orb.get_primitive_tc(TCKind._tk_wstring);
	}
	object = s;
	isInitialized = true;
    
public booleanisInitialized()

        return isInitialized;
    
public voidread_value(org.omg.CORBA.portable.InputStream in, org.omg.CORBA.TypeCode tc)

 
	//debug.log ("read_value");
	//
	// Assume that someone isn't going to think they can keep reading
	// from this stream after calling us. That would be likely for
	// an IIOPInputStream but if it is an AnyInputStream then they
	// presumably obtained it via our create_output_stream() so they could
	// write the contents of an IDL data type to it and then call
	// create_input_stream() for us to read it. This is how Helper classes
	// typically implement the insert() method.
	// We should probably document this behavior in the 1.1 revision
	// task force.
	//

	typeCode = TypeCodeImpl.convertToNative(orb, tc);
	int kind = realType().kind().value();
	if (kind >= isStreamed.length) {
	    throw wrapper.invalidIsstreamedTckind( CompletionStatus.COMPLETED_MAYBE,
		new Integer(kind)) ;
	}

	if (AnyImpl.isStreamed[kind]) {
	    if ( in instanceof AnyInputStream ) {
		// could only have been created here
		stream = (CDRInputStream)in;
	    } else {
		org.omg.CORBA_2_3.portable.OutputStream out =
		    (org.omg.CORBA_2_3.portable.OutputStream)orb.create_output_stream();
		typeCode.copy((org.omg.CORBA_2_3.portable.InputStream)in, out);
		stream = (CDRInputStream)out.create_input_stream();
	    }
	} else {
	    java.lang.Object[] objholder = new java.lang.Object[1];
	    objholder[0] = object;
	    long[] longholder = new long[1];
	    TCUtility.unmarshalIn(in, typeCode, longholder, objholder);
	    value = longholder[0];
	    object = objholder[0];
	    stream = null;
	}
	isInitialized = true;
    
private org.omg.CORBA.TypeCoderealType()

        return realType(typeCode);
    
private org.omg.CORBA.TypeCoderealType(org.omg.CORBA.TypeCode aType)

        TypeCode realType = aType;
        try {
            // Note: Indirect types are handled in kind() method
            while (realType.kind().value() == TCKind._tk_alias) {
                realType = realType.content_type();
            }
        } catch (BadKind bad) { // impossible
	    throw wrapper.badkindCannotOccur( bad ) ;
        }
        return realType;
    
public org.omg.CORBA.TypeCodetype()
returns the type of the element contained in the Any.

result
the TypeCode for the element in the Any

	return typeCode;
    
public voidtype(org.omg.CORBA.TypeCode tc)
sets the type of the element to be contained in the Any.

param
tc the TypeCode for the element in the Any

	//debug.log ("type2");
	// set the typecode
	typeCode = TypeCodeImpl.convertToNative(orb, tc);

	stream = null;
	value = 0;
	object = null;
	// null is the only legal value this Any can have after resetting the type code
	isInitialized = (tc.kind().value() == TCKind._tk_null);
    
public voidwrite_value(org.omg.CORBA.portable.OutputStream out)

	//debug.log ("write_value");
	if (AnyImpl.isStreamed[realType().kind().value()]) {
	    typeCode.copy(stream.dup(), out);
	} else {
	    // _REVISIT_ check isInitialized whether all we write is TypeCode!
	    TCUtility.marshalIn(out, realType(), value, object);
	}