cdrinputstream_1_0.java

来自「JAVA 所有包」· Java 代码 · 共 1,977 行 · 第 1/5 页

JAVA
1,977
字号
    // No such type in java    public final double read_longdouble() {	throw wrapper.longDoubleNotImplemented( CompletionStatus.COMPLETED_MAYBE);    }    public final boolean read_boolean() {	return (read_octet() != 0);    }    public final char read_char() {        alignAndCheck(1, 1);        return getConvertedChars(1, getCharConverter())[0];    }    public char read_wchar() {        // Don't allow transmission of wchar/wstring data with        // foreign ORBs since it's against the spec.        if (ORBUtility.isForeignORB((ORB)orb)) {	    throw wrapper.wcharDataInGiop10( CompletionStatus.COMPLETED_MAYBE);        }        // If we're talking to one of our legacy ORBs, do what        // they did:        int b1, b2;	alignAndCheck(2, 2);	if (littleEndian) {	    b2 = bbwi.byteBuffer.get(bbwi.position()) & 0x00FF;            bbwi.position(bbwi.position() + 1);	    b1 = bbwi.byteBuffer.get(bbwi.position()) & 0x00FF;            bbwi.position(bbwi.position() + 1);	} else {	    b1 = bbwi.byteBuffer.get(bbwi.position()) & 0x00FF;            bbwi.position(bbwi.position() + 1);	    b2 = bbwi.byteBuffer.get(bbwi.position()) & 0x00FF;            bbwi.position(bbwi.position() + 1);	}	return (char)((b1 << 8) + (b2 << 0));    }    public final byte read_octet() {        alignAndCheck(1, 1);    	byte b = bbwi.byteBuffer.get(bbwi.position());        bbwi.position(bbwi.position() + 1);    	return b;    }    public final short read_short() {    	int b1, b2;    	alignAndCheck(2, 2);    	if (littleEndian) {    	    b2 = (bbwi.byteBuffer.get(bbwi.position()) << 0) & 0x000000FF;            bbwi.position(bbwi.position() + 1);    	    b1 = (bbwi.byteBuffer.get(bbwi.position()) << 8) & 0x0000FF00;            bbwi.position(bbwi.position() + 1);    	} else {    	    b1 = (bbwi.byteBuffer.get(bbwi.position()) << 8) & 0x0000FF00;            bbwi.position(bbwi.position() + 1);    	    b2 = (bbwi.byteBuffer.get(bbwi.position()) << 0) & 0x000000FF;            bbwi.position(bbwi.position() + 1);    	}    	return (short)(b1 | b2);    }    public final short read_ushort() {	return read_short();    }    public final int read_long() {    	int b1, b2, b3, b4;        alignAndCheck(4, 4);        int bufPos = bbwi.position();    	if (littleEndian) {    	    b4 = bbwi.byteBuffer.get(bufPos++) & 0xFF;    	    b3 = bbwi.byteBuffer.get(bufPos++) & 0xFF;    	    b2 = bbwi.byteBuffer.get(bufPos++) & 0xFF;    	    b1 = bbwi.byteBuffer.get(bufPos++) & 0xFF;    	} else {    	    b1 = bbwi.byteBuffer.get(bufPos++) & 0xFF;    	    b2 = bbwi.byteBuffer.get(bufPos++) & 0xFF;    	    b3 = bbwi.byteBuffer.get(bufPos++) & 0xFF;    	    b4 = bbwi.byteBuffer.get(bufPos++) & 0xFF;    	}        bbwi.position(bufPos);    	return (b1 << 24) | (b2 << 16) | (b3 << 8) | b4;    }    public final int read_ulong() {	return read_long();    }    public final long read_longlong() {    	long i1, i2;    	alignAndCheck(8, 8);    	if (littleEndian) {    	    i2 = read_long() & 0xFFFFFFFFL;    	    i1 = (long)read_long() << 32;    	} else {    	    i1 = (long)read_long() << 32;    	    i2 = read_long() & 0xFFFFFFFFL;    	}    	return (i1 | i2);    }    public final long read_ulonglong() {	return read_longlong();    }    public final float read_float() {	return Float.intBitsToFloat(read_long());    }    public final double read_double() {	return Double.longBitsToDouble(read_longlong());    }    protected final void checkForNegativeLength(int length) {        if (length < 0)	    throw wrapper.negativeStringLength( CompletionStatus.COMPLETED_MAYBE,		new Integer(length) ) ;    }    protected final String readStringOrIndirection(boolean allowIndirection) {    	int len = read_long();        //        // Check for indirection        //        if (allowIndirection) {            if (len == 0xffffffff)		return null;	    else		stringIndirection = get_offset() - 4;	}        checkForNegativeLength(len);        if (orb != null && ORBUtility.isLegacyORB((ORB)orb))            return legacyReadString(len);        else            return internalReadString(len);    }    private final String internalReadString(int len) {    	// Workaround for ORBs which send string lengths of    	// zero to mean empty string.        //        // IMPORTANT: Do not replace 'new String("")' with "", it may result        // in a Serialization bug (See serialization.zerolengthstring) and        // bug id: 4728756 for details    	if (len == 0)    	    return new String("");        char[] result = getConvertedChars(len - 1, getCharConverter());        // Skip over the 1 byte null        read_octet();        return new String(result, 0, getCharConverter().getNumChars());    }    private final String legacyReadString(int len) {    	//    	// Workaround for ORBs which send string lengths of    	// zero to mean empty string.    	//        //        // IMPORTANT: Do not replace 'new String("")' with "", it may result        // in a Serialization bug (See serialization.zerolengthstring) and        // bug id: 4728756 for details    	if (len == 0)    	    return new String("");        len--;        char[] c = new char[len];    	int n = 0;    	while (n < len) {    	    int avail;    	    int bytes;    	    int wanted;    	    avail = bbwi.buflen - bbwi.position();            if (avail <= 0) {                grow(1, 1);                avail = bbwi.buflen - bbwi.position();            }    	    wanted = len - n;    	    bytes = (wanted < avail) ? wanted : avail;            // Microbenchmarks are showing a loop of ByteBuffer.get(int) being            // faster than ByteBuffer.get(byte[], int, int).            for (int i=0; i<bytes; i++) {        	c[n+i] = (char) (bbwi.byteBuffer.get(bbwi.position()+i) & 0xFF);            }            bbwi.position(bbwi.position() + bytes);    	    n += bytes;    	}        //        // Skip past terminating null byte        //        if (bbwi.position() + 1 > bbwi.buflen)            alignAndCheck(1, 1);        bbwi.position(bbwi.position() + 1);    	return new String(c);    }    public final String read_string() {        return readStringOrIndirection(false);    }    public String read_wstring() {        // Don't allow transmission of wchar/wstring data with        // foreign ORBs since it's against the spec.        if (ORBUtility.isForeignORB((ORB)orb)) {	    throw wrapper.wcharDataInGiop10( CompletionStatus.COMPLETED_MAYBE);        }    	int len = read_long();    	//    	// Workaround for ORBs which send string lengths of    	// zero to mean empty string.    	//        //        // IMPORTANT: Do not replace 'new String("")' with "", it may result        // in a Serialization bug (See serialization.zerolengthstring) and        // bug id: 4728756 for details    	if (len == 0)    	    return new String("");        checkForNegativeLength(len);        len--;        char[] c = new char[len];        for (int i = 0; i < len; i++)            c[i] = read_wchar();        // skip the two null terminator bytes        read_wchar();        // bbwi.position(bbwi.position() + 2);        return new String(c);    }    public final void read_octet_array(byte[] b, int offset, int length) {    	if ( b == null )	    throw wrapper.nullParam() ;        // Must call alignAndCheck at least once to ensure        // we aren't at the end of a chunk.  Of course, we        // should only call it if we actually need to read        // something, otherwise we might end up with an        // exception at the end of the stream.        if (length == 0)            return;        alignAndCheck(1, 1);    	int n = offset;    	while (n < length+offset) {    	    int avail;    	    int bytes;    	    int wanted;    	    avail = bbwi.buflen - bbwi.position();            if (avail <= 0) {                grow(1, 1);                avail = bbwi.buflen - bbwi.position();            }    	    wanted = (length + offset) - n;    	    bytes = (wanted < avail) ? wanted : avail;            // Microbenchmarks are showing a loop of ByteBuffer.get(int) being            // faster than ByteBuffer.get(byte[], int, int).            for (int i = 0; i < bytes; i++) {                b[n+i] = bbwi.byteBuffer.get(bbwi.position() + i);            }    	    bbwi.position(bbwi.position() + bytes);    	    n += bytes;    	}    }    public Principal read_Principal() {    	int len = read_long();    	byte[] pvalue = new byte[len];    	read_octet_array(pvalue,0,len);    	Principal p = new PrincipalImpl();    	p.name(pvalue);	    	return p;    }    public TypeCode read_TypeCode() {        TypeCodeImpl tc = new TypeCodeImpl(orb);        tc.read_value(parent);	return tc;    }      public Any read_any() {        Any any = orb.create_any();        TypeCodeImpl tc = new TypeCodeImpl(orb);        // read off the typecode        // REVISIT We could avoid this try-catch if we could peek the typecode 	// kind off this stream and see if it is a tk_value.  Looking at the 	// code we know that for tk_value the Any.read_value() below        // ignores the tc argument anyway (except for the kind field).        // But still we would need to make sure that the whole typecode, 	// including encapsulations, is read off.        try {            tc.read_value(parent);        } catch (MARSHAL ex) {            if (tc.kind().value() != TCKind._tk_value)                throw ex;            // We can be sure that the whole typecode encapsulation has been 	    // read off.            dprintThrowable(ex);        }        // read off the value of the any        any.read_value(parent, tc);        return any;    }    public org.omg.CORBA.Object read_Object() {         return read_Object(null);    }    // ------------ RMI related methods --------------------------    // IDL to Java ptc-00-01-08 1.21.4.1    //    // The clz argument to read_Object can be either a stub    // Class or the "Class object for the RMI/IDL interface type     // that is statically expected."    // This functions as follows:    // 1. If clz==null, just use the repository ID from the stub    // 2. If clz is a stub class, just use it as a static factory.    //	  clz is a stub class iff StubAdapter.isStubClass( clz ).    //    In addition, clz is a IDL stub class iff     //    IDLEntity.class.isAssignableFrom( clz ).    // 3. If clz is an interface, use it to create the appropriate    //    stub factory.    public org.omg.CORBA.Object read_Object(Class clz)     {	// In any case, we must first read the IOR.	IOR ior = IORFactories.makeIOR(parent) ;	if (ior.isNil())	    return null ;	PresentationManager.StubFactoryFactory sff = ORB.getStubFactoryFactory() ;	String codeBase = ior.getProfile().getCodebase() ;	PresentationManager.StubFactory stubFactory = null ;        if (clz == null) {	    RepositoryId rid = RepositoryId.cache.getId( ior.getTypeId() ) ;	    String className = rid.getClassName() ;	    boolean isIDLInterface = rid.isIDLType() ;	    if (className == null || className.equals( "" ))		stubFactory = null ;	    else		try {		    stubFactory = sff.createStubFactory( className, 			isIDLInterface, codeBase, (Class)null, 			(ClassLoader)null );		} catch (Exception exc) {		    // Could not create stubFactory, so use null.		    // XXX stubFactory handling is still too complex:		    // Can we resolve the stubFactory question once in 		    // a single place?		    stubFactory = null ;		}

⌨️ 快捷键说明

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