📄 abstractcdrinput.java
字号:
} /** * Read the double value, IEEE 754 format. */ public double read_double() { try { align(8); return b.readDouble(); } catch (EOFException ex) { MARSHAL t = new MARSHAL(UNEXP_EOF); t.minor = Minor.EOF; t.initCause(ex); throw t; } catch (IOException ex) { throw new Unexpected(); } } /** * Read the array of double values, IEEE 754 format. */ public void read_double_array(double[] x, int offs, int len) { try { align(8); for (int i = offs; i < offs + len; i++) { x[i] = b.readDouble(); } } catch (EOFException ex) { MARSHAL t = new MARSHAL(UNEXP_EOF); t.minor = Minor.EOF; t.initCause(ex); throw t; } catch (IOException ex) { throw new Unexpected(ex); } } /** * Read the encapsulated stream. If the encapsulated sequence appears to be in * the Little endian format, the flag of the returned stream is set to read * Little endian. */ public BufferredCdrInput read_encapsulation() { try { int l = read_long(); byte[] r = new byte[l]; int n = 0; reading: while (n < r.length) { n += read(r, n, r.length - n); } BufferredCdrInput capsule = new BufferredCdrInput(r); capsule.setOrb(orb); int endian = capsule.read_octet(); if (endian != 0) { capsule.setBigEndian(false); } return capsule; } catch (EOFException ex) { MARSHAL t = new MARSHAL(UNEXP_EOF); t.minor = Minor.EOF; t.initCause(ex); throw t; } catch (IOException ex) { throw new Unexpected(ex); } } /** * Read the CORBA fixed (the end of the <code>fixed</code> can be determined * by its last byte). The scale is always assumed to be zero. */ public BigDecimal read_fixed() { try { return BigDecimalHelper.read(this, 0); } catch (EOFException ex) { MARSHAL t = new MARSHAL(UNEXP_EOF); t.minor = Minor.EOF; t.initCause(ex); throw t; } catch (IOException ex) { throw new Unexpected(ex); } } /** * Read the float value, IEEE 754 format. */ public float read_float() { try { align(4); return b.readFloat(); } catch (EOFException ex) { MARSHAL t = new MARSHAL(UNEXP_EOF); t.minor = Minor.EOF; t.initCause(ex); throw t; } catch (IOException ex) { throw new Unexpected(ex); } } /** * Read an array of float values, IEEE 754 format. */ public void read_float_array(float[] x, int offs, int len) { try { align(4); for (int i = offs; i < offs + len; i++) { x[i] = b.readFloat(); } } catch (EOFException ex) { MARSHAL t = new MARSHAL(UNEXP_EOF); t.minor = Minor.EOF; t.initCause(ex); throw t; } catch (IOException ex) { throw new Unexpected(ex); } } /** * Read the CORBA long (java int), high byte first. */ public int read_long() { try { align(4); return b.readInt(); } catch (EOFException ex) { MARSHAL t = new MARSHAL(UNEXP_EOF); t.minor = Minor.EOF; t.initCause(ex); throw t; } catch (IOException ex) { throw new Unexpected(ex); } } /** * Read an array of CORBA longs (java ints). */ public void read_long_array(int[] x, int offs, int len) { try { align(4); for (int i = offs; i < offs + len; i++) { x[i] = b.readInt(); } } catch (EOFException ex) { MARSHAL t = new MARSHAL(UNEXP_EOF); t.minor = Minor.EOF; t.initCause(ex); throw t; } catch (IOException ex) { throw new Unexpected(ex); } } /** * Read the CORBA long long (java long). */ public long read_longlong() { try { align(8); return b.readLong(); } catch (EOFException ex) { MARSHAL t = new MARSHAL(UNEXP_EOF); t.minor = Minor.EOF; throw t; } catch (IOException ex) { throw new Unexpected(ex); } } /** * Read an array of CORBA long longs (java longs). */ public void read_longlong_array(long[] x, int offs, int len) { try { align(8); for (int i = offs; i < offs + len; i++) { x[i] = b.readLong(); } } catch (EOFException ex) { MARSHAL t = new MARSHAL(UNEXP_EOF); t.minor = Minor.EOF; t.initCause(ex); throw t; } catch (IOException ex) { throw new Unexpected(ex); } } /** * Read a single byte. */ public byte read_octet() { try { return b.readByte(); } catch (EOFException ex) { MARSHAL t = new MARSHAL(UNEXP_EOF); t.minor = Minor.EOF; t.initCause(ex); throw t; } catch (IOException ex) { throw new Unexpected(ex); } } /** * Read the byte array. */ public void read_octet_array(byte[] x, int offs, int len) { try { b.read(x, offs, len); } catch (EOFException ex) { MARSHAL t = new MARSHAL(UNEXP_EOF); t.minor = Minor.EOF; t.initCause(ex); throw t; } catch (IOException ex) { throw new Unexpected(ex); } } /** * Read the length of the byte array as CORBA long and then the array itseld. */ public byte[] read_sequence() { try { int l = read_long(); byte[] buf = new byte[l]; if (l > 0) { b.readFully(buf); } return buf; } catch (EOFException ex) { MARSHAL t = new MARSHAL(UNEXP_EOF); t.minor = Minor.EOF; t.initCause(ex); throw t; } catch (IOException ex) { throw new Unexpected(ex); } } /** * Read the CORBA short integer. */ public short read_short() { try { align(2); return b.readShort(); } catch (EOFException ex) { MARSHAL t = new MARSHAL(UNEXP_EOF); t.minor = Minor.EOF; t.initCause(ex); throw t; } catch (IOException ex) { throw new Unexpected(ex); } } /** * Read the array of CORBA short integer values. */ public void read_short_array(short[] x, int offs, int len) { try { align(2); for (int i = offs; i < offs + len; i++) { x[i] = b.readShort(); } } catch (EOFException ex) { MARSHAL t = new MARSHAL(UNEXP_EOF); t.minor = Minor.EOF; t.initCause(ex); throw t; } catch (IOException ex) { throw new Unexpected(ex); } } /** * Read a singe byte string. The method firs reads the byte array and then * calls a constructor to create a string from this array. The character * encoding, if previously set, is taken into consideration. * * @return a loaded string. */ public String read_string() { int n = 0; try { align(4); n = b.readInt(); byte[] s = new byte[n]; b.read(s); // Discard the null terminator. if (narrow_charset == null) return new String(s, 0, n - 1); else return new String(s, 0, n - 1, narrow_charset); } catch (EOFException ex) { MARSHAL t = new MARSHAL(UNEXP_EOF); t.minor = Minor.EOF; t.initCause(ex); throw t; } catch (IOException ex) { throw new Unexpected(); } catch (NegativeArraySizeException nex) { MARSHAL m = new MARSHAL("Input stream broken, got " + n + "(0x" + Integer.toHexString(n) + ") as a string size"); m.minor = Minor.Negative; throw m; } } /** * Reads the CORBA unsigned long (java int), delegating functionality to * {@link #read_long}. */ public int read_ulong() { return read_long(); } /** * Reads the array of CORBA unsigned long (java integer) values, delegating * functionality to {@link #real_long_array}. */ public void read_ulong_array(int[] x, int offs, int len) { read_long_array(x, offs, len); } /** * Read the CORBA unsigned long long value, delegating functionality to * {@link #read_longlong}. There is no way to return values over the limit of * the java signed long in other way than returning the negative value. */ public long read_ulonglong() { return read_longlong(); } /** * Reads the array of CORBA long long (java long) values, delegating * functionality to {@link #real_longlong_array}. */ public void read_ulonglong_array(long[] x, int offs, int len) { read_longlong_array(x, offs, len); } /** * Read the unsigned short integer value. Due strange specification, the * returned value must be the short type as well, so the the best solution * seems just to delegete functionality to read_short. */ public short read_ushort() { return read_short(); } /** * Read an array of unsigned short values, delegating the functionality to * {@link read_short_array}. */ public void read_ushort_array(short[] x, int offs, int len) { read_short_array(x, offs, len); } /** * Reads the wide character using the encoding, specified in the wide_charset. */ public char read_wchar() { try { if (giop.until_inclusive(1, 1)) { align(2); if (wide_native) return (char) b.readShort(); else return (char) new InputStreamReader((InputStream) b, wide_charset).read(); } else { int l = b.read(); if (l == 2 && wide_native) return b.readChar(); else if (l <= 0) { MARSHAL m = new MARSHAL("wchar size " + l); m.minor = Minor.Negative; throw m; } else { byte[] bytes = new byte[l]; b.readFully(bytes); String cs; if (bytes.length > 2 && bytes[0] == 0xFE && bytes[1] == 0xFF) cs = new String(bytes, 2, bytes.length - 2, wide_charset); else if (bytes.length > 2 && bytes[0] == 0xFF && bytes[1] == 0xFE) { // Litle endian detected - swap bytes. byte t; for (int i = 3; i < bytes.length; i = i + 2) { t = bytes[i]; bytes[i - 1] = bytes[i]; bytes[i] = t; } cs = new String(bytes, 2, bytes.length - 2, wide_charset); } else cs = new String(bytes, wide_charset); return cs.charAt(0); } } } catch (EOFException ex) { MARSHAL t = new MARSHAL(UNEXP_EOF); t.minor = Minor.EOF; t.initCause(ex); throw t; } catch (IOException ex) { throw new Unexpected(); } } /** * Read an array of "wide chars", each representing a two byte Unicode * character, high byte first. */ public void read_wchar_array(char[] x, int offset, int length) { try { if (giop.until_inclusive(1, 1)) align(2); if (wide_native) { for (int i = offset; i < offset + length; i++) x[i] = (char) b.readShort(); } else { InputStreamReader reader = new InputStreamReader((InputStream) b, wide_charset); reader.read(x, offset, length); } }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -