📄 abstractcdrinput.java
字号:
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); } } /** * Reads the string in wide character format (ussually UTF-16, Unicode). Takes * the currently set charset into consideration. * * If the native (UTF-16) encoding is used of the GIOP protocol is before 1.2, * delegates functionality to "plain" {@link #read_wstring_UTF_16}. */ public String read_wstring() { // Native encoding or word oriented data. if (wide_native || giop.until_inclusive(1, 1)) return read_wstring_UTF_16(); try { align(4); int n = b.readInt(); byte[] s = new byte[n]; b.read(s); return new String(s, 0, n, wide_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(ex); } } /** * Reads first length of the string and the all characters as an Unicode * (UTF-16) characters. Mind that GIOP 1.1 has the extra null character at the * end that must be discarded. */ public String read_wstring_UTF_16() { try { int p = 0; int n = read_long(); if (n<0) { MARSHAL m = new MARSHAL("Negative string size"); m.minor = Minor.Negative; throw m; } // The null terminator that is no longer present since 1.2 . int nt = giop.since_inclusive(1, 2) ? 0 : 1; // Convert bytes to shorts. n = n / 2; // Empty string. if (n == 0) return ""; char[] s = new char[n]; for (int i = 0; i < s.length; i++) s[i] = (char) b.readShort(); // Check for the byte order marker here. if (s[0] == 0xFEFF) { // Big endian encoding - do nothing, but move the pointer // one position forward. p = 1; } else if (s[0] == 0xFFFE) { // Little endian encoding, swap the bytes and move one // position forward. p = 1; for (int i = p; i < s.length; i++) s[i] = swap(s[i]); } // Discard the null terminator and, if needed, the endian marker. String r = new String(s, p, n - nt - p); return r; } 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); } } /** * Swap bytes in the character. */ public static char swap(char x) { int hi; int lo; lo = x & 0xFF; hi = (x >> 8) & 0xFF; return (char) ((lo << 8) | hi); } /** * Set the current code set context. */ public void setCodeSet(CodeSetServiceContext a_codeset) { this.codeset = a_codeset; narrow_charset = CharSets_OSF.getName(codeset.char_data); wide_charset = CharSets_OSF.getName(codeset.wide_char_data); narrow_native = CharSets_OSF.NATIVE_CHARACTER == codeset.char_data; wide_native = CharSets_OSF.NATIVE_WIDE_CHARACTER == codeset.wide_char_data; } /** * Get the current code set context. */ public CodeSetServiceContext getCodeSet() { return codeset; } /** * Read the object that is an instance of the given class. The current * implementation delegates functionality to the parameterless * {@link readObject()}. * * @param klass a class of that this object the instance is. * * @return the returned object. */ public org.omg.CORBA.Object read_Object(Class klass) { return read_Object(); } /** * Read a value type structure from the stream. * * OMG specification states the writing format is outside the scope of GIOP * definition. This implementation uses java serialization mechanism, calling * {@link ObjectInputStream#readObject} * * @return an value type structure, unmarshaled from the stream */ public Serializable read_Value() { return read_value(); } /** * Read the abstract interface. An abstract interface can be either CORBA * value type or CORBA object and is returned as an abstract java.lang.Object. * * As specified in OMG specification, this reads a single boolean and then * delegates either to {@link #read_Object()} (for false) or to * {@link #read_Value()} (for true). * * @return an abstract interface, unmarshaled from the stream */ public java.lang.Object read_Abstract() { return read_abstract_interface(); } /** * Read an array. In OMG specification is written that if the data does not * fit into the holder value field, that array must be resized. The * implementation follows this rule. If the holder value field contains null, * it is newly instantiated. */ public void read_char_array(CharSeqHolder holder, int offset, int length) { holder.value = ensureArray(holder.value, offset, length); read_char_array(holder.value, offset, length); } /** * Read an array. In OMG specification is written that if the data does not * fit into the holder value field, that array must be resized. The * implementation follows this rule. If the holder value field contains null, * it is newly instantiated. */ public void read_wchar_array(WCharSeqHolder holder, int offset, int length) { holder.value = ensureArray(holder.value, offset, length); read_wchar_array(holder.value, offset, length); } /** * If required, allocate or resize the char array to fit the newly read * values. * * @param holder_value the existing char array, may be null. * @param offset the required offset to read. * @param length the length of the new sequence. * * @return the allocated or resized array, same array if no such operations * are required. */ private char[] ensureArray(char[] holder_value, int offset, int length) { if (holder_value == null) return new char[offset + length]; else if (holder_value.length < offset + length) { char[] value = new char[offset + length]; System.arraycopy(holder_value, 0, value, 0, holder_value.length); return value; } else return holder_value; } /** * Read an array. In OMG specification is written that if the data does not * fit into the holder value field, that array must be resized. The * implementation follows this rule. If the holder value field contains null, * it is newly instantiated. */ public void read_ulong_array(ULongSeqHolder holder, int offset, int length) { holder.value = ensureArray(holder.value, offset, length); read_ulong_array(holder.value, offset, length); } /** * Read an array. In OMG specification is written that if the data does not * fit into the holder value field, that array must be resized. The * implementation follows this rule. If the holder value field contains null, * it is newly instantiated. */ public void read_long_array(LongSeqHolder holder, int offset, int length) { holder.value = ensureArray(holder.value, offset, length); read_ulong_array(holder.value, offset, length); } /** * If required, allocate or resize the int array to fit the newly read values. * * @param holder_value the existing int array, may be null. * @param offset the required offset to read. * @param length the length of the new sequence. * * @return the allocated or resized array, same array if no such operations * are required. */ private int[] ensureArray(int[] holder_value, int offset, int length) { if (holder_value == null) return new int[offset + length]; else if (holder_value.length < offset + length) { int[] value = new int[offset + length]; System.arraycopy(holder_value, 0, value, 0, holder_value.length); return value; } else return holder_value; } /** * Read an array. In OMG specification is written that if the data does not * fit into the holder value field, that array must be resized. The * implementation follows this rule. If the holder value field contains null, * it is newly instantiated. */ public void read_float_array(FloatSeqHolder holder, int offset, int length) { holder.value = ensureArray(holder.value, offset, length); read_float_array(holder.value, offset, length); } /** * If required, allocate or resize the float array to fit the newly read * values. * * @param holder_value the existing float array, may be null. * @param offset the required offset to read. * @param length the length of the new sequence. * * @return the allocated or resized array, same array if no such operations * are required. */ private float[] ensureArray(float[] holder_value, int offset, int length) { if (holder_value == null) return new float[offset + length]; else if (holder_value.length < offset + length) { float[] value = new float[offset + length]; System.arraycopy(holder_value, 0, value, 0, holder_value.length); return value; } else return holder_value; } /** * Read an array. In OMG specification is written that if the data does not * fit into the holder value field, that array must be resized. The * implementation follows this rule. If the holder value field contains null, * it is newly instantiated. */ public void read_double_array(DoubleSeqHolder holder, int offset, int length) { holder.value = ensureArray(holder.value, offset, length); read_double_array(holder.value, offset, length); } /** * If required, allocate or resize the double array to fit the newly read * values. * * @param holder_value the existing double array, may be null. * @param offset the required offset to read. * @param length the length of the new sequence. * * @return the allocated or resized array, same array if no such operations * are required. */ private double[] ensureArray(double[] holder_value, int offset, int length) { if (holder_value == null) return new double[offset + length]; else if (holder_value.length < offset + length) { double[] value = new double[offset + length]; System.arraycopy(holder_value, 0, value, 0, holder_value.length); return value; } else return holder_value; } /** * Read an array. In OMG specification is written that if the data does not * fit into the holder value field, that array must be resized. The * implementation follows this rule. If the holder value field contains null, * it is newly instantiated. */ public void read_short_array(ShortSeqHolder holder, int offset, int length) { holder.value = ensureArray(holder.value, offset, length); read_short_array(holder.value, offset, length); } /** {@inheritDoc} */ public void read_ushort_array(UShortSeqHolder holder, int offset, int length) { holder.value = ensureArray(holder.value, offset, length); read_ushort_array(holder.value, offset, length); } /** * If required, allocate or resize the short array to fit the newly read * values. * * @param holder_value the existing short array, may be null. * @param offset the required offset to read. * @param length the length of the new sequence. * * @return the allocated or resized array, same array if no such operations * are required. */ private short[] ensureArray(short[] holder_value, int offset, int length) { if (holder_value == null) return new short[offset + length]; else if (holder_value.length < offset + length) { short[] value = new short[offset + length]; System.arraycopy(holder_value, 0, value, 0, holder_value.length); return value; } else return holder_value; } /** * Read an array. In OMG specification is written that if the data does not * fit into the holder value field, that array must be resized. The * implementation follows this rule. If the holder value field contains null, * it is newly instantiated. */ public void read_octet_array(OctetSeqHolder holder, int offset, int length) { holder.value = ensureArray(holder.value, offset, length); read_octet_array(holder.value, offset, length); } /** * If required, allocate or resize the byte array to fit the newly read * values. * * @param holder_value the existing byte array, may be null. * @param offset the required offset to read. * @param length the length of the new sequence. * * @return the allocated or resized array, same array if no such operations * are required. */ private byte[] ensureArray(byte[] holder_value, int offset, int length) { if (holder_value == null) return new byte[offset + length]; else if (holder_value.length < offset + length) { byte[] value = new byte[offset + length]; System.arraycopy(holder_value, 0, value, 0, holder_value.length); return value; } else return holder_value; } /** * Read an array. In OMG specification is written that if the data does not * fit into the holder value field, that array must be resized. The * implementation follows this rule. If the holder value field contains null, * it is newly instantiated. */ public void read_longlong_array(LongLongSeqHolder holder, int offset, int length) { holder.value = ensureArray(holder.value, offset, length); read_longlong_array(holder.value, offset, length); } /** * Read an array. In OMG specification is written that if the data does not * fit into the holder value field, that array must be resized. The * implementation follows this rule. If the holder value field contains null, * it is newly instantiated. */ public void read_ulonglong_array(ULongLongSeqHolder holder, int offset, int length) { holder.value = ensureArray(holder.value, offset, length); read_ulonglong_array(holder.value, offset, length); } /** * If required, allocate or resize the array of longs to fit the newly read * values. * * @param holder_value the existing array, may be null. * @param offset the required offset to read. * @param length the length of the new sequence. * * @return the allocated or resized array, same array if no such operations * are required. */ private long[] ensureArray(long[] holder_value, int offset, int length) { if (holder_value == null) return new long[offset + length]; else if (holder_value.length < offset + length) { long[] value = new long[offset + length]; System.arraycopy(holder_value, 0, value, 0, holder_value.length); return value; } else return holder_value; } /** * Read an array. In OMG specification is written that if the data does not * fit into the holder value field, that array must be resized. The * implementation follows this rule. If the holder value field contains null, * it is newly instantiated. */ public void read_boolean_array(BooleanSeqHolder holder, int offset, int length) { holder.value = ensureArray(holder.value, offset, length); read_boolean_array(holder.value, offset, length); } /** * If required, allocate or resize the array of booleans to fit the newly read * values. * * @param holder_value the existing array of booleans, may be null. * @param offset the required offset to read. * @param length the length of the new sequence. * * @return the allocated or resized array, same array if no such operations * are required. */ private boolean[] ensureArray(boolean[] holder_value, int offset, int length) { if (holder_value == null) return new boolean[offset + length]; else if (holder_value.length < offset + length) { boolean[] value = new boolean[offset + length]; System.arraycopy(holder_value, 0, value, 0, holder_value.length); return value; } else return holder_value; } /** * Read an array. In OMG specification is written that if the data does not * fit into the holder value field, that array must be resized. The * implementation follows this rule. If the holder value field contains null, * it is newly instantiated. */ public void read_any_array(AnySeqHolder holder, int offset, int length) { holder.value = ensureArray(holder.value, offset, length); for (int i = offset; i < offset + length; i++) { holder.value[i] = read_any(); } } /** * If required, allocate or resize the array of Anys to fit the newly read * values. * * @param holder_value the existing array of Anys, may be null. * @param offset the required offset to read. * @param length the length of the new sequence. * * @return the allocated or resized array, same array if no such operations * are required. */ private Any[] ensureArray(Any[] holder_value, int offset, int length) { if (holder_value == null) return new Any[offset + length]; else if (holder_value.length < offset + length) { Any[] value = new Any[offset + length]; System.arraycopy(holder_value, 0, value, 0, holder_value.length); return value; } else return holder_value; } /** * This method is required to represent the DataInputStream as a value type * object. * * @return a single entity "IDL:omg.org/CORBA/DataInputStream:1.0", always. */ public String[] _truncatable_ids() { return new String[] { "IDL:omg.org/CORBA/DataInputStream:1.0" }; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -