cdroutputstream_1_0.java

来自「java jdk 1.4的源码」· Java 代码 · 共 2,001 行 · 第 1/4 页

JAVA
2,001
字号
    	    bbwi.index += bytes;    	    n += bytes;    	}    }        public final void write_octet_array(byte b[], int offset, int length)    {        if ( b == null )	    throw new BAD_PARAM(com.sun.corba.se.internal.orbutil.MinorCodes.NULL_PARAM,                                 CompletionStatus.COMPLETED_MAYBE);        // This will only have an effect if we're already chunking        handleSpecialChunkBegin(length);        internalWriteOctetArray(b, offset, length);        // This will only have an effect if we're already chunking        handleSpecialChunkEnd();    }    public void write_Principal(Principal p)    {    	write_long(p.name().length);    	write_octet_array(p.name(), 0, p.name().length);    }    public void write_any(Any any)     {        if ( any == null )	    throw new BAD_PARAM(com.sun.corba.se.internal.orbutil.MinorCodes.NULL_PARAM, CompletionStatus.COMPLETED_MAYBE);    	write_TypeCode(any.type());    	any.write_value(parent);    }    public void write_TypeCode(TypeCode tc)    {        if ( tc == null ) {            throw new BAD_PARAM(com.sun.corba.se.internal.orbutil.MinorCodes.NULL_PARAM, CompletionStatus.COMPLETED_MAYBE);	}        TypeCodeImpl tci;        if (tc instanceof TypeCodeImpl) {	    tci = (TypeCodeImpl)tc;	}        else {	    tci = new TypeCodeImpl(orb, tc);	}        tci.write_value(parent);    }     public void write_Object(org.omg.CORBA.Object ref)    {        if (ref == null) {            IOR.NULL.write(parent);            return;        }	        // IDL to Java formal 01-06-06 1.21.4.2        if (ref instanceof org.omg.CORBA.LocalObject)            throw new MARSHAL("write_Object called with LocalObject",                              MinorCodes.WRITE_LOCAL_OBJECT,                              CompletionStatus.COMPLETED_MAYBE);	        ObjectImpl oi = (ObjectImpl)ref;	ClientSubcontract rep = null;        try {            // If no delegate set:            // org.omg.CORBA.portable.ObjectImpl throws BAD_OPERATION            // org.omg.PortableServer.Servant throws BAD_INV_ORDER            rep = (ClientSubcontract) oi._get_delegate();        } catch ( BAD_OPERATION ex ) {            debugPrintThrowable(ex);        } catch ( BAD_INV_ORDER ex ) {            debugPrintThrowable(ex);        }        if ( rep == null ) {	    // no delegate: servant was not connected to ORB				    if (ref instanceof javax.rmi.CORBA.Stub) {                try {		    ((javax.rmi.CORBA.Stub)ref).connect(orb);		} catch (java.rmi.RemoteException e) {                    debugPrintThrowable(e);		    throw new MARSHAL("Error connecting servant: "                                      + e.getMessage(),                                      MinorCodes.CONNECTING_SERVANT,                                      CompletionStatus.COMPLETED_MAYBE);		}	    } else {		orb.connect(ref);	    }	    rep = (ClientSubcontract) oi._get_delegate();        }	        IOR ior = rep.marshal();	ior.write(parent);	return;    }    // ------------ RMI related methods --------------------------    public void write_abstract_interface(java.lang.Object obj) {	boolean corbaObject = false; // Assume value type.	org.omg.CORBA.Object theObject = null;	    	// Is it a CORBA.Object?	    	if (obj != null && obj instanceof org.omg.CORBA.Object) {	        	    // Yes.	        	    theObject = (org.omg.CORBA.Object)obj;	    corbaObject = true;	        	}	    	// Write our flag...	    	write_boolean(corbaObject);	    	// Now write out the object...	    	if (corbaObject) {	    write_Object(theObject);	} else {	    try {		write_value((java.io.Serializable)obj);	    } catch(ClassCastException cce) {		if (obj instanceof java.io.Serializable)		    throw cce;		else                    ORBUtility.throwNotSerializableForCorba(obj.getClass().getName());	    }	}    }    public void write_value(Serializable object, Class clz) {	write_value(object);     }    public void write_value(Serializable object, String repository_id) {	// Handle null references	if (object == null) {	    // Write null tag and return	    write_long(0);	    return;	}	// Handle shared references	if ((valueCache != null) && valueCache.containsKey(object)) {            writeIndirection(INDIRECTION_TAG, valueCache.getVal(object));	    return;	} 			Class clazz = object.getClass();	boolean oldMustChunk = mustChunk;	// _REVISIT_ should this be done when mustChunk is false?	if (inBlock)	    end_block();	// Handle arrays	if (clazz.isArray())	    {		if (valueHandler == null)		    valueHandler = ORBUtility.createValueHandler(orb); //d11638		if (mustChunk) {		    // Write value_tag		    int indirection = writeValueTag(true, false, Util.getCodebase(clazz));						    // Write repository ID		    write_repositoryId(repIdStrs.createSequenceRepID(clazz));						    // Add indirection for object to indirection table		    updateIndirectionTable(indirection, object, object);						    // Write Value chunk		    start_block();		    end_flag--;                    chunkedValueNestingLevel--;		    valueHandler.writeValue(parent, object);		    end_block();						    // Write end tag		    writeEndTag(true);		}		else {		    // Write value_tag		    int indirection = writeValueTag(false, false, Util.getCodebase(clazz));						    // Write repository ID		    write_repositoryId(repIdStrs.createSequenceRepID(clazz));						    // Add indirection for object to indirection table		    updateIndirectionTable(indirection, object, object);						    // Write Value chunk		    end_flag--;		    valueHandler.writeValue(parent, object);						    // Write end tag		    writeEndTag(false);		}				    }	// Handle IDL Value types	else if (object instanceof org.omg.CORBA.portable.ValueBase)	    {		// _REVISIT_ could check to see whether chunking really needed 		mustChunk = true;					// Write value_tag		int indirection = writeValueTag(true, false, Util.getCodebase(clazz));					// Get rep id		String repId = ((ValueBase)object)._truncatable_ids()[0];					// Write rep id		write_repositoryId(repId);					// Add indirection for object to indirection table		updateIndirectionTable(indirection, object, object);					// Write Value chunk		start_block();		end_flag--;                chunkedValueNestingLevel--;		writeIDLValue(object, repId);		end_block();					// Write end tag		writeEndTag(true);	    }	else if (shouldWriteAsIDLEntity(object))	    {		writeIDLEntity((IDLEntity)object);	    }	else if (object instanceof java.lang.String)	    {		if (mustChunk) {		    // Write value_tag		    int indirection = writeValueTag(true, false, null);						    // Write WStringValue's repository ID		    write_repositoryId(repIdStrs.getWStringValueRepId());						    // Add indirection for object to indirection table		    updateIndirectionTable(indirection, object, object);						    // Write Value chunk		    start_block();		    end_flag--;                    chunkedValueNestingLevel--;		    write_wstring((java.lang.String)object);		    end_block();						    // Write end tag		    writeEndTag(true);		}		else {		    int indirection = writeValueTag(false, false, null);						    // Write WStringValue's repository ID		    write_repositoryId(repIdStrs.getWStringValueRepId());						    // Add indirection for object to indirection table		    updateIndirectionTable(indirection, object, object);						    // Write Value chunk		    end_flag--;		    write_wstring((java.lang.String)object);						    // Write end tag		    writeEndTag(false);		}				    }	else if (object instanceof java.lang.Class)	    {		writeClass(repository_id, (Class)object);	    }	else // Not a CORBA Value Type	    {		if (valueHandler == null)		    valueHandler = ORBUtility.createValueHandler(orb); //d11638		Serializable key = object;		object = valueHandler.writeReplace(key);				if (object == null) {		    // Write null tag and return		    write_long(0);		    return;		}				if (object != key) {		    if ((valueCache != null) && valueCache.containsKey(object)) {                        writeIndirection(INDIRECTION_TAG, valueCache.getVal(object));			return;		    }		    clazz = object.getClass();		}		if (mustChunk || valueHandler.isCustomMarshaled(clazz)) {		    mustChunk = true;						    // Write value_tag		    int indirection = writeValueTag(true, false, Util.getCodebase(clazz));						    // Write rep. id		    write_repositoryId(repIdStrs.createForJavaType(clazz));						    // Add indirection for object to indirection table		    updateIndirectionTable(indirection, object, key);						    // Write Value chunk		    end_flag--;                    chunkedValueNestingLevel--;		    start_block();		    valueHandler.writeValue(parent, object);		    end_block();						    // Write end tag		    writeEndTag(true);		}		else {		    // Write value_tag		    int indirection = writeValueTag(false, false, Util.getCodebase(clazz));						    // Write rep. id		    write_repositoryId(repIdStrs.createForJavaType(clazz));						    // Add indirection for object to indirection table		    updateIndirectionTable(indirection, object, key);						    // Write Value chunk		    end_flag--;		    valueHandler.writeValue(parent, object);						    // Write end tag		    writeEndTag(false);		}				    }			mustChunk = oldMustChunk;	// Check to see if we need to start another block for a	// possible outer value	if (mustChunk)	    start_block();    }    public void write_value(Serializable object)    {	// Handle null references	if (object == null) {	    // Write null tag and return	    write_long(0);	    return;	}	// Handle shared references	if ((valueCache != null) && valueCache.containsKey(object)) {            writeIndirection(INDIRECTION_TAG, valueCache.getVal(object));	    return;	}		Class clazz = object.getClass();	boolean oldMustChunk = mustChunk;	// _REVISIT_ should this be done when mustChunk is false?	if (inBlock)	    end_block();	// Handle arrays	if (clazz.isArray())	    {		if (valueHandler == null)		    valueHandler = ORBUtility.createValueHandler(orb); //d11638		if (mustChunk) {		    // Write value_tag		    int indirection = writeValueTag(true, false, Util.getCodebase(clazz));						    // Write repository ID		    write_repositoryId(repIdStrs.createSequenceRepID(clazz));						    // Add indirection for object to indirection table		    updateIndirectionTable(indirection, object, object);						    // Write Value chunk		    start_block();		    end_flag--;                    chunkedValueNestingLevel--;		    valueHandler.writeValue(parent, object);		    end_block();						    // Write end tag		    writeEndTag(true);		}		else {		    // Write value_tag		    int indirection = writeValueTag(false, false, Util.getCodebase(clazz));						    // Write repository ID		    write_repositoryId(repIdStrs.createSequenceRepID(clazz));						    // Add indirection for object to indirection table		    updateIndirectionTable(indirection, object, object);						    // Write Value chunk		    end_flag--;		    valueHandler.writeValue(parent, object);						    // Write end tag		    writeEndTag(false);						}				    }	// Handle IDL Value types	else if (object instanceof org.omg.CORBA.portable.ValueBase)	    {		// _REVISIT_ could check to see whether chunking really needed 		mustChunk = true;					// Write value_tag		int indirection = writeValueTag(true, false, Util.getCodebase(clazz));						// Get rep id		String repId = ((ValueBase)object)._truncatable_ids()[0];					// Write rep id		write_repositoryId(repId);					// Add indirection for object to indirection table		updateIndirectionTable(indirection, object, object);					// Write Value chunk		start_block();		end_flag--;                chunkedValueNestingLevel--;					writeIDLValue(object, repId);					end_block();					writeEndTag(true);	    }	else if (shouldWriteAsIDLEntity(object))	    {		writeIDLEntity((IDLEntity)object);	    }	else if (object instanceof java.lang.String)	    {					// Write value_tag		//   Are we nested ?		if (mustChunk) { 		    int indirection = writeValueTag(true, false, null);						    // Write WStringValue's repository ID		    write_repositoryId(repIdStrs.getWStringValueRepId());						    // Add indirection for object to indirection table		    updateIndirectionTable(indirection, object, object);						    // Write Value chunk		    start_block();		    end_flag--;                    chunkedValueNestingLevel--;		    write_wstring((java.lang.String)object);		    end_block();						    // Write end tag		    writeEndTag(true);		}		else {		    int indirection = writeValueTag(false, false, null);						    // Write WStringValue's repository ID		    write_repositoryId(repIdStrs.getWStringValueRepId());						    // Add indirection for object to indirection table		    updateIndirectionTable(indirection, object, object);						    // Write Value chunk		    end_flag--;		    write_wstring((java.lang.String)object);						    // Write end tag

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?