⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 iiopinputstream.java

📁 java jdk 1.4的源码
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
                    if (type != null)                        objectValue = Utility.readAbstractAndNarrow(orbStream, type);                    else                        objectValue = orbStream.read_abstract_interface();                    break;                case ValueHandlerImpl.kValueType:                    if (type != null)                        objectValue = orbStream.read_value(type);                    else                        objectValue = orbStream.read_value();                    break;                default:                    throw new StreamCorruptedException("Unknown callType: " + callType);            }        }        return objectValue;    }    /**     * Factored out of inputClassFields and reused in      * inputCurrentClassFieldsForReadFields.     *     * Reads the field (which of an Object type as opposed to a primitive)      * described by ObjectStreamField field and returns it.     */    private Object inputObjectField(ObjectStreamField field)         throws InvalidClassException, StreamCorruptedException,               ClassNotFoundException, IndirectionException, IOException {        if (ObjectStreamClassCorbaExt.isAny(field.getTypeString())) {            return javax.rmi.CORBA.Util.readAny(orbStream);        }        Object objectValue = null;        // fields have an API to provide the actual class        // corresponding to the data type        // Class type = osc.forClass();        Class type = field.getType();				        // Decide what method call to make based on the type. If        // it is a type for which we need to load a stub, convert        // the type to the correct stub type.                int callType = ValueHandlerImpl.kValueType;        boolean narrow = false;                if (type.isInterface()) {             boolean loadStubClass = false;                        if (java.rmi.Remote.class.isAssignableFrom(type)) {                                // RMI Object reference...                callType = ValueHandlerImpl.kRemoteType;                            } else if (org.omg.CORBA.Object.class.isAssignableFrom(type)){                                // IDL Object reference...                callType = ValueHandlerImpl.kRemoteType;                loadStubClass = true;                            } else if (vhandler.isAbstractBase(type)) {                // IDL Abstract Object reference...                                callType = ValueHandlerImpl.kAbstractType;                loadStubClass = true;            } else if (ObjectStreamClassCorbaExt.isAbstractInterface(type)) {                // RMI Abstract Object reference...                                callType = ValueHandlerImpl.kAbstractType;            }                        if (loadStubClass) {                try {                    String codebase = Util.getCodebase(type);                    String repID = vhandler.createForAnyType(type);                    type = Utility.loadStubClass(repID, codebase, type); //d11638                } catch (ClassNotFoundException e) {                    narrow = true;                }            } else {                narrow = true;            }        }			        switch (callType) {            case ValueHandlerImpl.kRemoteType:                 if (!narrow)                     objectValue = (Object)orbStream.read_Object(type);                else                    objectValue = Utility.readObjectAndNarrow(orbStream, type);                break;            case ValueHandlerImpl.kAbstractType:                 if (!narrow)                    objectValue = (Object)orbStream.read_abstract_interface(type);                 else                    objectValue = Utility.readAbstractAndNarrow(orbStream, type);                break;            case ValueHandlerImpl.kValueType:                objectValue = (Object)orbStream.read_value(type);                break;            default:                throw new StreamCorruptedException("Unknown callType: " + callType);        }        return objectValue;    }    private final boolean mustUseRemoteValueMembers() {        return defaultReadObjectFVDMembers != null;    }    void readFields(java.util.Map fieldToValueMap)        throws InvalidClassException, StreamCorruptedException,               ClassNotFoundException, IOException {        if (mustUseRemoteValueMembers()) {            inputRemoteMembersForReadFields(fieldToValueMap);        } else            inputCurrentClassFieldsForReadFields(fieldToValueMap);    }    private final void inputRemoteMembersForReadFields(java.util.Map fieldToValueMap)        throws InvalidClassException, StreamCorruptedException,               ClassNotFoundException, IOException {        // Must have this local variable since defaultReadObjectFVDMembers        // may get mangled by recursion.        ValueMember fields[] = defaultReadObjectFVDMembers;	try {	    for (int i = 0; i < fields.length; i++) {                                switch (fields[i].type.kind().value()) {                case TCKind._tk_octet:                    byte byteValue = orbStream.read_octet();                    fieldToValueMap.put(fields[i].name, new Byte(byteValue));                    break;                case TCKind._tk_boolean:                    boolean booleanValue = orbStream.read_boolean();                    fieldToValueMap.put(fields[i].name, new Boolean(booleanValue));                    break;                case TCKind._tk_char:                    // Backwards compatibility.  Older Sun ORBs sent                    // _tk_char even though they read and wrote wchars                    // correctly.                    //                    // Fall through to the _tk_wchar case.                case TCKind._tk_wchar:                    char charValue = orbStream.read_wchar();                    fieldToValueMap.put(fields[i].name, new Character(charValue));                    break;                case TCKind._tk_short:                    short shortValue = orbStream.read_short();                    fieldToValueMap.put(fields[i].name, new Short(shortValue));                    break;                case TCKind._tk_long:                    int intValue = orbStream.read_long();                    fieldToValueMap.put(fields[i].name, new Integer(intValue));                    break;                case TCKind._tk_longlong:                    long longValue = orbStream.read_longlong();                    fieldToValueMap.put(fields[i].name, new Long(longValue));                    break;                case TCKind._tk_float:                    float floatValue = orbStream.read_float();                    fieldToValueMap.put(fields[i].name, new Float(floatValue));                    break;                case TCKind._tk_double:                    double doubleValue = orbStream.read_double();                    fieldToValueMap.put(fields[i].name, new Double(doubleValue));                    break;                case TCKind._tk_value:                case TCKind._tk_objref:                case TCKind._tk_value_box:                    Object objectValue = null;                    try {                        objectValue = inputObjectField(fields[i],                                                       cbSender);                    } catch (IndirectionException cdrie) {                        // The CDR stream had never seen the given offset before,                        // so check the recursion manager (it will throw an                        // IOException if it doesn't have a reference, either).                        objectValue = activeRecursionMgr.getObject(cdrie.offset);                    }                    fieldToValueMap.put(fields[i].name, objectValue);                    break;                default:                    throw new StreamCorruptedException("Unknown kind: "                                                       + fields[i].type.kind().value());                }            }        } catch (Throwable t) {            throw new StreamCorruptedException(t.getMessage());	}    }    /**     * Called from InputStreamHook.     *     * Reads the fields of the current class (could be the ones     * queried from the remote FVD) and puts them in     * the given Map, name to value.  Wraps primitives in the     * corresponding java.lang Objects.     */    private final void inputCurrentClassFieldsForReadFields(java.util.Map fieldToValueMap)        throws InvalidClassException, StreamCorruptedException,               ClassNotFoundException, IOException {        ObjectStreamField[] fields = currentClassDesc.getFieldsNoCopy();	int primFields = fields.length - currentClassDesc.objFields;        // Handle the primitives first        for (int i = 0; i < primFields; ++i) {            switch (fields[i].getTypeCode()) {                case 'B':                    byte byteValue = orbStream.read_octet();                    fieldToValueMap.put(fields[i].getName(),                                        new Byte(byteValue));                    break;                case 'Z':                   boolean booleanValue = orbStream.read_boolean();                   fieldToValueMap.put(fields[i].getName(),                                       new Boolean(booleanValue));                   break;		case 'C':                    char charValue = orbStream.read_wchar();                    fieldToValueMap.put(fields[i].getName(),                                        new Character(charValue));                    break;		case 'S':                    short shortValue = orbStream.read_short();                    fieldToValueMap.put(fields[i].getName(),                                        new Short(shortValue));                    break;		case 'I':                    int intValue = orbStream.read_long();                    fieldToValueMap.put(fields[i].getName(),                                        new Integer(intValue));                    break;		case 'J':                    long longValue = orbStream.read_longlong();                    fieldToValueMap.put(fields[i].getName(),                                        new Long(longValue));                    break;		case 'F' :                    float floatValue = orbStream.read_float();                    fieldToValueMap.put(fields[i].getName(),                                        new Float(floatValue));                    break;		case 'D' :                    double doubleValue = orbStream.read_double();                    fieldToValueMap.put(fields[i].getName(),                                        new Double(doubleValue));                    break;		default:                    throw new InvalidClassException(currentClassDesc.getName());	    }	}	/* Read and set object fields from the input stream. */	if (currentClassDesc.objFields > 0) {	    for (int i = primFields; i < fields.length; i++) {                Object objectValue = null;                try {                    objectValue = inputObjectField(fields[i]);                } catch(IndirectionException cdrie) {                    // The CDR stream had never seen the given offset before,                    // so check the recursion manager (it will throw an                    // IOException if it doesn't have a reference, either).                    objectValue = activeRecursionMgr.getObject(cdrie.offset);                }                fieldToValueMap.put(fields[i].getName(), objectValue);            }        }    }    /*     * Read the fields of the specified class from the input stream and set     * the values of the fields in the specified object. If the specified     * object is null, just consume the fields without setting any values. If     * any ObjectStreamField does not have a reflected Field, don't try to set     * that field in the object.     *     * REVISIT -- This code doesn't do what the comment says to when     * getField() is null!     */    private void inputClassFields(Object o, Class cl,				  ObjectStreamField[] fields, 				  com.sun.org.omg.SendingContext.CodeBase sender)	throws InvalidClassException, StreamCorruptedException,	       ClassNotFoundException, IOException    {			int primFields = fields.length - currentClassDesc.objFields;	if (o != null) {	    for (int i = 0; i < primFields; ++i) {		if (fields[i].getField() == null)		    continue;                inputPrimitiveField(o, cl, fields[i]);	    }	}	/* Read and set object fields from the input stream. */	if (currentClassDesc.objFields > 0) {	    for (int i = primFields; i < fields.length; i++) {		Object objectValue = null;                try {                    objectValue = inputObjectField(fields[i]);                } catch(IndirectionException cdrie) {                    // The CDR stream had never seen the given offset before,                    // so check the recursion manager (it will throw an                    // IOException if it doesn't have a reference, either).                    objectValue = activeRecursionMgr.getObject(cdrie.offset);                }		if ((o == null) || (fields[i].getField() == null)) {		    continue;		}		try {		    setObjectFieldOpt(o, fields[i].getFieldID(cl), objectValue);		} catch (IllegalArgumentException e) {		    throw new ClassCastException("Assigning instance of class " +						 objectValue.getClass().getName() +						 " to field " +						 currentClassDesc.getName() +						 '#' +						 fields[i].getField().getName());		}	    } // end : for loop	    }	}    /*     * Read the fields of the specified class from the input stream and set     * the values of the fields in the specified object. If the specified     * object is null, just consume the fields without setting any values. If     * any ObjectStreamField does not have a reflected Field, don't try to set     * that field in the object.     */    private void inputClassFields(Object o, Class cl, 				  ObjectStreamClass osc,				  ValueMember[] fields,				  com.sun.org.omg.SendingContext.CodeBase sender)	throws InvalidClassException, StreamCorruptedException,	       ClassNotFoundException, IOException    {	try{	    for (int i = 0; i < fields.length; ++i) {		try {		    switch (fields[i].type.kind().value()) {

⌨️ 快捷键说明

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