/[classpath]/classpath/gnu/CORBA/CDR/cdrInput.java
ViewVC logotype

Diff of /classpath/gnu/CORBA/CDR/cdrInput.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.10 by audriusa, Sun Oct 2 19:58:00 2005 UTC revision 1.11 by audriusa, Tue Oct 4 17:58:14 2005 UTC
# Line 44  import gnu.CORBA.GIOP.CharSets_OSF; Line 44  import gnu.CORBA.GIOP.CharSets_OSF;
44  import gnu.CORBA.GIOP.cxCodeSet;  import gnu.CORBA.GIOP.cxCodeSet;
45  import gnu.CORBA.IOR;  import gnu.CORBA.IOR;
46  import gnu.CORBA.IOR_Delegate;  import gnu.CORBA.IOR_Delegate;
47    import gnu.CORBA.Minor;
48  import gnu.CORBA.TypeCodeHelper;  import gnu.CORBA.TypeCodeHelper;
49  import gnu.CORBA.Unexpected;  import gnu.CORBA.Unexpected;
50  import gnu.CORBA.Version;  import gnu.CORBA.Version;
# Line 81  import java.io.Serializable; Line 82  import java.io.Serializable;
82  import java.math.BigDecimal;  import java.math.BigDecimal;
83    
84  /**  /**
85   * A simple CORBA CDR (common data representation)   * A simple CORBA CDR (common data representation) input stream, reading data
86   * input stream, reading data from the   * from the given {@link java.io.InputStream}. The primitive types are aligned
87   * given {@link java.io.InputStream}. The primitive types   * on they natural boundaries by implementing the abstract method
88   * are aligned on they natural boundaries by implementing the   * {@link #align(int boundary)}.
89   * abstract method {@link #align(int boundary)}.   *
90   *   * The same class also implements {@link org.omg.CORBA.DataInputStream} to read
91   * The same class also implements {@link org.omg.CORBA.DataInputStream} to   * the object content in a user defined way.
92   * read the object content in a user defined way.   *
93     * TODO This class uses 16 bits per Unicode character only, as it was until jdk
94     * 1.4 inclusive.
95   *   *
  * TODO This class uses 16 bits per Unicode character only, as it was until  
  * jdk 1.4 inclusive.  
  *  
96   * @author Audrius Meskauskas (AudriusA@Bioinformatics.org)   * @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
97   */   */
98  public abstract class cdrInput  public abstract class cdrInput
# Line 100  public abstract class cdrInput Line 100  public abstract class cdrInput
100    implements org.omg.CORBA.DataInputStream    implements org.omg.CORBA.DataInputStream
101  {  {
102    /**    /**
103     * The runtime, associated with this stream. This field is only used when     * 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.     * reading and writing value types and filled-in in gnu.CORBA.CDR.Vio.
105     */     */
106    public transient gnuRuntime runtime;      public transient gnuRuntime runtime;
107      
108    /**    /**
109     * The message, explaining that the exception has been thrown due     * The message, explaining that the exception has been thrown due unexpected
110     * unexpected end of the input stream. This usually happens the     * end of the input stream. This usually happens the server and client
111     * server and client disagree on communication or data representation     * disagree on communication or data representation rules.
    * rules.  
112     */     */
113    protected static final String UNEXP_EOF = "Unexpected end of stream";    protected static final String UNEXP_EOF = "Unexpected end of stream";
114    
115    /**    /**
116     * This instance is used to convert primitive data types into the     * This instance is used to convert primitive data types into the byte
117     * byte sequences.     * sequences.
118     */     */
119    protected abstractDataInputStream b;    protected abstractDataInputStream b;
120    
121    /**    /**
122     * The input stream, from where the data are actually     * The input stream, from where the data are actually being read.
    * being read.  
123     */     */
124    protected java.io.InputStream actual_stream;    protected java.io.InputStream actual_stream;
125    
# Line 141  public abstract class cdrInput Line 139  public abstract class cdrInput
139    protected cxCodeSet codeset = cxCodeSet.STANDARD;    protected cxCodeSet codeset = cxCodeSet.STANDARD;
140    
141    /**    /**
142     * The name of the currently used narrow charset, null if     * The name of the currently used narrow charset, null if the native narrow
143     * the native narrow charset is used.     * charset is used.
144     */     */
145    private String narrow_charset = null;    private String narrow_charset = null;
146    
147    /**    /**
148     * The name of the currently used wide charset, null if     * The name of the currently used wide charset, null if the native wide
149     * the native wide charset is used.     * charset is used.
150     */     */
151    private String wide_charset = null;    private String wide_charset = null;
152    
153    /**    /**
154     * True if the native code set is used for narrow characters.     * True if the native code set is used for narrow characters. If the set is
155     * If the set is native, no the intermediate Reader object     * native, no the intermediate Reader object is instantiated when writing
156     * is instantiated when writing characters.     * characters.
157     */     */
158    private boolean narrow_native;    private boolean narrow_native;
159    
160    /**    /**
161     * True if the native code set is used for wide characters.     * True if the native code set is used for wide characters. If the set is
162     * If the set is native, no the intermediate Reader object     * native, no the intermediate Reader object is instantiated when writing
163     * is instantiated when writing characters.     * characters.
164     */     */
165    private boolean wide_native;    private boolean wide_native;
166    
167    /**    /**
168     * If true, the stream expect     * If true, the stream expect the multi-byte data in the form "less
169     * the multi-byte data in the form "less significant byte     * significant byte first" (Little Endian). This is the opposite to the java
170     * first" (Little Endian). This is the opposite to the     * standard (Big Endian).
    * java standard (Big Endian).  
171     */     */
172    private boolean little_endian;    private boolean little_endian;
173    
174    /**    /**
175     * Creates the stream. The stream reads Big Endian by     * Creates the stream. The stream reads Big Endian by default.
176     * default.     *
    *  
177     * @param readFrom a stream to read CORBA input from.     * @param readFrom a stream to read CORBA input from.
178     */     */
179    public cdrInput(java.io.InputStream readFrom)    public cdrInput(java.io.InputStream readFrom)
# Line 187  public abstract class cdrInput Line 183  public abstract class cdrInput
183    }    }
184    
185    /**    /**
186     * Creates the stream, requiring the subsequent call     * Creates the stream, requiring the subsequent call of
187     * of {@link #setInputStream(java.io.InputStream)}.     * {@link #setInputStream(java.io.InputStream)}.
188     */     */
189    public cdrInput()    public cdrInput()
190    {    {
# Line 196  public abstract class cdrInput Line 192  public abstract class cdrInput
192    }    }
193    
194    /**    /**
195     * Set the Big Endian or Little Endian encoding.     * Set the Big Endian or Little Endian encoding. The stream reads Big Endian
196     * The stream reads Big Endian by default.     * by default.
197     *     *
198     * @param use_little_endian if true, the stream expect     * @param use_little_endian if true, the stream expect the multi-byte data in
199     * the multi-byte data in the form "less significant byte     * the form "less significant byte first" (Little Endian). This is the
200     * first" (Little Endian). This is the opposite to the     * opposite to the java standard (Big Endian).
    * java standard (Big Endian).  
201     */     */
202    public void setBigEndian(boolean use_big_endian)    public void setBigEndian(boolean use_big_endian)
203    {    {
# Line 212  public abstract class cdrInput Line 207  public abstract class cdrInput
207    
208    /**    /**
209     * Get the used encoding.     * Get the used encoding.
210     *     *
211     * @param true for Big Endian, false for Little Endian.     * @param true for Big Endian, false for Little Endian.
212     */     */
213    public boolean isBigEndian()    public boolean isBigEndian()
214    {    {
215      return !little_endian;      return !little_endian;
216    }    }
217      
218    /**    /**
219     * Clone all important settings to another stream.     * Clone all important settings to another stream.
220     */     */
# Line 233  public abstract class cdrInput Line 228  public abstract class cdrInput
228    
229    /**    /**
230     * Set the input stream that receives the CORBA input.     * Set the input stream that receives the CORBA input.
231     *     *
232     * @param readFrom the stream.     * @param readFrom the stream.
233     */     */
234    public void setInputStream(java.io.InputStream readFrom)    public void setInputStream(java.io.InputStream readFrom)
# Line 247  public abstract class cdrInput Line 242  public abstract class cdrInput
242    }    }
243    
244    /**    /**
245     * Set the alignment offset, if the index of the first byte in the     * Set the alignment offset, if the index of the first byte in the stream is
246     * stream is different from 0.     * different from 0.
247     */     */
248    public abstract void setOffset(int offset);    public abstract void setOffset(int offset);
249    
250    /**    /**
251     * Set the orb, associated with this stream.     * Set the orb, associated with this stream.
252       *
253     * @param an_orb     * @param an_orb
254     */     */
255    public void setOrb(ORB an_orb)    public void setOrb(ORB an_orb)
# Line 262  public abstract class cdrInput Line 258  public abstract class cdrInput
258    }    }
259    
260    /**    /**
261     * Set the GIOP version. Some data types are written differently     * Set the GIOP version. Some data types are written differently for the
262     * for the different versions. The default version is 1.0 .     * different versions. The default version is 1.0 .
263     */     */
264    public void setVersion(Version giop_version)    public void setVersion(Version giop_version)
265    {    {
# Line 276  public abstract class cdrInput Line 272  public abstract class cdrInput
272    public abstract void align(int boundary);    public abstract void align(int boundary);
273    
274    /**    /**
275     * Reads the CORBA unsigned long (java int), returning the     * Reads the CORBA unsigned long (java int), returning the value in the
276     * value in the sufficiently large java long.     * sufficiently large java long.
277     */     */
278    public long gnu_read_ulong()    public long gnu_read_ulong()
279    {    {
# Line 290  public abstract class cdrInput Line 286  public abstract class cdrInput
286      catch (EOFException ex)      catch (EOFException ex)
287        {        {
288          MARSHAL t = new MARSHAL(UNEXP_EOF);          MARSHAL t = new MARSHAL(UNEXP_EOF);
289            t.minor = Minor.EOF;
290          t.initCause(ex);          t.initCause(ex);
291          throw t;          throw t;
292        }        }
# Line 300  public abstract class cdrInput Line 297  public abstract class cdrInput
297    }    }
298    
299    /**    /**
300     * Read the unsigned short integer value and return it as java     * Read the unsigned short integer value and return it as java int,
301     * int, sufficiently large to hold all values.     * sufficiently large to hold all values.
302     */     */
303    public int gnu_read_ushort()    public int gnu_read_ushort()
304    {    {
# Line 313  public abstract class cdrInput Line 310  public abstract class cdrInput
310      catch (EOFException ex)      catch (EOFException ex)
311        {        {
312          MARSHAL t = new MARSHAL(UNEXP_EOF);          MARSHAL t = new MARSHAL(UNEXP_EOF);
313            t.minor = Minor.EOF;
314          t.initCause(ex);          t.initCause(ex);
315          throw t;          throw t;
316        }        }
# Line 325  public abstract class cdrInput Line 323  public abstract class cdrInput
323    
324    /**    /**
325     * Return the associated {@link ORB}.     * Return the associated {@link ORB}.
326       *
327     * @return the associated {@link ORB} or null is no such is set.     * @return the associated {@link ORB} or null is no such is set.
328     */     */
329    public ORB orb()    public ORB orb()
# Line 336  public abstract class cdrInput Line 335  public abstract class cdrInput
335     * Read a single byte directly from the buffer.     * Read a single byte directly from the buffer.
336     */     */
337    public int read()    public int read()
338             throws java.io.IOException      throws java.io.IOException
339    {    {
340      try      try
341        {        {
# Line 345  public abstract class cdrInput Line 344  public abstract class cdrInput
344      catch (EOFException ex)      catch (EOFException ex)
345        {        {
346          MARSHAL t = new MARSHAL(UNEXP_EOF);          MARSHAL t = new MARSHAL(UNEXP_EOF);
347            t.minor = Minor.EOF;
348          t.initCause(ex);          t.initCause(ex);
349          throw t;          throw t;
350        }        }
# Line 354  public abstract class cdrInput Line 354  public abstract class cdrInput
354     * Read bytes directly from the buffer.     * Read bytes directly from the buffer.
355     */     */
356    public int read(byte[] x, int ofs, int len)    public int read(byte[] x, int ofs, int len)
357             throws java.io.IOException      throws java.io.IOException
358    {    {
359      try      try
360        {        {
# Line 363  public abstract class cdrInput Line 363  public abstract class cdrInput
363      catch (EOFException ex)      catch (EOFException ex)
364        {        {
365          MARSHAL t = new MARSHAL(UNEXP_EOF);          MARSHAL t = new MARSHAL(UNEXP_EOF);
366            t.minor = Minor.EOF;
367          t.initCause(ex);          t.initCause(ex);
368          throw t;          throw t;
369        }        }
# Line 372  public abstract class cdrInput Line 373  public abstract class cdrInput
373     * Read bytes directly from the buffer.     * Read bytes directly from the buffer.
374     */     */
375    public int read(byte[] x)    public int read(byte[] x)
376             throws java.io.IOException      throws java.io.IOException
377    {    {
378      try      try
379        {        {
# Line 381  public abstract class cdrInput Line 382  public abstract class cdrInput
382      catch (EOFException ex)      catch (EOFException ex)
383        {        {
384          MARSHAL t = new MARSHAL(UNEXP_EOF);          MARSHAL t = new MARSHAL(UNEXP_EOF);
385            t.minor = Minor.EOF;
386          t.initCause(ex);          t.initCause(ex);
387          throw t;          throw t;
388        }        }
389    }    }
390    
391    /**    /**
392     * Read the CORBA object. The object to read is represented in the     * Read the CORBA object. The object to read is represented in the form of the
393     * form of the plain (not a string-encoded) IOR profile without the     * plain (not a string-encoded) IOR profile without the heading endian
394     * heading endian indicator. The responsible method for reading such     * indicator. The responsible method for reading such data is
395     * data is {@link IOR.read_no_endian}.     * {@link IOR.read_no_endian}.
396     *     *
397     * The returned object is usually casted into the given type using     * The returned object is usually casted into the given type using the .narrow
398     * the .narrow method of its helper, despite in some cases the direct     * method of its helper, despite in some cases the direct cast would also
399     * cast would also work.     * work.
400     *     *
401     * The null objects are recognised from the empty profile set.     * The null objects are recognised from the empty profile set. For such
402     * For such objects, null is returned.     * objects, null is returned.
403     *     *
404     * @return the loaded and constructed object.     * @return the loaded and constructed object.
405     */     */
406    public org.omg.CORBA.Object read_Object()    public org.omg.CORBA.Object read_Object()
# Line 447  public abstract class cdrInput Line 449  public abstract class cdrInput
449    }    }
450    
451    /**    /**
452     * Read the type code. The type code format is defined in the     * Read the type code. The type code format is defined in the CORBA
453     * CORBA documenation.     * documenation.
454     */     */
455    public TypeCode read_TypeCode()    public TypeCode read_TypeCode()
456    {    {
# Line 468  public abstract class cdrInput Line 470  public abstract class cdrInput
470    }    }
471    
472    /**    /**
473     * Read the CORBA {@link Any}. This method first reads the     * Read the CORBA {@link Any}. This method first reads the type code, then
474     * type code, then delegates the functionality     * delegates the functionality to {@link Any#read_value}.
    * to {@link Any#read_value}.  
475     */     */
476    public Any read_any()    public Any read_any()
477    {    {
# Line 481  public abstract class cdrInput Line 482  public abstract class cdrInput
482    }    }
483    
484    /**    /**
485     * Read the boolean, treating any non zero byte as true,     * Read the boolean, treating any non zero byte as true, zero byte as false.
    * zero byte as false.  
486     */     */
487    public boolean read_boolean()    public boolean read_boolean()
488    {    {
# Line 493  public abstract class cdrInput Line 493  public abstract class cdrInput
493      catch (EOFException ex)      catch (EOFException ex)
494        {        {
495          MARSHAL t = new MARSHAL(UNEXP_EOF);          MARSHAL t = new MARSHAL(UNEXP_EOF);
496            t.minor = Minor.EOF;
497          t.initCause(ex);          t.initCause(ex);
498          throw t;          throw t;
499        }        }
# Line 511  public abstract class cdrInput Line 512  public abstract class cdrInput
512        {        {
513          for (int i = offs; i < offs + len; i++)          for (int i = offs; i < offs + len; i++)
514            {            {
515              x [ i ] = b.read() == 0 ? false : true;              x[i] = b.read() == 0 ? false : true;
516            }            }
517        }        }
518      catch (EOFException ex)      catch (EOFException ex)
519        {        {
520          MARSHAL t = new MARSHAL(UNEXP_EOF);          MARSHAL t = new MARSHAL(UNEXP_EOF);
521            t.minor = Minor.EOF;
522          t.initCause(ex);          t.initCause(ex);
523          throw t;          throw t;
524        }        }
# Line 528  public abstract class cdrInput Line 530  public abstract class cdrInput
530    }    }
531    
532    /**    /**
533     * Read a character using narrow charset encoding. Depending form     * Read a character using narrow charset encoding. Depending form which
534     * which encoding is set, this still can be Unicode or ever wider.     * encoding is set, this still can be Unicode or ever wider.
535     */     */
536    public char read_char()    public char read_char()
537    {    {
# Line 543  public abstract class cdrInput Line 545  public abstract class cdrInput
545      catch (EOFException ex)      catch (EOFException ex)
546        {        {
547          MARSHAL t = new MARSHAL(UNEXP_EOF);          MARSHAL t = new MARSHAL(UNEXP_EOF);
548            t.minor = Minor.EOF;
549          t.initCause(ex);          t.initCause(ex);
550          throw t;          throw t;
551        }        }
# Line 563  public abstract class cdrInput Line 566  public abstract class cdrInput
566          if (narrow_native)          if (narrow_native)
567            {            {
568              for (int i = offset; i < offset + length; i++)              for (int i = offset; i < offset + length; i++)
569                x [ i ] = (char) b.read();                x[i] = (char) b.read();
570            }            }
571          else          else
572            {            {
573              InputStreamReader reader =              InputStreamReader reader = new InputStreamReader((InputStream) b,
574                new InputStreamReader((InputStream) b, narrow_charset);                narrow_charset);
575              reader.read(x, offset, length);              reader.read(x, offset, length);
576            }            }
577        }        }
578      catch (EOFException ex)      catch (EOFException ex)
579        {        {
580          MARSHAL t = new MARSHAL(UNEXP_EOF);          MARSHAL t = new MARSHAL(UNEXP_EOF);
581            t.minor = Minor.EOF;
582          t.initCause(ex);          t.initCause(ex);
583          throw t;          throw t;
584        }        }
# Line 598  public abstract class cdrInput Line 602  public abstract class cdrInput
602      catch (EOFException ex)      catch (EOFException ex)
603        {        {
604          MARSHAL t = new MARSHAL(UNEXP_EOF);          MARSHAL t = new MARSHAL(UNEXP_EOF);
605            t.minor = Minor.EOF;
606          t.initCause(ex);          t.initCause(ex);
607          throw t;          throw t;
608        }        }
# Line 618  public abstract class cdrInput Line 623  public abstract class cdrInput
623          align(8);          align(8);
624          for (int i = offs; i < offs + len; i++)          for (int i = offs; i < offs + len; i++)
625            {            {
626              x [ i ] = b.readDouble();              x[i] = b.readDouble();
627            }            }
628        }        }
629      catch (EOFException ex)      catch (EOFException ex)
630        {        {
631          MARSHAL t = new MARSHAL(UNEXP_EOF);          MARSHAL t = new MARSHAL(UNEXP_EOF);
632            t.minor = Minor.EOF;
633          t.initCause(ex);          t.initCause(ex);
634          throw t;          throw t;
635        }        }
# Line 635  public abstract class cdrInput Line 641  public abstract class cdrInput
641    }    }
642    
643    /**    /**
644     * Read the encapsulated stream.     * Read the encapsulated stream. If the encapsulated sequence appears to be in
645     * If the encapsulated sequence appears to be in the     * the Little endian format, the flag of the returned stream is set to read
646     * Little endian format, the flag of the returned stream     * Little endian.
    * is set to read Little endian.  
647     */     */
648    public cdrBufInput read_encapsulation()    public cdrBufInput read_encapsulation()
649    {    {
# Line 646  public abstract class cdrInput Line 651  public abstract class cdrInput
651        {        {
652          int l = read_long();          int l = read_long();
653    
654          byte[] r = new byte[ l ];          byte[] r = new byte[l];
655          int n = 0;          int n = 0;
656          reading:          reading: while (n < r.length)
         while (n < r.length)  
657            {            {
658              n += read(r, n, r.length - n);              n += read(r, n, r.length - n);
659            }            }
# Line 669  public abstract class cdrInput Line 673  public abstract class cdrInput
673      catch (EOFException ex)      catch (EOFException ex)
674        {        {
675          MARSHAL t = new MARSHAL(UNEXP_EOF);          MARSHAL t = new MARSHAL(UNEXP_EOF);
676            t.minor = Minor.EOF;
677          t.initCause(ex);          t.initCause(ex);
678          throw t;          throw t;
679        }        }
# Line 680  public abstract class cdrInput Line 685  public abstract class cdrInput
685    }    }
686    
687    /**    /**
688     * Read the CORBA fixed (the end of the <code>fixed</code>     * Read the CORBA fixed (the end of the <code>fixed</code> can be determined
689     * can be determined by its last byte). The scale is always     * by its last byte). The scale is always assumed to be zero.
    * assumed to be zero.  
690     */     */
691    public BigDecimal read_fixed()    public BigDecimal read_fixed()
692    {    {
# Line 693  public abstract class cdrInput Line 697  public abstract class cdrInput
697      catch (EOFException ex)      catch (EOFException ex)
698        {        {
699          MARSHAL t = new MARSHAL(UNEXP_EOF);          MARSHAL t = new MARSHAL(UNEXP_EOF);
700            t.minor = Minor.EOF;
701          t.initCause(ex);          t.initCause(ex);
702          throw t;          throw t;
703        }        }
# Line 716  public abstract class cdrInput Line 721  public abstract class cdrInput
721      catch (EOFException ex)      catch (EOFException ex)
722        {        {
723          MARSHAL t = new MARSHAL(UNEXP_EOF);          MARSHAL t = new MARSHAL(UNEXP_EOF);
724            t.minor = Minor.EOF;
725          t.initCause(ex);          t.initCause(ex);
726          throw t;          throw t;
727        }        }
# Line 736  public abstract class cdrInput Line 742  public abstract class cdrInput
742          align(4);          align(4);
743          for (int i = offs; i < offs + len; i++)          for (int i = offs; i < offs + len; i++)
744            {            {
745              x [ i ] = b.readFloat();              x[i] = b.readFloat();
746            }            }
747        }        }
748      catch (EOFException ex)      catch (EOFException ex)
749        {        {
750          MARSHAL t = new MARSHAL(UNEXP_EOF);          MARSHAL t = new MARSHAL(UNEXP_EOF);
751            t.minor = Minor.EOF;
752          t.initCause(ex);          t.initCause(ex);
753          throw t;          throw t;
754        }        }
# Line 765  public abstract class cdrInput Line 772  public abstract class cdrInput
772      catch (EOFException ex)      catch (EOFException ex)
773        {        {
774          MARSHAL t = new MARSHAL(UNEXP_EOF);          MARSHAL t = new MARSHAL(UNEXP_EOF);
775            t.minor = Minor.EOF;
776          t.initCause(ex);          t.initCause(ex);
777          throw t;          throw t;
778        }        }
# Line 785  public abstract class cdrInput Line 793  public abstract class cdrInput
793          align(4);          align(4);
794          for (int i = offs; i < offs + len; i++)          for (int i = offs; i < offs + len; i++)
795            {            {
796              x [ i ] = b.readInt();              x[i] = b.readInt();
797            }            }
798        }        }
799      catch (EOFException ex)      catch (EOFException ex)
800        {        {
801          MARSHAL t = new MARSHAL(UNEXP_EOF);          MARSHAL t = new MARSHAL(UNEXP_EOF);
802            t.minor = Minor.EOF;
803          t.initCause(ex);          t.initCause(ex);
804          throw t;          throw t;
805        }        }
# Line 813  public abstract class cdrInput Line 822  public abstract class cdrInput
822        }        }
823      catch (EOFException ex)      catch (EOFException ex)
824        {        {
825          throw new MARSHAL(UNEXP_EOF);          MARSHAL t = new MARSHAL(UNEXP_EOF);
826            t.minor = Minor.EOF;
827            throw t;
828        }        }
829    
830      catch (IOException ex)      catch (IOException ex)
# Line 832  public abstract class cdrInput Line 843  public abstract class cdrInput
843          align(8);          align(8);
844          for (int i = offs; i < offs + len; i++)          for (int i = offs; i < offs + len; i++)
845            {            {
846              x [ i ] = b.readLong();              x[i] = b.readLong();
847            }            }
848        }        }
849      catch (EOFException ex)      catch (EOFException ex)
850        {        {
851          MARSHAL t = new MARSHAL(UNEXP_EOF);          MARSHAL t = new MARSHAL(UNEXP_EOF);
852            t.minor = Minor.EOF;
853          t.initCause(ex);          t.initCause(ex);
854          throw t;          throw t;
855        }        }
# Line 860  public abstract class cdrInput Line 872  public abstract class cdrInput
872      catch (EOFException ex)      catch (EOFException ex)
873        {        {
874          MARSHAL t = new MARSHAL(UNEXP_EOF);          MARSHAL t = new MARSHAL(UNEXP_EOF);
875            t.minor = Minor.EOF;
876          t.initCause(ex);          t.initCause(ex);
877          throw t;          throw t;
878        }        }
# Line 882  public abstract class cdrInput Line 895  public abstract class cdrInput
895      catch (EOFException ex)      catch (EOFException ex)
896        {        {
897          MARSHAL t = new MARSHAL(UNEXP_EOF);          MARSHAL t = new MARSHAL(UNEXP_EOF);
898            t.minor = Minor.EOF;
899          t.initCause(ex);          t.initCause(ex);
900          throw t;          throw t;
901        }        }
# Line 893  public abstract class cdrInput Line 907  public abstract class cdrInput
907    }    }
908    
909    /**    /**
910     * Read the length of the byte array as CORBA long and then     * Read the length of the byte array as CORBA long and then the array itseld.
    * the array itseld.  
911     */     */
912    public byte[] read_sequence()    public byte[] read_sequence()
913    {    {
914      try      try
915        {        {
916          int l = read_long();          int l = read_long();
917          byte[] buf = new byte[ l ];          byte[] buf = new byte[l];
918          if (l > 0)          if (l > 0)
919            {            {
920              b.readFully(buf);              b.readFully(buf);
# Line 911  public abstract class cdrInput Line 924  public abstract class cdrInput
924      catch (EOFException ex)      catch (EOFException ex)
925        {        {
926          MARSHAL t = new MARSHAL(UNEXP_EOF);          MARSHAL t = new MARSHAL(UNEXP_EOF);
927            t.minor = Minor.EOF;
928          t.initCause(ex);          t.initCause(ex);
929          throw t;          throw t;
930        }        }
# Line 934  public abstract class cdrInput Line 948  public abstract class cdrInput
948      catch (EOFException ex)      catch (EOFException ex)
949        {        {
950          MARSHAL t = new MARSHAL(UNEXP_EOF);          MARSHAL t = new MARSHAL(UNEXP_EOF);
951            t.minor = Minor.EOF;
952          t.initCause(ex);          t.initCause(ex);
953          throw t;          throw t;
954        }        }
# Line 954  public abstract class cdrInput Line 969  public abstract class cdrInput
969          align(2);          align(2);
970          for (int i = offs; i < offs + len; i++)          for (int i = offs; i < offs + len; i++)
971            {            {
972              x [ i ] = b.readShort();              x[i] = b.readShort();
973            }            }
974        }        }
975      catch (EOFException ex)      catch (EOFException ex)
976        {        {
977          MARSHAL t = new MARSHAL(UNEXP_EOF);          MARSHAL t = new MARSHAL(UNEXP_EOF);
978            t.minor = Minor.EOF;
979          t.initCause(ex);          t.initCause(ex);
980          throw t;          throw t;
981        }        }
# Line 997  public abstract class cdrInput Line 1013  public abstract class cdrInput
1013      catch (EOFException ex)      catch (EOFException ex)
1014        {        {
1015          MARSHAL t = new MARSHAL(UNEXP_EOF);          MARSHAL t = new MARSHAL(UNEXP_EOF);
1016            t.minor = Minor.EOF;
1017          t.initCause(ex);          t.initCause(ex);
1018          throw t;          throw t;
1019        }        }
# Line 1006  public abstract class cdrInput Line 1023  public abstract class cdrInput
1023        }        }
1024      catch (NegativeArraySizeException nex)      catch (NegativeArraySizeException nex)
1025        {        {
1026          throw new MARSHAL("Input stream broken, got " + n + "(0x"          MARSHAL m = new MARSHAL("Input stream broken, got " + n + "(0x"
1027            + Integer.toHexString(n) + ") as a string size");            + Integer.toHexString(n) + ") as a string size");
1028            m.minor = Minor.Negative;
1029            throw m;
1030        }        }
1031    }    }
1032    
1033    /**    /**
1034     * Reads the CORBA unsigned long (java int), delegating     * Reads the CORBA unsigned long (java int), delegating functionality to
1035     * functionality to {@link #read_long}.     * {@link #read_long}.
1036     */     */
1037    public int read_ulong()    public int read_ulong()
1038    {    {
# Line 1021  public abstract class cdrInput Line 1040  public abstract class cdrInput
1040    }    }
1041    
1042    /**    /**
1043     * Reads the array of CORBA unsigned long (java integer) values,     * Reads the array of CORBA unsigned long (java integer) values, delegating
1044     * delegating functionality to     * functionality to {@link #real_long_array}.
    * {@link #real_long_array}.  
1045     */     */
1046    public void read_ulong_array(int[] x, int offs, int len)    public void read_ulong_array(int[] x, int offs, int len)
1047    {    {
# Line 1031  public abstract class cdrInput Line 1049  public abstract class cdrInput
1049    }    }
1050    
1051    /**    /**
1052     * Read the CORBA unsigned long long value,     * Read the CORBA unsigned long long value, delegating functionality to
1053     * delegating functionality to {@link #read_longlong}.     * {@link #read_longlong}. There is no way to return values over the limit of
1054     * There is no way to return values over the limit of     * the java signed long in other way than returning the negative value.
    * the java signed long in other way than returning  
    * the negative value.  
1055     */     */
1056    public long read_ulonglong()    public long read_ulonglong()
1057    {    {
# Line 1043  public abstract class cdrInput Line 1059  public abstract class cdrInput
1059    }    }
1060    
1061    /**    /**
1062     * Reads the array of CORBA long long (java long) values,     * Reads the array of CORBA long long (java long) values, delegating
1063     * delegating functionality to     * functionality to {@link #real_longlong_array}.
    * {@link #real_longlong_array}.  
1064     */     */
1065    public void read_ulonglong_array(long[] x, int offs, int len)    public void read_ulonglong_array(long[] x, int offs, int len)
1066    {    {
# Line 1053  public abstract class cdrInput Line 1068  public abstract class cdrInput
1068    }    }
1069    
1070    /**    /**
1071     * Read the unsigned short integer value. Due strange specification,     * Read the unsigned short integer value. Due strange specification, the
1072     * the returned value must be the short type as well, so the     * returned value must be the short type as well, so the the best solution
1073     * the best solution seems just to delegete functionality to     * seems just to delegete functionality to read_short.
    * read_short.  
1074     */     */
1075    public short read_ushort()    public short read_ushort()
1076    {    {
# Line 1064  public abstract class cdrInput Line 1078  public abstract class cdrInput
1078    }    }
1079    
1080    /**    /**
1081     * Read an array of unsigned short values, delegating the     * Read an array of unsigned short values, delegating the functionality to
1082     * functionality to {@link read_short_array}.     * {@link read_short_array}.
1083     */     */
1084    public void read_ushort_array(short[] x, int offs, int len)    public void read_ushort_array(short[] x, int offs, int len)
1085    {    {
# Line 1094  public abstract class cdrInput Line 1108  public abstract class cdrInput
1108              if (l == 2 && wide_native)              if (l == 2 && wide_native)
1109                return b.readChar();                return b.readChar();
1110              else if (l <= 0)              else if (l <= 0)
1111                throw new MARSHAL("wchar size " + l);                {
1112                     MARSHAL m = new MARSHAL("wchar size " + l);
1113                     m.minor = Minor.Negative;
1114                     throw m;
1115                  }
1116              else              else
1117                {                {
1118                  byte[] bytes = new byte[l];                  byte[] bytes = new byte[l];
# Line 1119  public abstract class cdrInput Line 1137  public abstract class cdrInput
1137                  else                  else
1138                    cs = new String(bytes, wide_charset);                    cs = new String(bytes, wide_charset);
1139    
                 if (cs.length() != 1)  
                   throw new MARSHAL("Wide char decoded as '" + cs + "'");  
1140                  return cs.charAt(0);                  return cs.charAt(0);
1141                }                }
1142            }            }
# Line 1128  public abstract class cdrInput Line 1144  public abstract class cdrInput
1144      catch (EOFException ex)      catch (EOFException ex)
1145        {        {
1146          MARSHAL t = new MARSHAL(UNEXP_EOF);          MARSHAL t = new MARSHAL(UNEXP_EOF);
1147            t.minor = Minor.EOF;
1148          t.initCause(ex);          t.initCause(ex);
1149          throw t;          throw t;
1150        }        }
# Line 1151  public abstract class cdrInput Line 1168  public abstract class cdrInput
1168          if (wide_native)          if (wide_native)
1169            {            {
1170              for (int i = offset; i < offset + length; i++)              for (int i = offset; i < offset + length; i++)
1171                x [ i ] = (char) b.readShort();                x[i] = (char) b.readShort();
1172            }            }
1173          else          else
1174            {            {
1175              InputStreamReader reader =              InputStreamReader reader = new InputStreamReader((InputStream) b,
1176                new InputStreamReader((InputStream) b, wide_charset);                wide_charset);
1177              reader.read(x, offset, length);              reader.read(x, offset, length);
1178            }            }
1179        }        }
1180      catch (EOFException ex)      catch (EOFException ex)
1181        {        {
1182          MARSHAL t = new MARSHAL(UNEXP_EOF);          MARSHAL t = new MARSHAL(UNEXP_EOF);
1183            t.minor = Minor.EOF;
1184          t.initCause(ex);          t.initCause(ex);
1185          throw t;          throw t;
1186        }        }
# Line 1174  public abstract class cdrInput Line 1192  public abstract class cdrInput
1192    }    }
1193    
1194    /**    /**
1195     * Reads the string in wide character format     * Reads the string in wide character format (ussually UTF-16, Unicode). Takes
1196     * (ussually UTF-16, Unicode). Takes the currently set charset     * the currently set charset into consideration.
1197     * into consideration.     *
1198     *     * If the native (UTF-16) encoding is used of the GIOP protocol is before 1.2,
1199     * If the native (UTF-16) encoding is used     * delegates functionality to "plain" {@link #read_wstring_UTF_16}.
    * of the GIOP protocol is before 1.2, delegates functionality  
    * to "plain" {@link #read_wstring_UTF_16}.  
1200     */     */
1201    public String read_wstring()    public String read_wstring()
1202    {    {
# Line 1192  public abstract class cdrInput Line 1208  public abstract class cdrInput
1208          align(4);          align(4);
1209    
1210          int n = b.readInt();          int n = b.readInt();
1211          byte[] s = new byte[ n ];          byte[] s = new byte[n];
1212          b.read(s);          b.read(s);
1213    
1214          return new String(s, 0, n, wide_charset);          return new String(s, 0, n, wide_charset);
# Line 1200  public abstract class cdrInput Line 1216  public abstract class cdrInput
1216      catch (EOFException ex)      catch (EOFException ex)
1217        {        {
1218          MARSHAL t = new MARSHAL(UNEXP_EOF);          MARSHAL t = new MARSHAL(UNEXP_EOF);
1219            t.minor = Minor.EOF;
1220          t.initCause(ex);          t.initCause(ex);
1221          throw t;          throw t;
1222        }        }
# Line 1211  public abstract class cdrInput Line 1228  public abstract class cdrInput
1228    }    }
1229    
1230    /**    /**
1231     * Reads first length of the string and the all characters as an     * Reads first length of the string and the all characters as an Unicode
1232     * Unicode (UTF-16) characters. Mind that GIOP 1.1 has the extra     * (UTF-16) characters. Mind that GIOP 1.1 has the extra null character at the
1233     * null character at the end that must be discarded.     * end that must be discarded.
1234     */     */
1235    public String read_wstring_UTF_16()    public String read_wstring_UTF_16()
1236    {    {
# Line 1221  public abstract class cdrInput Line 1238  public abstract class cdrInput
1238        {        {
1239          int p = 0;          int p = 0;
1240          int n = read_long();          int n = read_long();
1241            
1242            if (n<0)
1243              {
1244                MARSHAL m = new MARSHAL("Negative string size");
1245                m.minor = Minor.Negative;
1246                throw m;
1247              }
1248    
1249          // The null terminator that is no longer present since 1.2 .          // The null terminator that is no longer present since 1.2 .
1250          int nt = giop.since_inclusive(1, 2) ? 0 : 1;          int nt = giop.since_inclusive(1, 2) ? 0 : 1;
# Line 1229  public abstract class cdrInput Line 1253  public abstract class cdrInput
1253          n = n / 2;          n = n / 2;
1254    
1255          // Empty string.          // Empty string.
1256          if (n==0) return "";          if (n == 0)
1257                      return "";
1258          char[] s = new char[ n ];  
1259            char[] s = new char[n];
1260    
1261          for (int i = 0; i < s.length; i++)          for (int i = 0; i < s.length; i++)
1262            s [ i ] = (char) b.readShort();            s[i] = (char) b.readShort();
1263    
1264          // Check for the byte order marker here.          // Check for the byte order marker here.
1265          if (s [ 0 ] == 0xFEFF)          if (s[0] == 0xFEFF)
1266            {            {
1267              // Big endian encoding - do nothing, but move the pointer              // Big endian encoding - do nothing, but move the pointer
1268              // one position forward.              // one position forward.
1269              p = 1;              p = 1;
1270            }            }
1271          else if (s [ 0 ] == 0xFFFE)          else if (s[0] == 0xFFFE)
1272            {            {
1273              // Little endian encoding, swap the bytes and move one              // Little endian encoding, swap the bytes and move one
1274              // position forward.              // position forward.
1275              p = 1;              p = 1;
1276    
1277              for (int i = p; i < s.length; i++)              for (int i = p; i < s.length; i++)
1278                s [ i ] = swap(s [ i ]);                s[i] = swap(s[i]);
1279            }            }
1280    
1281          // Discard the null terminator and, if needed, the endian marker.          // Discard the null terminator and, if needed, the endian marker.
# Line 1260  public abstract class cdrInput Line 1285  public abstract class cdrInput
1285      catch (EOFException ex)      catch (EOFException ex)
1286        {        {
1287          MARSHAL t = new MARSHAL(UNEXP_EOF);          MARSHAL t = new MARSHAL(UNEXP_EOF);
1288            t.minor = Minor.EOF;
1289          t.initCause(ex);          t.initCause(ex);
1290          throw t;          throw t;
1291        }        }
# Line 1309  public abstract class cdrInput Line 1335  public abstract class cdrInput
1335     * Read the object that is an instance of the given class. The current     * Read the object that is an instance of the given class. The current
1336     * implementation delegates functionality to the parameterless     * implementation delegates functionality to the parameterless
1337     * {@link readObject()}.     * {@link readObject()}.
1338     *     *
1339     * @param klass a class of that this object the instance is.     * @param klass a class of that this object the instance is.
1340     *     *
1341     * @return the returned object.     * @return the returned object.
1342     */     */
1343    public org.omg.CORBA.Object read_Object(Class klass)    public org.omg.CORBA.Object read_Object(Class klass)
# Line 1321  public abstract class cdrInput Line 1347  public abstract class cdrInput
1347    
1348    /**    /**
1349     * Read a value type structure from the stream.     * Read a value type structure from the stream.
1350     *     *
1351     * OMG specification states the writing format is outside the scope     * OMG specification states the writing format is outside the scope of GIOP
1352     * of GIOP definition. This implementation uses java serialization     * definition. This implementation uses java serialization mechanism, calling
1353     * mechanism, calling {@link ObjectInputStream#readObject}     * {@link ObjectInputStream#readObject}
1354     *     *
1355     * @return an value type structure, unmarshaled from the stream     * @return an value type structure, unmarshaled from the stream
1356     */     */
1357    public Serializable read_Value()    public Serializable read_Value()
# Line 1334  public abstract class cdrInput Line 1360  public abstract class cdrInput
1360    }    }
1361    
1362    /**    /**
1363     * Read the abstract interface. An abstract interface can be either     * Read the abstract interface. An abstract interface can be either CORBA
1364     * CORBA value type or CORBA object and is returned as an abstract     * value type or CORBA object and is returned as an abstract java.lang.Object.
1365     * java.lang.Object.     *
1366     *     * As specified in OMG specification, this reads a single boolean and then
1367     * As specified in OMG specification, this reads a single     * delegates either to {@link #read_Object()} (for false) or to
1368     * boolean and then delegates either to {@link #read_Object()} (for false)     * {@link #read_Value()} (for true).
1369     * or to {@link #read_Value()} (for true).     *
    *  
1370     * @return an abstract interface, unmarshaled from the stream     * @return an abstract interface, unmarshaled from the stream
1371     */     */
1372    public java.lang.Object read_Abstract()    public java.lang.Object read_Abstract()
# Line 1350  public abstract class cdrInput Line 1375  public abstract class cdrInput
1375    }    }
1376    
1377    /**    /**
1378     * Read an array. In OMG specification is written that if the data does     * Read an array. In OMG specification is written that if the data does not
1379     * not fit into the holder value field, that array must be resized.     * fit into the holder value field, that array must be resized. The
1380     * The implementation follows this rule. If the holder value field     * implementation follows this rule. If the holder value field contains null,
1381     * contains null, it is newly instantiated.     * it is newly instantiated.
1382     */     */
1383    public void read_char_array(CharSeqHolder holder, int offset, int length)    public void read_char_array(CharSeqHolder holder, int offset, int length)
1384    {    {
# Line 1362  public abstract class cdrInput Line 1387  public abstract class cdrInput
1387    }    }
1388    
1389    /**    /**
1390     * Read an array. In OMG specification is written that if the data does     * Read an array. In OMG specification is written that if the data does not
1391     * not fit into the holder value field, that array must be resized.     * fit into the holder value field, that array must be resized. The
1392     * The implementation follows this rule. If the holder value field     * implementation follows this rule. If the holder value field contains null,
1393     * contains null, it is newly instantiated.     * it is newly instantiated.
1394     */     */
1395    public void read_wchar_array(WCharSeqHolder holder, int offset, int length)    public void read_wchar_array(WCharSeqHolder holder, int offset, int length)
1396    {    {
# Line 1374  public abstract class cdrInput Line 1399  public abstract class cdrInput
1399    }    }
1400    
1401    /**    /**
1402     * If required, allocate or resize the char array to fit the newly     * If required, allocate or resize the char array to fit the newly read
1403     * read values.     * values.
1404     *     *
1405     * @param holder_value the existing char array, may be null.     * @param holder_value the existing char array, may be null.
1406     * @param offset the required offset to read.     * @param offset the required offset to read.
1407     * @param length the length of the new sequence.     * @param length the length of the new sequence.
1408     *     *
1409     * @return the allocated or resized array, same array if no such operations     * @return the allocated or resized array, same array if no such operations
1410     * are required.     * are required.
1411     */     */
1412    private char[] ensureArray(char[] holder_value, int offset, int length)    private char[] ensureArray(char[] holder_value, int offset, int length)
1413    {    {
1414      if (holder_value == null)      if (holder_value == null)
1415        return new char[ offset + length ];        return new char[offset + length];
1416      else if (holder_value.length < offset + length)      else if (holder_value.length < offset + length)
1417        {        {
1418          char[] value = new char[ offset + length ];          char[] value = new char[offset + length];
1419          System.arraycopy(holder_value, 0, value, 0, holder_value.length);          System.arraycopy(holder_value, 0, value, 0, holder_value.length);
1420          return value;          return value;
1421        }        }
# Line 1399  public abstract class cdrInput Line 1424  public abstract class cdrInput
1424    }    }
1425    
1426    /**    /**
1427     * Read an array. In OMG specification is written that if the data does     * Read an array. In OMG specification is written that if the data does not
1428     * not fit into the holder value field, that array must be resized.     * fit into the holder value field, that array must be resized. The
1429     * The implementation follows this rule. If the holder value field     * implementation follows this rule. If the holder value field contains null,
1430     * contains null, it is newly instantiated.     * it is newly instantiated.
1431     */     */
1432    public void read_ulong_array(ULongSeqHolder holder, int offset, int length)    public void read_ulong_array(ULongSeqHolder holder, int offset, int length)
1433    {    {
# Line 1411  public abstract class cdrInput Line 1436  public abstract class cdrInput
1436    }    }
1437    
1438    /**    /**
1439     * Read an array. In OMG specification is written that if the data does     * Read an array. In OMG specification is written that if the data does not
1440     * not fit into the holder value field, that array must be resized.     * fit into the holder value field, that array must be resized. The
1441     * The implementation follows this rule. If the holder value field     * implementation follows this rule. If the holder value field contains null,
1442     * contains null, it is newly instantiated.     * it is newly instantiated.
1443     */     */
1444    public void read_long_array(LongSeqHolder holder, int offset, int length)    public void read_long_array(LongSeqHolder holder, int offset, int length)
1445    {    {
# Line 1423  public abstract class cdrInput Line 1448  public abstract class cdrInput
1448    }    }
1449    
1450    /**    /**
1451     * If required, allocate or resize the int array to fit the newly     * If required, allocate or resize the int array to fit the newly read values.
1452     * read values.     *
    *  
1453     * @param holder_value the existing int array, may be null.     * @param holder_value the existing int array, may be null.
1454     * @param offset the required offset to read.     * @param offset the required offset to read.
1455     * @param length the length of the new sequence.     * @param length the length of the new sequence.
1456     *     *
1457     * @return the allocated or resized array, same array if no such operations     * @return the allocated or resized array, same array if no such operations
1458     * are required.     * are required.
1459     */     */
1460    private int[] ensureArray(int[] holder_value, int offset, int length)    private int[] ensureArray(int[] holder_value, int offset, int length)
1461    {    {
1462      if (holder_value == null)      if (holder_value == null)
1463        return new int[ offset + length ];        return new int[offset + length];
1464      else if (holder_value.length < offset + length)      else if (holder_value.length < offset + length)
1465        {        {
1466          int[] value = new int[ offset + length ];          int[] value = new int[offset + length];
1467          System.arraycopy(holder_value, 0, value, 0, holder_value.length);          System.arraycopy(holder_value, 0, value, 0, holder_value.length);
1468          return value;          return value;
1469        }        }
# Line 1448  public abstract class cdrInput Line 1472  public abstract class cdrInput
1472    }    }
1473    
1474    /**    /**
1475     * Read an array. In OMG specification is written that if the data does     * Read an array. In OMG specification is written that if the data does not
1476     * not fit into the holder value field, that array must be resized.     * fit into the holder value field, that array must be resized. The
1477     * The implementation follows this rule. If the holder value field     * implementation follows this rule. If the holder value field contains null,
1478     * contains null, it is newly instantiated.     * it is newly instantiated.
1479     */     */
1480    public void read_float_array(FloatSeqHolder holder, int offset, int length)    public void read_float_array(FloatSeqHolder holder, int offset, int length)
1481    {    {
# Line 1460  public abstract class cdrInput Line 1484  public abstract class cdrInput
1484    }    }
1485    
1486    /**    /**
1487     * If required, allocate or resize the float array to fit the newly     * If required, allocate or resize the float array to fit the newly read
1488     * read values.     * values.
1489     *     *
1490     * @param holder_value the existing float array, may be null.     * @param holder_value the existing float array, may be null.
1491     * @param offset the required offset to read.     * @param offset the required offset to read.
1492     * @param length the length of the new sequence.     * @param length the length of the new sequence.
1493     *     *
1494     * @return the allocated or resized array, same array if no such operations     * @return the allocated or resized array, same array if no such operations
1495     * are required.     * are required.
1496     */     */
1497    private float[] ensureArray(float[] holder_value, int offset, int length)    private float[] ensureArray(float[] holder_value, int offset, int length)
1498    {    {
1499      if (holder_value == null)      if (holder_value == null)
1500        return new float[ offset + length ];        return new float[offset + length];
1501      else if (holder_value.length < offset + length)      else if (holder_value.length < offset + length)
1502        {        {
1503          float[] value = new float[ offset + length ];          float[] value = new float[offset + length];
1504          System.arraycopy(holder_value, 0, value, 0, holder_value.length);          System.arraycopy(holder_value, 0, value, 0, holder_value.length);
1505          return value;          return value;
1506        }        }
# Line 1485  public abstract class cdrInput Line 1509  public abstract class cdrInput
1509    }    }
1510    
1511    /**    /**
1512     * Read an array. In OMG specification is written that if the data does     * Read an array. In OMG specification is written that if the data does not
1513     * not fit into the holder value field, that array must be resized.     * fit into the holder value field, that array must be resized. The
1514     * The implementation follows this rule. If the holder value field     * implementation follows this rule. If the holder value field contains null,
1515     * contains null, it is newly instantiated.     * it is newly instantiated.
1516     */     */
1517    public void read_double_array(DoubleSeqHolder holder, int offset, int length)    public void read_double_array(DoubleSeqHolder holder, int offset, int length)
1518    {    {
# Line 1497  public abstract class cdrInput Line 1521  public abstract class cdrInput
1521    }    }
1522    
1523    /**    /**
1524     * If required, allocate or resize the double array to fit the newly     * If required, allocate or resize the double array to fit the newly read
1525     * read values.     * values.
1526     *     *
1527     * @param holder_value the existing double array, may be null.     * @param holder_value the existing double array, may be null.
1528     * @param offset the required offset to read.     * @param offset the required offset to read.
1529     * @param length the length of the new sequence.     * @param length the length of the new sequence.
1530     *     *
1531     * @return the allocated or resized array, same array if no such operations     * @return the allocated or resized array, same array if no such operations
1532     * are required.     * are required.
1533     */     */
1534    private double[] ensureArray(double[] holder_value, int offset, int length)    private double[] ensureArray(double[] holder_value, int offset, int length)
1535    {    {
1536      if (holder_value == null)      if (holder_value == null)
1537        return new double[ offset + length ];        return new double[offset + length];
1538      else if (holder_value.length < offset + length)      else if (holder_value.length < offset + length)
1539        {        {
1540          double[] value = new double[ offset + length ];          double[] value = new double[offset + length];
1541          System.arraycopy(holder_value, 0, value, 0, holder_value.length);          System.arraycopy(holder_value, 0, value, 0, holder_value.length);
1542          return value;          return value;
1543        }        }
# Line 1522  public abstract class cdrInput Line 1546  public abstract class cdrInput
1546    }    }
1547    
1548    /**    /**
1549     * Read an array. In OMG specification is written that if the data does     * Read an array. In OMG specification is written that if the data does not
1550     * not fit into the holder value field, that array must be resized.     * fit into the holder value field, that array must be resized. The
1551     * The implementation follows this rule. If the holder value field     * implementation follows this rule. If the holder value field contains null,
1552     * contains null, it is newly instantiated.     * it is newly instantiated.
1553     */     */
1554    public void read_short_array(ShortSeqHolder holder, int offset, int length)    public void read_short_array(ShortSeqHolder holder, int offset, int length)
1555    {    {
# Line 1541  public abstract class cdrInput Line 1565  public abstract class cdrInput
1565    }    }
1566    
1567    /**    /**
1568     * If required, allocate or resize the short array to fit the newly     * If required, allocate or resize the short array to fit the newly read
1569     * read values.     * values.
1570     *     *
1571     * @param holder_value the existing short array, may be null.     * @param holder_value the existing short array, may be null.
1572     * @param offset the required offset to read.     * @param offset the required offset to read.
1573     * @param length the length of the new sequence.     * @param length the length of the new sequence.
1574     *     *
1575     * @return the allocated or resized array, same array if no such operations     * @return the allocated or resized array, same array if no such operations
1576     * are required.     * are required.
1577     */     */
1578    private short[] ensureArray(short[] holder_value, int offset, int length)    private short[] ensureArray(short[] holder_value, int offset, int length)
1579    {    {
1580      if (holder_value == null)      if (holder_value == null)
1581        return new short[ offset + length ];        return new short[offset + length];
1582      else if (holder_value.length < offset + length)      else if (holder_value.length < offset + length)
1583        {        {
1584          short[] value = new short[ offset + length ];          short[] value = new short[offset + length];
1585          System.arraycopy(holder_value, 0, value, 0, holder_value.length);          System.arraycopy(holder_value, 0, value, 0, holder_value.length);
1586          return value;          return value;
1587        }        }
# Line 1566  public abstract class cdrInput Line 1590  public abstract class cdrInput
1590    }    }
1591    
1592    /**    /**
1593     * Read an array. In OMG specification is written that if the data does     * Read an array. In OMG specification is written that if the data does not
1594     * not fit into the holder value field, that array must be resized.     * fit into the holder value field, that array must be resized. The
1595     * The implementation follows this rule. If the holder value field     * implementation follows this rule. If the holder value field contains null,
1596     * contains null, it is newly instantiated.     * it is newly instantiated.
1597     */     */
1598    public void read_octet_array(OctetSeqHolder holder, int offset, int length)    public void read_octet_array(OctetSeqHolder holder, int offset, int length)
1599    {    {
# Line 1578  public abstract class cdrInput Line 1602  public abstract class cdrInput
1602    }    }
1603    
1604    /**    /**
1605     * If required, allocate or resize the byte array to fit the newly     * If required, allocate or resize the byte array to fit the newly read
1606     * read values.     * values.
1607     *     *
1608     * @param holder_value the existing byte array, may be null.     * @param holder_value the existing byte array, may be null.
1609     * @param offset the required offset to read.     * @param offset the required offset to read.
1610     * @param length the length of the new sequence.     * @param length the length of the new sequence.
1611     *     *
1612     * @return the allocated or resized array, same array if no such operations     * @return the allocated or resized array, same array if no such operations
1613     * are required.     * are required.
1614     */     */
1615    private byte[] ensureArray(byte[] holder_value, int offset, int length)    private byte[] ensureArray(byte[] holder_value, int offset, int length)
1616    {    {
1617      if (holder_value == null)      if (holder_value == null)
1618        return new byte[ offset + length ];        return new byte[offset + length];
1619      else if (holder_value.length < offset + length)      else if (holder_value.length < offset + length)
1620        {        {
1621          byte[] value = new byte[ offset + length ];          byte[] value = new byte[offset + length];
1622          System.arraycopy(holder_value, 0, value, 0, holder_value.length);          System.arraycopy(holder_value, 0, value, 0, holder_value.length);
1623          return value;          return value;
1624        }        }
# Line 1603  public abstract class cdrInput Line 1627  public abstract class cdrInput
1627    }    }
1628    
1629    /**    /**
1630     * Read an array. In OMG specification is written that if the data does     * Read an array. In OMG specification is written that if the data does not
1631     * not fit into the holder value field, that array must be resized.     * fit into the holder value field, that array must be resized. The
1632     * The implementation follows this rule. If the holder value field     * implementation follows this rule. If the holder value field contains null,
1633     * contains null, it is newly instantiated.     * it is newly instantiated.
1634     */     */
1635    public void read_longlong_array(LongLongSeqHolder holder, int offset,    public void read_longlong_array(LongLongSeqHolder holder, int offset,
1636                                    int length      int length)
                                  )  
1637    {    {
1638      holder.value = ensureArray(holder.value, offset, length);      holder.value = ensureArray(holder.value, offset, length);
1639      read_longlong_array(holder.value, offset, length);      read_longlong_array(holder.value, offset, length);
1640    }    }
1641    
1642    /**    /**
1643     * Read an array. In OMG specification is written that if the data does     * Read an array. In OMG specification is written that if the data does not
1644     * not fit into the holder value field, that array must be resized.     * fit into the holder value field, that array must be resized. The
1645     * The implementation follows this rule. If the holder value field     * implementation follows this rule. If the holder value field contains null,
1646     * contains null, it is newly instantiated.     * it is newly instantiated.
1647     */     */
1648    public void read_ulonglong_array(ULongLongSeqHolder holder, int offset,    public void read_ulonglong_array(ULongLongSeqHolder holder, int offset,
1649                                     int length      int length)
                                   )  
1650    {    {
1651      holder.value = ensureArray(holder.value, offset, length);      holder.value = ensureArray(holder.value, offset, length);
1652      read_ulonglong_array(holder.value, offset, length);      read_ulonglong_array(holder.value, offset, length);
1653    }    }
1654    
1655    /**    /**
1656     * If required, allocate or resize the array of longs to fit the newly     * If required, allocate or resize the array of longs to fit the newly read
1657     * read values.     * values.
1658     *     *
1659     * @param holder_value the existing array, may be null.     * @param holder_value the existing array, may be null.
1660     * @param offset the required offset to read.     * @param offset the required offset to read.
1661     * @param length the length of the new sequence.     * @param length the length of the new sequence.
1662     *     *
1663     * @return the allocated or resized array, same array if no such operations     * @return the allocated or resized array, same array if no such operations
1664     * are required.     * are required.
1665     */     */
1666    private long[] ensureArray(long[] holder_value, int offset, int length)    private long[] ensureArray(long[] holder_value, int offset, int length)
1667    {    {
1668      if (holder_value == null)      if (holder_value == null)
1669        return new long[ offset + length ];        return new long[offset + length];
1670      else if (holder_value.length < offset + length)      else if (holder_value.length < offset + length)
1671        {        {
1672          long[] value = new long[ offset + length ];          long[] value = new long[offset + length];
1673          System.arraycopy(holder_value, 0, value, 0, holder_value.length);          System.arraycopy(holder_value, 0, value, 0, holder_value.length);
1674          return value;          return value;
1675        }        }
# Line 1656  public abstract class cdrInput Line 1678  public abstract class cdrInput
1678    }    }
1679    
1680    /**    /**
1681     * Read an array. In OMG specification is written that if the data does     * Read an array. In OMG specification is written that if the data does not
1682     * not fit into the holder value field, that array must be resized.     * fit into the holder value field, that array must be resized. The
1683     * The implementation follows this rule. If the holder value field     * implementation follows this rule. If the holder value field contains null,
1684     * contains null, it is newly instantiated.     * it is newly instantiated.
1685     */     */
1686    public void read_boolean_array(BooleanSeqHolder holder, int offset, int length)    public void read_boolean_array(BooleanSeqHolder holder, int offset, int length)
1687    {    {
# Line 1668  public abstract class cdrInput Line 1690  public abstract class cdrInput
1690    }    }
1691    
1692    /**    /**
1693     * If required, allocate or resize the array of booleans to fit the newly     * If required, allocate or resize the array of booleans to fit the newly read
1694     * read values.     * values.
1695     *     *
1696     * @param holder_value the existing array of booleans, may be null.     * @param holder_value the existing array of booleans, may be null.
1697     * @param offset the required offset to read.     * @param offset the required offset to read.
1698     * @param length the length of the new sequence.     * @param length the length of the new sequence.
1699     *     *
1700     * @return the allocated or resized array, same array if no such operations     * @return the allocated or resized array, same array if no such operations
1701     * are required.     * are required.
1702     */     */
1703    private boolean[] ensureArray(boolean[] holder_value, int offset, int length)    private boolean[] ensureArray(boolean[] holder_value, int offset, int length)
1704    {    {
1705      if (holder_value == null)      if (holder_value == null)
1706        return new boolean[ offset + length ];        return new boolean[offset + length];
1707      else if (holder_value.length < offset + length)      else if (holder_value.length < offset + length)
1708        {        {
1709          boolean[] value = new boolean[ offset + length ];          boolean[] value = new boolean[offset + length];
1710          System.arraycopy(holder_value, 0, value, 0, holder_value.length);          System.arraycopy(holder_value, 0, value, 0, holder_value.length);
1711          return value;          return value;
1712        }        }
# Line 1693  public abstract class cdrInput Line 1715  public abstract class cdrInput
1715    }    }
1716    
1717    /**    /**
1718     * Read an array. In OMG specification is written that if the data does     * Read an array. In OMG specification is written that if the data does not
1719     * not fit into the holder value field, that array must be resized.     * fit into the holder value field, that array must be resized. The
1720     * The implementation follows this rule. If the holder value field     * implementation follows this rule. If the holder value field contains null,
1721     * contains null, it is newly instantiated.     * it is newly instantiated.
1722     */     */
1723    public void read_any_array(AnySeqHolder holder, int offset, int length)    public void read_any_array(AnySeqHolder holder, int offset, int length)
1724    {    {
1725      holder.value = ensureArray(holder.value, offset, length);      holder.value = ensureArray(holder.value, offset, length);
1726      for (int i = offset; i < offset + length; i++)      for (int i = offset; i < offset + length; i++)
1727        {        {
1728          holder.value [ i ] = read_any();          holder.value[i] = read_any();
1729        }        }
1730    }    }
1731    
1732    /**    /**
1733     * If required, allocate or resize the array of Anys to fit the newly     * If required, allocate or resize the array of Anys to fit the newly read
1734     * read values.     * values.
1735     *     *
1736     * @param holder_value the existing array of Anys, may be null.     * @param holder_value the existing array of Anys, may be null.
1737     * @param offset the required offset to read.     * @param offset the required offset to read.
1738     * @param length the length of the new sequence.     * @param length the length of the new sequence.
1739     *     *
1740     * @return the allocated or resized array, same array if no such operations     * @return the allocated or resized array, same array if no such operations
1741     * are required.     * are required.
1742     */     */
1743    private Any[] ensureArray(Any[] holder_value, int offset, int length)    private Any[] ensureArray(Any[] holder_value, int offset, int length)
1744    {    {
1745      if (holder_value == null)      if (holder_value == null)
1746        return new Any[ offset + length ];        return new Any[offset + length];
1747      else if (holder_value.length < offset + length)      else if (holder_value.length < offset + length)
1748        {        {
1749          Any[] value = new Any[ offset + length ];          Any[] value = new Any[offset + length];
1750          System.arraycopy(holder_value, 0, value, 0, holder_value.length);          System.arraycopy(holder_value, 0, value, 0, holder_value.length);
1751          return value;          return value;
1752        }        }
# Line 1733  public abstract class cdrInput Line 1755  public abstract class cdrInput
1755    }    }
1756    
1757    /**    /**
1758     * This method is required to represent the DataInputStream as a value     * This method is required to represent the DataInputStream as a value type
1759     * type object.     * object.
1760     *     *
1761     * @return a single entity "IDL:omg.org/CORBA/DataInputStream:1.0",     * @return a single entity "IDL:omg.org/CORBA/DataInputStream:1.0", always.
    * always.  
1762     */     */
1763    public String[] _truncatable_ids()    public String[] _truncatable_ids()
1764    {    {

Legend:
Removed from v.1.10  
changed lines
  Added in v.1.11

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26