cdrinputstream_1_0.java
来自「JAVA 所有包」· Java 代码 · 共 1,977 行 · 第 1/5 页
JAVA
1,977 行
// recursively to read any further chunks that the containing // valuetype might still have after the nested // value. read_value(); handleEndOfValue(); } else { // This probably means that the code to skip chunks has // an error, and ended up setting blockLength to something // other than maxBlockLength even though we weren't // starting a new chunk. throw wrapper.couldNotSkipBytes( CompletionStatus.COMPLETED_MAYBE, new Integer( nextLong ), new Integer( get_offset() ) ) ; } } private void end_block() { // if in a chunk, check for underflow or overflow if (blockLength != maxBlockLength) { if (blockLength == get_offset()) { // Chunk ended correctly blockLength = maxBlockLength; } else { // Skip over anything left by bad unmarshaling code (ex: // a buggy custom unmarshaler). See handleEndOfValue. if (blockLength > get_offset()) { skipToOffset(blockLength); } else { throw wrapper.badChunkLength( new Integer( blockLength ), new Integer( get_offset() ) ) ; } } } } private int readValueTag(){ // outerValueDone = false; return read_long(); } public org.omg.CORBA.ORB orb() { return orb; } // ------------ End RMI related methods -------------------------- public final void read_boolean_array(boolean[] value, int offset, int length) { for(int i=0; i < length; i++) { value[i+offset] = read_boolean(); } } public final void read_char_array(char[] value, int offset, int length) { for(int i=0; i < length; i++) { value[i+offset] = read_char(); } } public final void read_wchar_array(char[] value, int offset, int length) { for(int i=0; i < length; i++) { value[i+offset] = read_wchar(); } } public final void read_short_array(short[] value, int offset, int length) { for(int i=0; i < length; i++) { value[i+offset] = read_short(); } } public final void read_ushort_array(short[] value, int offset, int length) { read_short_array(value, offset, length); } public final void read_long_array(int[] value, int offset, int length) { for(int i=0; i < length; i++) { value[i+offset] = read_long(); } } public final void read_ulong_array(int[] value, int offset, int length) { read_long_array(value, offset, length); } public final void read_longlong_array(long[] value, int offset, int length) { for(int i=0; i < length; i++) { value[i+offset] = read_longlong(); } } public final void read_ulonglong_array(long[] value, int offset, int length) { read_longlong_array(value, offset, length); } public final void read_float_array(float[] value, int offset, int length) { for(int i=0; i < length; i++) { value[i+offset] = read_float(); } } public final void read_double_array(double[] value, int offset, int length) { for(int i=0; i < length; i++) { value[i+offset] = read_double(); } } public final void read_any_array(org.omg.CORBA.Any[] value, int offset, int length) { for(int i=0; i < length; i++) { value[i+offset] = read_any(); } } //--------------------------------------------------------------------// // CDRInputStream state management. // /** * Are we at the end of the input stream? */// public final boolean isAtEnd() {// return bbwi.position() == bbwi.buflen;// }// public int available() throws IOException {// return bbwi.buflen - bbwi.position();// } private String read_repositoryIds() { // Read # of repository ids int numRepIds = read_long(); if (numRepIds == 0xffffffff) { int indirection = read_long() + get_offset() - 4; if (repositoryIdCache != null && repositoryIdCache.containsOrderedVal(indirection)) return (String)repositoryIdCache.getKey(indirection); else throw wrapper.unableToLocateRepIdArray( new Integer( indirection ) ) ; } else { // read first array element and store it as an indirection to the whole array int indirection = get_offset(); String repID = read_repositoryId(); if (repositoryIdCache == null) repositoryIdCache = new CacheTable(orb,false); repositoryIdCache.put(repID, indirection); // read and ignore the subsequent array elements, but put them in the // indirection table in case there are later indirections back to them for (int i = 1; i < numRepIds; i++) { read_repositoryId(); } return repID; } } private final String read_repositoryId() { String result = readStringOrIndirection(true); if (result == null) { // Indirection int indirection = read_long() + get_offset() - 4; if (repositoryIdCache != null && repositoryIdCache.containsOrderedVal(indirection)) return (String)repositoryIdCache.getKey(indirection); else throw wrapper.badRepIdIndirection( CompletionStatus.COMPLETED_MAYBE, new Integer(bbwi.position()) ) ; } else { if (repositoryIdCache == null) repositoryIdCache = new CacheTable(orb,false); repositoryIdCache.put(result, stringIndirection); } return result ; } private final String read_codebase_URL() { String result = readStringOrIndirection(true); if (result == null) { // Indirection int indirection = read_long() + get_offset() - 4; if (codebaseCache != null && codebaseCache.containsVal(indirection)) return (String)codebaseCache.getKey(indirection); else throw wrapper.badCodebaseIndirection( CompletionStatus.COMPLETED_MAYBE, new Integer(bbwi.position()) ) ; } else { if (codebaseCache == null) codebaseCache = new CacheTable(orb,false); codebaseCache.put(result, stringIndirection); } return result; } /* DataInputStream methods */ public java.lang.Object read_Abstract () { return read_abstract_interface(); } public java.io.Serializable read_Value () { return read_value(); } public void read_any_array (org.omg.CORBA.AnySeqHolder seq, int offset, int length) { read_any_array(seq.value, offset, length); } public void read_boolean_array (org.omg.CORBA.BooleanSeqHolder seq, int offset, int length) { read_boolean_array(seq.value, offset, length); } public void read_char_array (org.omg.CORBA.CharSeqHolder seq, int offset, int length) { read_char_array(seq.value, offset, length); } public void read_wchar_array (org.omg.CORBA.WCharSeqHolder seq, int offset, int length) { read_wchar_array(seq.value, offset, length); } public void read_octet_array (org.omg.CORBA.OctetSeqHolder seq, int offset, int length) { read_octet_array(seq.value, offset, length); } public void read_short_array (org.omg.CORBA.ShortSeqHolder seq, int offset, int length) { read_short_array(seq.value, offset, length); } public void read_ushort_array (org.omg.CORBA.UShortSeqHolder seq, int offset, int length) { read_ushort_array(seq.value, offset, length); } public void read_long_array (org.omg.CORBA.LongSeqHolder seq, int offset, int length) { read_long_array(seq.value, offset, length); } public void read_ulong_array (org.omg.CORBA.ULongSeqHolder seq, int offset, int length) { read_ulong_array(seq.value, offset, length); } public void read_ulonglong_array (org.omg.CORBA.ULongLongSeqHolder seq, int offset, int length) { read_ulonglong_array(seq.value, offset, length); } public void read_longlong_array (org.omg.CORBA.LongLongSeqHolder seq, int offset, int length) { read_longlong_array(seq.value, offset, length); } public void read_float_array (org.omg.CORBA.FloatSeqHolder seq, int offset, int length) { read_float_array(seq.value, offset, length); } public void read_double_array (org.omg.CORBA.DoubleSeqHolder seq, int offset, int length) { read_double_array(seq.value, offset, length); } public java.math.BigDecimal read_fixed(short digits, short scale) { // digits isn't really needed here StringBuffer buffer = read_fixed_buffer(); if (digits != buffer.length()) throw wrapper.badFixed( new Integer(digits), new Integer(buffer.length()) ) ; buffer.insert(digits - scale, '.'); return new BigDecimal(buffer.toString()); } // This method is unable to yield the correct scale. public java.math.BigDecimal read_fixed() { return new BigDecimal(read_fixed_buffer().toString()); } // Each octet contains (up to) two decimal digits. // If the fixed type has an odd number of decimal digits, then the representation // begins with the first (most significant) digit. // Otherwise, this first half-octet is all zero, and the first digit // is in the second half-octet. // The sign configuration, in the last half-octet of the representation, // is 0xD for negative numbers and 0xC for positive and zero values. private StringBuffer read_fixed_buffer() { StringBuffer buffer = new StringBuffer(64); byte doubleDigit; int firstDigit; int secondDigit; boolean wroteFirstDigit = false; boolean more = true; while (more) { doubleDigit = this.read_octet(); firstDigit = (int)((doubleDigit & 0xf0) >> 4); secondDigit = (int)(doubleDigit & 0x0f); if (wroteFirstDigit || firstDigit != 0) { buffer.append(Character.forDigit(firstDigit, 10)); wroteFirstDigit = true; } if (secondDigit == 12) { // positive number or zero if ( ! wroteFirstDigit) { // zero return new StringBuffer("0.0"); } else { // positive number // done } more = false; } else if (secondDigit == 13) { // negative number buffer.insert(0, '-'); more = false; } else { buffer.append(Character.forDigit(secondDigit, 10)); wroteFirstDigit = true; } } return buffer; } private final static String _id = "IDL:omg.org/CORBA/DataInputStream:1.0"; private final static String[] _ids = { _id }; public String[] _truncatable_ids() { if (_ids == null) return null; return (String[])_ids.clone(); } /* for debugging */ public void printBuffer() { CDRInputStream_1_0.printBuffer(this.bbwi); } public static void printBuffer(ByteBufferWithInfo bbwi) { System.out.println("----- Input Buffer -----"); System.out.println(); System.out.println("Current position: " + bbwi.position()); System.out.println("Total length : " + bbwi.buflen); System.out.println(); try { char[] charBuf = new char[16]; for (int i = 0; i < bbwi.buflen; i += 16) { int j = 0; // For every 16 bytes, there is one line // of output. First, the hex output of // the 16 bytes with each byte separated // by a space. while (j < 16 && j + i < bbwi.buflen) { int k = bbwi.byteBuffer.get(i + j); if (k < 0) k = 256 + k; String hex = Integer.toHexString(k); if (hex.length() == 1) hex = "0" + hex; System.out.print(hex + " "); j++; } // Add any extra spaces to align the // text column in case we didn't end // at 16 while (j < 16) { System.out.print(" "); j++; } // Now output the ASCII equivalents. Non-ASCII // characters are shown as periods. int x = 0; while (x < 16 && x + i < bbwi.buflen) { if (ORBUtility.isPrintable((char)bbwi.byteBuffer.get(i + x))) charBuf[x] = (char)bbwi.byteBuffer.get(i + x); else charBuf[x] = '.'; x++; } System.out.println(new String(charBuf, 0, x)); } } catch (Throwable t) { t.printStackTrace(); } System.out.println("---
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?