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

📄 valuehandlerimpl.java

📁 Mobile 应用程序使用 Java Micro Edition (Java ME) 平台
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
                                 char[] array,                                 int offset,                                 int length)    {          in.read_wchar_array(array, offset, length);    }    private java.lang.Object read_Array(IIOPInputStream bridge,                                         org.omg.CORBA_2_3.portable.InputStream in,					Class sequence,                                         com.sun.org.omg.SendingContext.CodeBase sender,                                        int offset)     {    	try {	    // Read length of coming array            int length = in.read_ulong();            int i;	    if (sequence == null) {		for (i = 0; i < length; i++)		    in.read_value();		return null;	    }				    Class componentType = sequence.getComponentType();	    Class actualType = componentType;            if (componentType.isPrimitive()) {                if (componentType == Integer.TYPE) {		    int[] array = new int[length];		    in.read_long_array(array, 0, length);		    return ((java.io.Serializable)((Object)array));                } else if (componentType == Byte.TYPE) {		    byte[] array = new byte[length];		    in.read_octet_array(array, 0, length);		    return ((java.io.Serializable)((Object)array));                } else if (componentType == Long.TYPE) {		    long[] array = new long[length];		    in.read_longlong_array(array, 0, length);		    return ((java.io.Serializable)((Object)array));                } else if (componentType == Float.TYPE) {		    float[] array = new float[length];		    in.read_float_array(array, 0, length);		    return ((java.io.Serializable)((Object)array));                } else if (componentType == Double.TYPE) {		    double[] array = new double[length];		    in.read_double_array(array, 0, length);		    return ((java.io.Serializable)((Object)array));                } else if (componentType == Short.TYPE) {		    short[] array = new short[length];		    in.read_short_array(array, 0, length);		    return ((java.io.Serializable)((Object)array));                } else if (componentType == Character.TYPE) {		    char[] array = new char[length];		    readCharArray(in, array, 0, length);		    return ((java.io.Serializable)((Object)array));                } else if (componentType == Boolean.TYPE) {		    boolean[] array = new boolean[length];		    in.read_boolean_array(array, 0, length);		    return ((java.io.Serializable)((Object)array));                } else {		    // XXX I18N, logging needed.		    throw new Error("Invalid primitive componentType : " + sequence.getName());                }            } else if (componentType == java.lang.Object.class) {		Object[] array = (Object[])java.lang.reflect.Array.newInstance(		    componentType, length);                // Store this object and its beginning position                // since there might be indirections to it while                // it's been unmarshalled.                bridge.activeRecursionMgr.addObject(offset, array);                for (i = 0; i < length; i++) {                    Object objectValue = null;                    try {                        objectValue = Util.readAny(in);                    } catch(IndirectionException cdrie) {                        try {                            // 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 = bridge.activeRecursionMgr.getObject(				cdrie.offset);                        } catch (IOException ie) {                            // Translate to a MARSHAL exception since                            // ValueHandlers aren't allowed to throw                            // IOExceptions			    throw utilWrapper.invalidIndirection( ie,				new Integer( cdrie.offset ) ) ;                        }                    }                                        array[i] = objectValue;                }                return ((java.io.Serializable)((Object)array));            } else {		Object[] array = (Object[])java.lang.reflect.Array.newInstance(		    componentType, length);                // Store this object and its beginning position                // since there might be indirections to it while                // it's been unmarshalled.				                bridge.activeRecursionMgr.addObject(offset, array);		// Decide what method call to make based on the componentType.		// If it is a componentType for which we need to load a stub,		// convert the componentType to the correct stub type.				                int callType = kValueType;                boolean narrow = false;				                if (componentType.isInterface()) {                     boolean loadStubClass = false;                    // String className = componentType.getName();                                            if (java.rmi.Remote.class.isAssignableFrom(componentType)) {						                        // RMI Object reference...                        callType = kRemoteType;                                                // for better performance, load the stub class once                        // instead of for each element of the array                        loadStubClass = true;                    } else if (org.omg.CORBA.Object.class.isAssignableFrom(componentType)){                        // IDL Object reference...                        callType = kRemoteType;                        loadStubClass = true;                    } else if (RepositoryId.isAbstractBase(componentType)) {                        // IDL Abstract Object reference...                        callType = kAbstractType;                        loadStubClass = true;                    } else if (ObjectStreamClassCorbaExt.isAbstractInterface(componentType)) {                                                // RMI Abstract Object reference...                                                // componentType = null;                        callType = kAbstractType;                    }                    if (loadStubClass) {                        try {                            String codebase = Util.getCodebase(componentType);                            String repID = RepositoryId.createForAnyType(componentType);                            Class stubType = 				Utility.loadStubClass(repID, codebase, componentType); 			    actualType = stubType;                        } catch (ClassNotFoundException e) {                            narrow = true;                        }                    } else {                        narrow = true;                    }                }                for (i = 0; i < length; i++) {                                        try {                        switch (callType) {                        case kRemoteType:                             if (!narrow)                                array[i] = (Object)in.read_Object(actualType);                             else {                                array[i] = Utility.readObjectAndNarrow(in, actualType);                                                            }                            break;                        case kAbstractType:                             if (!narrow)                                array[i] = (Object)in.read_abstract_interface(actualType);                             else {                                array[i] = Utility.readAbstractAndNarrow(in, actualType);                            }                            break;                        case kValueType:                            array[i] = (Object)in.read_value(actualType);                            break;                        }                    } 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).                        try {                            array[i] = bridge.activeRecursionMgr.getObject(				cdrie.offset);                        } catch (IOException ioe) {                            // Translate to a MARSHAL exception since                            // ValueHandlers aren't allowed to throw                            // IOExceptions			    throw utilWrapper.invalidIndirection( ioe,				new Integer( cdrie.offset ) ) ;                        }                    }                                    }                                return ((java.io.Serializable)((Object)array));	    }        } finally {            // We've completed deserializing this object.  Any            // future indirections will be handled correctly at the            // CDR level.  The ActiveRecursionManager only deals with            // objects currently being deserialized.            bridge.activeRecursionMgr.removeObject(offset);        }    }    private boolean isArray(String repId){	return RepositoryId.cache.getId(repId).isSequence();    }    protected String getOutputStreamClassName() {        return "com.sun.corba.se.impl.io.IIOPOutputStream";    }    private com.sun.corba.se.impl.io.IIOPOutputStream createOutputStream() {        return (com.sun.corba.se.impl.io.IIOPOutputStream)AccessController.doPrivileged(	    new StreamFactory(getOutputStreamClassName()));    }    protected String getInputStreamClassName() {        return "com.sun.corba.se.impl.io.IIOPInputStream";    }    private com.sun.corba.se.impl.io.IIOPInputStream createInputStream() {        return (com.sun.corba.se.impl.io.IIOPInputStream)AccessController.doPrivileged(	    new StreamFactory(getInputStreamClassName()));    }    /**     * Instantiates a class of the given name using the system ClassLoader     * as part of a PrivilegedAction.     *     * It's private final so hopefully people can't grab it outside of     * this class.     *     * If you're worried that someone could subclass ValueHandlerImpl,     * install his own streams, and snoop what's on the wire:     * Someone can do that only if he's allowed to use the feature     * of installing his own javax.rmi.CORBA.Util delegate (via a     * JVM property or orb.properties file, read the first time the     * Util class is used).  If he can do that, he can snoop     * anything on the wire, anyway, without abusing the     * StreamFactory class.     */    private static final class StreamFactory implements PrivilegedAction {        private String className;        public StreamFactory (String _className) {            className = _className;        }        public Object run() {            try {                // Note: We must use the system ClassLoader here                // since we want to load classes outside of the                // core JDK when running J2EE Pure ORB and                // talking to Kestrel.                ClassLoader cl = Thread.currentThread().getContextClassLoader();                if (cl == null)                    cl = ClassLoader.getSystemClassLoader();                Class streamClass = cl.loadClass(className);                // Since the ClassLoader should cache the class, this isn't                // as expensive as it looks.                return streamClass.newInstance();            } catch(Throwable t) {                InternalError ie = new InternalError( "Error loading " + className ) ;		ie.initCause( t ) ;		throw ie ;            }        }    }    /**     * Our JDK 1.3 and JDK 1.3.1 behavior subclasses override this.     * The correct behavior is for a Java char to map to a CORBA wchar,     * but our older code mapped it to a CORBA char.     */    protected TCKind getJavaCharTCKind() {        return TCKind.tk_wchar;    }}

⌨️ 快捷键说明

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