1 /* AbstractCdrInput.java --
2 Copyright (C) 2005 Free Software Foundation, Inc.
4 This file is part of GNU Classpath.
6 GNU Classpath is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
11 GNU Classpath is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GNU Classpath; see the file COPYING. If not, write to the
18 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21 Linking this library statically or dynamically with other modules is
22 making a combined work based on this library. Thus, the terms and
23 conditions of the GNU General Public License cover the whole
26 As a special exception, the copyright holders of this library give you
27 permission to link this library with independent modules to produce an
28 executable, regardless of the license terms of these independent
29 modules, and to copy and distribute the resulting executable under
30 terms of your choice, provided that you also meet, for each linked
31 independent module, the terms and conditions of the license of that
32 module. An independent module is a module which is not derived from
33 or based on this library. If you modify this library, you may extend
34 this exception to your version of the library, but you are not
35 obligated to do so. If you do not wish to do so, delete this
36 exception statement from your version. */
39 package gnu.CORBA.CDR;
41 import gnu.CORBA.BigDecimalHelper;
42 import gnu.CORBA.OrbFunctional;
43 import gnu.CORBA.GIOP.CharSets_OSF;
44 import gnu.CORBA.GIOP.CodeSetServiceContext;
46 import gnu.CORBA.IorDelegate;
47 import gnu.CORBA.Minor;
48 import gnu.CORBA.TypeCodeHelper;
49 import gnu.CORBA.Unexpected;
50 import gnu.CORBA.Version;
51 import gnu.CORBA.gnuAny;
52 import gnu.CORBA.StubLocator;
54 import org.omg.CORBA.Any;
55 import org.omg.CORBA.AnySeqHolder;
56 import org.omg.CORBA.BAD_OPERATION;
57 import org.omg.CORBA.BooleanSeqHolder;
58 import org.omg.CORBA.CharSeqHolder;
59 import org.omg.CORBA.DoubleSeqHolder;
60 import org.omg.CORBA.FloatSeqHolder;
61 import org.omg.CORBA.LongLongSeqHolder;
62 import org.omg.CORBA.LongSeqHolder;
63 import org.omg.CORBA.MARSHAL;
64 import org.omg.CORBA.ORB;
65 import org.omg.CORBA.OctetSeqHolder;
66 import org.omg.CORBA.ShortSeqHolder;
67 import org.omg.CORBA.TypeCode;
68 import org.omg.CORBA.TypeCodePackage.BadKind;
69 import org.omg.CORBA.TypeCodePackage.Bounds;
70 import org.omg.CORBA.ULongLongSeqHolder;
71 import org.omg.CORBA.ULongSeqHolder;
72 import org.omg.CORBA.UShortSeqHolder;
73 import org.omg.CORBA.WCharSeqHolder;
74 import org.omg.CORBA.portable.InputStream;
75 import org.omg.CORBA.portable.ObjectImpl;
77 import java.io.EOFException;
78 import java.io.IOException;
79 import java.io.InputStreamReader;
80 import java.io.Serializable;
82 import java.math.BigDecimal;
85 * A simple CORBA CDR (common data representation) input stream, reading data
86 * from the given {@link java.io.InputStream}. The primitive types are aligned
87 * on they natural boundaries by implementing the abstract method
88 * {@link #align(int boundary)}.
90 * The same class also implements {@link org.omg.CORBA.DataInputStream} to read
91 * the object content in a user defined way.
93 * TODO This class uses 16 bits per Unicode character only, as it was until jdk
96 * @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
98 public abstract class AbstractCdrInput
99 extends org.omg.CORBA_2_3.portable.InputStream
100 implements org.omg.CORBA.DataInputStream
103 * The runtime, associated with this stream. This field is only used when
104 * reading and writing value types and filled-in in gnu.CORBA.CDR.Vio.
106 public transient gnuRuntime runtime;
109 * The message, explaining that the exception has been thrown due unexpected
110 * end of the input stream. This usually happens the server and client
111 * disagree on communication or data representation rules.
113 protected static final String UNEXP_EOF = "Unexpected end of stream";
116 * This instance is used to convert primitive data types into the byte
119 protected AbstractDataInput b;
122 * The input stream, from where the data are actually being read.
124 protected java.io.InputStream actual_stream;
127 * The associated orb, if any.
134 protected Version giop = new Version(1, 2);
137 * The code set information.
139 protected CodeSetServiceContext codeset = CodeSetServiceContext.STANDARD;
142 * The name of the currently used narrow charset, null if the native narrow
145 private String narrow_charset = null;
148 * The name of the currently used wide charset, null if the native wide
151 private String wide_charset = null;
154 * True if the native code set is used for narrow characters. If the set is
155 * native, no the intermediate Reader object is instantiated when writing
158 private boolean narrow_native;
161 * True if the native code set is used for wide characters. If the set is
162 * native, no the intermediate Reader object is instantiated when writing
165 private boolean wide_native;
168 * If true, the stream expect the multi-byte data in the form "less
169 * significant byte first" (Little Endian). This is the opposite to the java
170 * standard (Big Endian).
172 private boolean little_endian;
175 * Creates the stream. The stream reads Big Endian by default.
177 * @param readFrom a stream to read CORBA input from.
179 public AbstractCdrInput(java.io.InputStream readFrom)
181 setInputStream(readFrom);
182 setCodeSet(CodeSetServiceContext.STANDARD);
186 * Creates the stream, requiring the subsequent call of
187 * {@link #setInputStream(java.io.InputStream)}.
189 public AbstractCdrInput()
191 setCodeSet(CodeSetServiceContext.STANDARD);
195 * Set the Big Endian or Little Endian encoding. The stream reads Big Endian
198 * @param use_big_endian if true, the stream expect the multi-byte data in
199 * the form "most significant byte first" (Big Endian). This is the
202 public void setBigEndian(boolean use_big_endian)
204 little_endian = !use_big_endian;
205 setInputStream(actual_stream);
209 * Get the used encoding.
211 * @return true for Big Endian, false for Little Endian.
213 public boolean isBigEndian()
215 return !little_endian;
219 * Clone all important settings to another stream.
221 public void cloneSettings(AbstractCdrInput stream)
223 stream.setBigEndian(isBigEndian());
224 stream.setCodeSet(getCodeSet());
225 stream.setVersion(giop);
230 * Set the input stream that receives the CORBA input.
232 * @param readFrom the stream.
234 public void setInputStream(java.io.InputStream readFrom)
237 b = new LittleEndianInputStream(readFrom);
239 b = new BigEndianInputStream(readFrom);
241 actual_stream = readFrom;
245 * Set the alignment offset, if the index of the first byte in the stream is
248 public abstract void setOffset(int offset);
251 * Set the orb, associated with this stream.
255 public void setOrb(ORB an_orb)
261 * Set the GIOP version. Some data types are written differently for the
262 * different versions. The default version is 1.0 .
264 public void setVersion(Version giop_version)
270 * Align the curretn position at the given natural boundary.
272 public abstract void align(int boundary);
275 * Reads the CORBA unsigned long (java int), returning the value in the
276 * sufficiently large java long.
278 public long gnu_read_ulong()
282 long l = b.readInt();
286 catch (EOFException ex)
288 MARSHAL t = new MARSHAL(UNEXP_EOF);
293 catch (IOException ex)
295 throw new Unexpected(ex);
300 * Read the unsigned short integer value and return it as java int,
301 * sufficiently large to hold all values.
303 public int gnu_read_ushort()
308 return b.readUnsignedShort();
310 catch (EOFException ex)
312 MARSHAL t = new MARSHAL(UNEXP_EOF);
318 catch (IOException ex)
320 throw new Unexpected(ex);
325 * Return the associated {@link ORB}.
327 * @return the associated {@link ORB} or null is no such is set.
335 * Read a single byte directly from the buffer.
338 throws java.io.IOException
344 catch (EOFException ex)
346 MARSHAL t = new MARSHAL(UNEXP_EOF);
354 * Read bytes directly from the buffer.
356 public int read(byte[] x, int ofs, int len)
357 throws java.io.IOException
361 return b.read(x, ofs, len);
363 catch (EOFException ex)
365 MARSHAL t = new MARSHAL(UNEXP_EOF);
373 * Read bytes directly from the buffer.
375 public int read(byte[] x)
376 throws java.io.IOException
382 catch (EOFException ex)
384 MARSHAL t = new MARSHAL(UNEXP_EOF);
392 * Read the CORBA object. The object to read is represented in the form of the
393 * plain (not a string-encoded) IOR profile without the heading endian
394 * indicator. The responsible method for reading such data is
395 * {@link IOR.read_no_endian}.
397 * The returned object is usually casted into the given type using the .narrow
398 * method of its helper, despite in some cases the direct cast would also
401 * The null objects are recognised from the empty profile set. For such
402 * objects, null is returned.
404 * @return the loaded and constructed object.
406 public org.omg.CORBA.Object read_Object()
411 ior._read_no_endian(this);
416 // Check maybe this is a remote reference to the local object.
417 // This is only possible if we access the repository of the
419 if (orb instanceof OrbFunctional)
421 OrbFunctional forb = (OrbFunctional) orb;
422 org.omg.CORBA.Object local = forb.find_local_object(ior);
427 // Search for the available stubs.
428 ObjectImpl impl = StubLocator.search(orb, ior);
431 if (impl._get_delegate() == null)
432 impl._set_delegate(new IorDelegate(orb, ior));
434 catch (BAD_OPERATION ex)
436 // Some colaborants may throw this exception
437 // in response to the attempt to get the unset delegate.
438 impl._set_delegate(new IorDelegate(orb, ior));
443 catch (IOException ex)
445 MARSHAL bad = new MARSHAL();
446 bad.minor = Minor.IOR;
453 * Read the type code. The type code format is defined in the CORBA
456 public TypeCode read_TypeCode()
460 return TypeCodeHelper.read(this);
465 throw new Unexpected();
469 throw new Unexpected();
474 * Read the CORBA {@link Any}. This method first reads the type code, then
475 * delegates the functionality to {@link Any#read_value}.
477 public Any read_any()
479 TypeCode ty = read_TypeCode();
480 gnuAny any = new gnuAny();
481 any.read_value(this, ty);
486 * Read the boolean, treating any non zero byte as true, zero byte as false.
488 public boolean read_boolean()
492 return b.read() == 0 ? false : true;
494 catch (EOFException ex)
496 MARSHAL t = new MARSHAL(UNEXP_EOF);
501 catch (IOException ex)
503 throw new Unexpected(ex);
508 * Read the array of boolean.
510 public void read_boolean_array(boolean[] x, int offs, int len)
514 for (int i = offs; i < offs + len; i++)
516 x[i] = b.read() == 0 ? false : true;
519 catch (EOFException ex)
521 MARSHAL t = new MARSHAL(UNEXP_EOF);
527 catch (IOException ex)
529 throw new Unexpected(ex);
534 * Read a character using narrow charset encoding. Depending form which
535 * encoding is set, this still can be Unicode or ever wider.
537 public char read_char()
542 return (char) b.read();
544 return (char) new InputStreamReader((InputStream) b, narrow_charset).read();
546 catch (EOFException ex)
548 MARSHAL t = new MARSHAL(UNEXP_EOF);
554 catch (IOException ex)
556 throw new Unexpected(ex);
561 * Read a character array, using narrow charset encoding.
563 public void read_char_array(char[] x, int offset, int length)
569 for (int i = offset; i < offset + length; i++)
570 x[i] = (char) b.read();
574 InputStreamReader reader = new InputStreamReader((InputStream) b,
576 reader.read(x, offset, length);
579 catch (EOFException ex)
581 MARSHAL t = new MARSHAL(UNEXP_EOF);
587 catch (IOException ex)
589 throw new Unexpected(ex);
594 * Read the double value, IEEE 754 format.
596 public double read_double()
601 return b.readDouble();
603 catch (EOFException ex)
605 MARSHAL t = new MARSHAL(UNEXP_EOF);
611 catch (IOException ex)
613 throw new Unexpected();
618 * Read the array of double values, IEEE 754 format.
620 public void read_double_array(double[] x, int offs, int len)
625 for (int i = offs; i < offs + len; i++)
627 x[i] = b.readDouble();
630 catch (EOFException ex)
632 MARSHAL t = new MARSHAL(UNEXP_EOF);
638 catch (IOException ex)
640 throw new Unexpected(ex);
645 * Read the encapsulated stream. If the encapsulated sequence appears to be in
646 * the Little endian format, the flag of the returned stream is set to read
649 public BufferredCdrInput read_encapsulation()
655 byte[] r = new byte[l];
659 n += read(r, n, r.length - n);
662 BufferredCdrInput capsule = new BufferredCdrInput(r);
665 int endian = capsule.read_octet();
669 capsule.setBigEndian(false);
674 catch (EOFException ex)
676 MARSHAL t = new MARSHAL(UNEXP_EOF);
682 catch (IOException ex)
684 throw new Unexpected(ex);
689 * Read the CORBA fixed (the end of the <code>fixed</code> can be determined
690 * by its last byte). The scale is always assumed to be zero.
692 public BigDecimal read_fixed()
696 return BigDecimalHelper.read(this, 0);
698 catch (EOFException ex)
700 MARSHAL t = new MARSHAL(UNEXP_EOF);
706 catch (IOException ex)
708 throw new Unexpected(ex);
713 * Read the float value, IEEE 754 format.
715 public float read_float()
720 return b.readFloat();
722 catch (EOFException ex)
724 MARSHAL t = new MARSHAL(UNEXP_EOF);
730 catch (IOException ex)
732 throw new Unexpected(ex);
737 * Read an array of float values, IEEE 754 format.
739 public void read_float_array(float[] x, int offs, int len)
744 for (int i = offs; i < offs + len; i++)
746 x[i] = b.readFloat();
749 catch (EOFException ex)
751 MARSHAL t = new MARSHAL(UNEXP_EOF);
757 catch (IOException ex)
759 throw new Unexpected(ex);
764 * Read the CORBA long (java int), high byte first.
766 public int read_long()
773 catch (EOFException ex)
775 MARSHAL t = new MARSHAL(UNEXP_EOF);
781 catch (IOException ex)
783 throw new Unexpected(ex);
788 * Read an array of CORBA longs (java ints).
790 public void read_long_array(int[] x, int offs, int len)
795 for (int i = offs; i < offs + len; i++)
800 catch (EOFException ex)
802 MARSHAL t = new MARSHAL(UNEXP_EOF);
808 catch (IOException ex)
810 throw new Unexpected(ex);
815 * Read the CORBA long long (java long).
817 public long read_longlong()
824 catch (EOFException ex)
826 MARSHAL t = new MARSHAL(UNEXP_EOF);
831 catch (IOException ex)
833 throw new Unexpected(ex);
838 * Read an array of CORBA long longs (java longs).
840 public void read_longlong_array(long[] x, int offs, int len)
845 for (int i = offs; i < offs + len; i++)
850 catch (EOFException ex)
852 MARSHAL t = new MARSHAL(UNEXP_EOF);
858 catch (IOException ex)
860 throw new Unexpected(ex);
865 * Read a single byte.
867 public byte read_octet()
873 catch (EOFException ex)
875 MARSHAL t = new MARSHAL(UNEXP_EOF);
881 catch (IOException ex)
883 throw new Unexpected(ex);
888 * Read the byte array.
890 public void read_octet_array(byte[] x, int offs, int len)
894 b.read(x, offs, len);
896 catch (EOFException ex)
898 MARSHAL t = new MARSHAL(UNEXP_EOF);
904 catch (IOException ex)
906 throw new Unexpected(ex);
911 * Read the length of the byte array as CORBA long and then the array itseld.
913 public byte[] read_sequence()
918 byte[] buf = new byte[l];
925 catch (EOFException ex)
927 MARSHAL t = new MARSHAL(UNEXP_EOF);
933 catch (IOException ex)
935 throw new Unexpected(ex);
940 * Read the CORBA short integer.
942 public short read_short()
947 return b.readShort();
949 catch (EOFException ex)
951 MARSHAL t = new MARSHAL(UNEXP_EOF);
957 catch (IOException ex)
959 throw new Unexpected(ex);
964 * Read the array of CORBA short integer values.
966 public void read_short_array(short[] x, int offs, int len)
971 for (int i = offs; i < offs + len; i++)
973 x[i] = b.readShort();
976 catch (EOFException ex)
978 MARSHAL t = new MARSHAL(UNEXP_EOF);
984 catch (IOException ex)
986 throw new Unexpected(ex);
991 * Read a singe byte string. The method firs reads the byte array and then
992 * calls a constructor to create a string from this array. The character
993 * encoding, if previously set, is taken into consideration.
995 * @return a loaded string.
997 public String read_string()
1005 byte[] s = new byte[n];
1008 // Discard the null terminator.
1009 if (narrow_charset == null)
1010 return new String(s, 0, n - 1);
1012 return new String(s, 0, n - 1, narrow_charset);
1014 catch (EOFException ex)
1016 MARSHAL t = new MARSHAL(UNEXP_EOF);
1017 t.minor = Minor.EOF;
1021 catch (IOException ex)
1023 throw new Unexpected();
1025 catch (NegativeArraySizeException nex)
1027 MARSHAL m = new MARSHAL("Input stream broken, got " + n + "(0x"
1028 + Integer.toHexString(n) + ") as a string size");
1029 m.minor = Minor.Negative;
1035 * Reads the CORBA unsigned long (java int), delegating functionality to
1036 * {@link #read_long}.
1038 public int read_ulong()
1044 * Reads the array of CORBA unsigned long (java integer) values, delegating
1045 * functionality to {@link #real_long_array}.
1047 public void read_ulong_array(int[] x, int offs, int len)
1049 read_long_array(x, offs, len);
1053 * Read the CORBA unsigned long long value, delegating functionality to
1054 * {@link #read_longlong}. There is no way to return values over the limit of
1055 * the java signed long in other way than returning the negative value.
1057 public long read_ulonglong()
1059 return read_longlong();
1063 * Reads the array of CORBA long long (java long) values, delegating
1064 * functionality to {@link #real_longlong_array}.
1066 public void read_ulonglong_array(long[] x, int offs, int len)
1068 read_longlong_array(x, offs, len);
1072 * Read the unsigned short integer value. Due strange specification, the
1073 * returned value must be the short type as well, so the the best solution
1074 * seems just to delegete functionality to read_short.
1076 public short read_ushort()
1078 return read_short();
1082 * Read an array of unsigned short values, delegating the functionality to
1083 * {@link read_short_array}.
1085 public void read_ushort_array(short[] x, int offs, int len)
1087 read_short_array(x, offs, len);
1091 * Reads the wide character using the encoding, specified in the wide_charset.
1093 public char read_wchar()
1097 if (giop.until_inclusive(1, 1))
1102 return (char) b.readShort();
1104 return (char) new InputStreamReader((InputStream) b, wide_charset).read();
1109 if (l == 2 && wide_native)
1110 return b.readChar();
1113 MARSHAL m = new MARSHAL("wchar size " + l);
1114 m.minor = Minor.Negative;
1119 byte[] bytes = new byte[l];
1123 if (bytes.length > 2 && bytes[0] == 0xFE && bytes[1] == 0xFF)
1124 cs = new String(bytes, 2, bytes.length - 2, wide_charset);
1125 else if (bytes.length > 2 && bytes[0] == 0xFF
1126 && bytes[1] == 0xFE)
1128 // Litle endian detected - swap bytes.
1130 for (int i = 3; i < bytes.length; i = i + 2)
1133 bytes[i - 1] = bytes[i];
1136 cs = new String(bytes, 2, bytes.length - 2, wide_charset);
1139 cs = new String(bytes, wide_charset);
1141 return cs.charAt(0);
1145 catch (EOFException ex)
1147 MARSHAL t = new MARSHAL(UNEXP_EOF);
1148 t.minor = Minor.EOF;
1152 catch (IOException ex)
1154 throw new Unexpected();
1159 * Read an array of "wide chars", each representing a two byte Unicode
1160 * character, high byte first.
1162 public void read_wchar_array(char[] x, int offset, int length)
1166 if (giop.until_inclusive(1, 1))
1171 for (int i = offset; i < offset + length; i++)
1172 x[i] = (char) b.readShort();
1176 InputStreamReader reader = new InputStreamReader((InputStream) b,
1178 reader.read(x, offset, length);
1181 catch (EOFException ex)
1183 MARSHAL t = new MARSHAL(UNEXP_EOF);
1184 t.minor = Minor.EOF;
1189 catch (IOException ex)
1191 throw new Unexpected(ex);
1196 * Reads the string in wide character format (ussually UTF-16, Unicode). Takes
1197 * the currently set charset into consideration.
1199 * If the native (UTF-16) encoding is used of the GIOP protocol is before 1.2,
1200 * delegates functionality to "plain" {@link #read_wstring_UTF_16}.
1202 public String read_wstring()
1204 // Native encoding or word oriented data.
1205 if (wide_native || giop.until_inclusive(1, 1))
1206 return read_wstring_UTF_16();
1211 int n = b.readInt();
1212 byte[] s = new byte[n];
1215 return new String(s, 0, n, wide_charset);
1217 catch (EOFException ex)
1219 MARSHAL t = new MARSHAL(UNEXP_EOF);
1220 t.minor = Minor.EOF;
1225 catch (IOException ex)
1227 throw new Unexpected(ex);
1232 * Reads first length of the string and the all characters as an Unicode
1233 * (UTF-16) characters. Mind that GIOP 1.1 has the extra null character at the
1234 * end that must be discarded.
1236 public String read_wstring_UTF_16()
1241 int n = read_long();
1245 MARSHAL m = new MARSHAL("Negative string size");
1246 m.minor = Minor.Negative;
1250 // The null terminator that is no longer present since 1.2 .
1251 int nt = giop.since_inclusive(1, 2) ? 0 : 1;
1253 // Convert bytes to shorts.
1260 char[] s = new char[n];
1262 for (int i = 0; i < s.length; i++)
1263 s[i] = (char) b.readShort();
1265 // Check for the byte order marker here.
1268 // Big endian encoding - do nothing, but move the pointer
1269 // one position forward.
1272 else if (s[0] == 0xFFFE)
1274 // Little endian encoding, swap the bytes and move one
1275 // position forward.
1278 for (int i = p; i < s.length; i++)
1282 // Discard the null terminator and, if needed, the endian marker.
1283 String r = new String(s, p, n - nt - p);
1286 catch (EOFException ex)
1288 MARSHAL t = new MARSHAL(UNEXP_EOF);
1289 t.minor = Minor.EOF;
1294 catch (IOException ex)
1296 throw new Unexpected(ex);
1301 * Swap bytes in the character.
1303 public static char swap(char x)
1309 hi = (x >> 8) & 0xFF;
1311 return (char) ((lo << 8) | hi);
1315 * Set the current code set context.
1317 public void setCodeSet(CodeSetServiceContext a_codeset)
1319 this.codeset = a_codeset;
1320 narrow_charset = CharSets_OSF.getName(codeset.char_data);
1321 wide_charset = CharSets_OSF.getName(codeset.wide_char_data);
1323 narrow_native = CharSets_OSF.NATIVE_CHARACTER == codeset.char_data;
1324 wide_native = CharSets_OSF.NATIVE_WIDE_CHARACTER == codeset.wide_char_data;
1328 * Get the current code set context.
1330 public CodeSetServiceContext getCodeSet()
1336 * Read the object that is an instance of the given class. The current
1337 * implementation delegates functionality to the parameterless
1338 * {@link readObject()}.
1340 * @param klass a class of that this object the instance is.
1342 * @return the returned object.
1344 public org.omg.CORBA.Object read_Object(Class klass)
1346 return read_Object();
1350 * Read a value type structure from the stream.
1352 * OMG specification states the writing format is outside the scope of GIOP
1353 * definition. This implementation uses java serialization mechanism, calling
1354 * {@link ObjectInputStream#readObject}
1356 * @return an value type structure, unmarshaled from the stream
1358 public Serializable read_Value()
1360 return read_value();
1364 * Read the abstract interface. An abstract interface can be either CORBA
1365 * value type or CORBA object and is returned as an abstract java.lang.Object.
1367 * As specified in OMG specification, this reads a single boolean and then
1368 * delegates either to {@link #read_Object()} (for false) or to
1369 * {@link #read_Value()} (for true).
1371 * @return an abstract interface, unmarshaled from the stream
1373 public java.lang.Object read_Abstract()
1375 return read_abstract_interface();
1379 * Read an array. In OMG specification is written that if the data does not
1380 * fit into the holder value field, that array must be resized. The
1381 * implementation follows this rule. If the holder value field contains null,
1382 * it is newly instantiated.
1384 public void read_char_array(CharSeqHolder holder, int offset, int length)
1386 holder.value = ensureArray(holder.value, offset, length);
1387 read_char_array(holder.value, offset, length);
1391 * Read an array. In OMG specification is written that if the data does not
1392 * fit into the holder value field, that array must be resized. The
1393 * implementation follows this rule. If the holder value field contains null,
1394 * it is newly instantiated.
1396 public void read_wchar_array(WCharSeqHolder holder, int offset, int length)
1398 holder.value = ensureArray(holder.value, offset, length);
1399 read_wchar_array(holder.value, offset, length);
1403 * If required, allocate or resize the char array to fit the newly read
1406 * @param holder_value the existing char array, may be null.
1407 * @param offset the required offset to read.
1408 * @param length the length of the new sequence.
1410 * @return the allocated or resized array, same array if no such operations
1413 private char[] ensureArray(char[] holder_value, int offset, int length)
1415 if (holder_value == null)
1416 return new char[offset + length];
1417 else if (holder_value.length < offset + length)
1419 char[] value = new char[offset + length];
1420 System.arraycopy(holder_value, 0, value, 0, holder_value.length);
1424 return holder_value;
1428 * Read an array. In OMG specification is written that if the data does not
1429 * fit into the holder value field, that array must be resized. The
1430 * implementation follows this rule. If the holder value field contains null,
1431 * it is newly instantiated.
1433 public void read_ulong_array(ULongSeqHolder holder, int offset, int length)
1435 holder.value = ensureArray(holder.value, offset, length);
1436 read_ulong_array(holder.value, offset, length);
1440 * Read an array. In OMG specification is written that if the data does not
1441 * fit into the holder value field, that array must be resized. The
1442 * implementation follows this rule. If the holder value field contains null,
1443 * it is newly instantiated.
1445 public void read_long_array(LongSeqHolder holder, int offset, int length)
1447 holder.value = ensureArray(holder.value, offset, length);
1448 read_ulong_array(holder.value, offset, length);
1452 * If required, allocate or resize the int array to fit the newly read values.
1454 * @param holder_value the existing int array, may be null.
1455 * @param offset the required offset to read.
1456 * @param length the length of the new sequence.
1458 * @return the allocated or resized array, same array if no such operations
1461 private int[] ensureArray(int[] holder_value, int offset, int length)
1463 if (holder_value == null)
1464 return new int[offset + length];
1465 else if (holder_value.length < offset + length)
1467 int[] value = new int[offset + length];
1468 System.arraycopy(holder_value, 0, value, 0, holder_value.length);
1472 return holder_value;
1476 * Read an array. In OMG specification is written that if the data does not
1477 * fit into the holder value field, that array must be resized. The
1478 * implementation follows this rule. If the holder value field contains null,
1479 * it is newly instantiated.
1481 public void read_float_array(FloatSeqHolder holder, int offset, int length)
1483 holder.value = ensureArray(holder.value, offset, length);
1484 read_float_array(holder.value, offset, length);
1488 * If required, allocate or resize the float array to fit the newly read
1491 * @param holder_value the existing float array, may be null.
1492 * @param offset the required offset to read.
1493 * @param length the length of the new sequence.
1495 * @return the allocated or resized array, same array if no such operations
1498 private float[] ensureArray(float[] holder_value, int offset, int length)
1500 if (holder_value == null)
1501 return new float[offset + length];
1502 else if (holder_value.length < offset + length)
1504 float[] value = new float[offset + length];
1505 System.arraycopy(holder_value, 0, value, 0, holder_value.length);
1509 return holder_value;
1513 * Read an array. In OMG specification is written that if the data does not
1514 * fit into the holder value field, that array must be resized. The
1515 * implementation follows this rule. If the holder value field contains null,
1516 * it is newly instantiated.
1518 public void read_double_array(DoubleSeqHolder holder, int offset, int length)
1520 holder.value = ensureArray(holder.value, offset, length);
1521 read_double_array(holder.value, offset, length);
1525 * If required, allocate or resize the double array to fit the newly read
1528 * @param holder_value the existing double array, may be null.
1529 * @param offset the required offset to read.
1530 * @param length the length of the new sequence.
1532 * @return the allocated or resized array, same array if no such operations
1535 private double[] ensureArray(double[] holder_value, int offset, int length)
1537 if (holder_value == null)
1538 return new double[offset + length];
1539 else if (holder_value.length < offset + length)
1541 double[] value = new double[offset + length];
1542 System.arraycopy(holder_value, 0, value, 0, holder_value.length);
1546 return holder_value;
1550 * Read an array. In OMG specification is written that if the data does not
1551 * fit into the holder value field, that array must be resized. The
1552 * implementation follows this rule. If the holder value field contains null,
1553 * it is newly instantiated.
1555 public void read_short_array(ShortSeqHolder holder, int offset, int length)
1557 holder.value = ensureArray(holder.value, offset, length);
1558 read_short_array(holder.value, offset, length);
1561 /** {@inheritDoc} */
1562 public void read_ushort_array(UShortSeqHolder holder, int offset, int length)
1564 holder.value = ensureArray(holder.value, offset, length);
1565 read_ushort_array(holder.value, offset, length);
1569 * If required, allocate or resize the short array to fit the newly read
1572 * @param holder_value the existing short array, may be null.
1573 * @param offset the required offset to read.
1574 * @param length the length of the new sequence.
1576 * @return the allocated or resized array, same array if no such operations
1579 private short[] ensureArray(short[] holder_value, int offset, int length)
1581 if (holder_value == null)
1582 return new short[offset + length];
1583 else if (holder_value.length < offset + length)
1585 short[] value = new short[offset + length];
1586 System.arraycopy(holder_value, 0, value, 0, holder_value.length);
1590 return holder_value;
1594 * Read an array. In OMG specification is written that if the data does not
1595 * fit into the holder value field, that array must be resized. The
1596 * implementation follows this rule. If the holder value field contains null,
1597 * it is newly instantiated.
1599 public void read_octet_array(OctetSeqHolder holder, int offset, int length)
1601 holder.value = ensureArray(holder.value, offset, length);
1602 read_octet_array(holder.value, offset, length);
1606 * If required, allocate or resize the byte array to fit the newly read
1609 * @param holder_value the existing byte array, may be null.
1610 * @param offset the required offset to read.
1611 * @param length the length of the new sequence.
1613 * @return the allocated or resized array, same array if no such operations
1616 private byte[] ensureArray(byte[] holder_value, int offset, int length)
1618 if (holder_value == null)
1619 return new byte[offset + length];
1620 else if (holder_value.length < offset + length)
1622 byte[] value = new byte[offset + length];
1623 System.arraycopy(holder_value, 0, value, 0, holder_value.length);
1627 return holder_value;
1631 * Read an array. In OMG specification is written that if the data does not
1632 * fit into the holder value field, that array must be resized. The
1633 * implementation follows this rule. If the holder value field contains null,
1634 * it is newly instantiated.
1636 public void read_longlong_array(LongLongSeqHolder holder, int offset,
1639 holder.value = ensureArray(holder.value, offset, length);
1640 read_longlong_array(holder.value, offset, length);
1644 * Read an array. In OMG specification is written that if the data does not
1645 * fit into the holder value field, that array must be resized. The
1646 * implementation follows this rule. If the holder value field contains null,
1647 * it is newly instantiated.
1649 public void read_ulonglong_array(ULongLongSeqHolder holder, int offset,
1652 holder.value = ensureArray(holder.value, offset, length);
1653 read_ulonglong_array(holder.value, offset, length);
1657 * If required, allocate or resize the array of longs to fit the newly read
1660 * @param holder_value the existing array, may be null.
1661 * @param offset the required offset to read.
1662 * @param length the length of the new sequence.
1664 * @return the allocated or resized array, same array if no such operations
1667 private long[] ensureArray(long[] holder_value, int offset, int length)
1669 if (holder_value == null)
1670 return new long[offset + length];
1671 else if (holder_value.length < offset + length)
1673 long[] value = new long[offset + length];
1674 System.arraycopy(holder_value, 0, value, 0, holder_value.length);
1678 return holder_value;
1682 * Read an array. In OMG specification is written that if the data does not
1683 * fit into the holder value field, that array must be resized. The
1684 * implementation follows this rule. If the holder value field contains null,
1685 * it is newly instantiated.
1687 public void read_boolean_array(BooleanSeqHolder holder, int offset, int length)
1689 holder.value = ensureArray(holder.value, offset, length);
1690 read_boolean_array(holder.value, offset, length);
1694 * If required, allocate or resize the array of booleans to fit the newly read
1697 * @param holder_value the existing array of booleans, may be null.
1698 * @param offset the required offset to read.
1699 * @param length the length of the new sequence.
1701 * @return the allocated or resized array, same array if no such operations
1704 private boolean[] ensureArray(boolean[] holder_value, int offset, int length)
1706 if (holder_value == null)
1707 return new boolean[offset + length];
1708 else if (holder_value.length < offset + length)
1710 boolean[] value = new boolean[offset + length];
1711 System.arraycopy(holder_value, 0, value, 0, holder_value.length);
1715 return holder_value;
1719 * Read an array. In OMG specification is written that if the data does not
1720 * fit into the holder value field, that array must be resized. The
1721 * implementation follows this rule. If the holder value field contains null,
1722 * it is newly instantiated.
1724 public void read_any_array(AnySeqHolder holder, int offset, int length)
1726 holder.value = ensureArray(holder.value, offset, length);
1727 for (int i = offset; i < offset + length; i++)
1729 holder.value[i] = read_any();
1734 * If required, allocate or resize the array of Anys to fit the newly read
1737 * @param holder_value the existing array of Anys, may be null.
1738 * @param offset the required offset to read.
1739 * @param length the length of the new sequence.
1741 * @return the allocated or resized array, same array if no such operations
1744 private Any[] ensureArray(Any[] holder_value, int offset, int length)
1746 if (holder_value == null)
1747 return new Any[offset + length];
1748 else if (holder_value.length < offset + length)
1750 Any[] value = new Any[offset + length];
1751 System.arraycopy(holder_value, 0, value, 0, holder_value.length);
1755 return holder_value;
1759 * This method is required to represent the DataInputStream as a value type
1762 * @return a single entity "IDL:omg.org/CORBA/DataInputStream:1.0", always.
1764 public String[] _truncatable_ids()
1766 return new String[] { "IDL:omg.org/CORBA/DataInputStream:1.0" };