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

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

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

revision 1.1 by audriusa, Sun Aug 7 17:17:43 2005 UTC revision 1.2 by audriusa, Sun Oct 2 19:58:00 2005 UTC
# Line 38  exception statement from your version. * Line 38  exception statement from your version. *
38    
39  package gnu.CORBA.CDR;  package gnu.CORBA.CDR;
40    
41  import org.omg.CORBA.CustomMarshal;  import org.omg.CORBA.Any;
42    import org.omg.CORBA.AnySeqHolder;
43    import org.omg.CORBA.BooleanSeqHolder;
44    import org.omg.CORBA.CharSeqHolder;
45    import org.omg.CORBA.Context;
46  import org.omg.CORBA.DataInputStream;  import org.omg.CORBA.DataInputStream;
47    import org.omg.CORBA.DoubleSeqHolder;
48    import org.omg.CORBA.FloatSeqHolder;
49    import org.omg.CORBA.LongLongSeqHolder;
50    import org.omg.CORBA.LongSeqHolder;
51  import org.omg.CORBA.MARSHAL;  import org.omg.CORBA.MARSHAL;
52    import org.omg.CORBA.ORB;
53    import org.omg.CORBA.OctetSeqHolder;
54    import org.omg.CORBA.Principal;
55    import org.omg.CORBA.ShortSeqHolder;
56    import org.omg.CORBA.TypeCode;
57    import org.omg.CORBA.ULongLongSeqHolder;
58    import org.omg.CORBA.ULongSeqHolder;
59    import org.omg.CORBA.UShortSeqHolder;
60    import org.omg.CORBA.WCharSeqHolder;
61  import org.omg.CORBA.portable.BoxedValueHelper;  import org.omg.CORBA.portable.BoxedValueHelper;
62  import org.omg.CORBA.portable.Streamable;  import org.omg.CORBA.portable.InputStream;
 import org.omg.CORBA.portable.ValueFactory;  
63    
64    import java.io.IOException;
65  import java.io.Serializable;  import java.io.Serializable;
66    import java.math.BigDecimal;
67    
68  /**  /**
69   * Substitutes the main stream in factories when the header is already   * Substitutes the main stream in factories when the header is already behind.
70   * behind. Overrides methods that may be invoked from the factory,   * Overrides methods that may be invoked from the factory, forcing not to read
71   * forcing not to read the header if called first time on this stream.   * the header if called first time on this stream.
72   *   *
73   * This stream reverts to default behavior if one or more call are   * This stream reverts to default behavior if one or more call are made (reading
74   * made (reading value types that are nested fields of the value type).   * value types that are nested fields of the value type).
75   *   *
76   * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)   * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
77   */   */
78  class noHeaderInput  public class noHeaderInput
79    extends cdrBufInput    extends org.omg.CORBA_2_3.portable.InputStream
80    implements DataInputStream    implements DataInputStream, gnuValueStream
81  {  {
82    /**    /**
83       * Use serialVersionUID for interoperability.
84       */
85      private static final long serialVersionUID = 1;
86    
87      /**
88       * Indicates that no positional information is available.
89       */
90      static final int NONE = -1;
91    
92      /**
93     * If true, this is not the first call.     * If true, this is not the first call.
94     */     */
95    boolean notFirst;    public boolean subsequentCalls;
96    
97    /**    /**
98     * Create an instance, reading from the given buffer.     * The enclosed stream.
99     */     */
100    public noHeaderInput(byte[] buffer)    final cdrBufInput stream;
   {  
     super(buffer);  
   }  
101    
102    /**    /**
103     * Read when knowning the class instance.     * Create an instance, reading from the given buffer.
104       *
105       * @param a_stram a stream from where the data will be read.
106       * @param inheritSettings a stream from that endian and other settings are
107       * inherited.
108     */     */
109    public Serializable read_value(Class clz)    public noHeaderInput(cdrBufInput a_stream, InputStream inheritSettings)
110    {    {
111      if (notFirst)      stream = a_stream;
112        return super.read_value(clz);  
113      else      if (inheritSettings instanceof cdrInput)
114        {        {
115          try          cdrInput t = (cdrInput) inheritSettings;
116            {          t.cloneSettings(stream);
117              notFirst = true;        }
118              return read_value((Serializable) clz.newInstance());      else if (stream.orb() == null)
119            }        stream.setOrb(inheritSettings.orb());
120          catch (Exception ex)  
121            {      if (inheritSettings instanceof gnuValueStream
122              MARSHAL m = new MARSHAL("Unable to create an instance");        && stream.getRunTime() == null)
123              m.initCause(ex);        {
124              throw m;          stream.setRunTime(((gnuValueStream) inheritSettings).getRunTime());
           }  
125        }        }
126    }    }
127    
# Line 102  class noHeaderInput Line 130  class noHeaderInput
130     */     */
131    public Serializable read_value(BoxedValueHelper helper)    public Serializable read_value(BoxedValueHelper helper)
132    {    {
133      if (notFirst)      if (subsequentCalls)
134        return super.read_value(helper);        return stream.read_value(helper);
135      else      else
136        {        {
137          notFirst = true;          subsequentCalls = true;
138          return helper.read_value(this);          return helper.read_value(this);
139        }        }
140    }    }
# Line 116  class noHeaderInput Line 144  class noHeaderInput
144     */     */
145    public Serializable read_value(String repository_id)    public Serializable read_value(String repository_id)
146    {    {
147      if (notFirst)      if (subsequentCalls)
148        return super.read_value(repository_id);        return stream.read_value(repository_id);
149      else      else
150        {        {
151          notFirst = true;          subsequentCalls = true;
152            Serializable value = (Serializable) Vio.readValue(this, NONE, null,
153          ValueFactory factory =            null, repository_id, null, null);
154            ((org.omg.CORBA_2_3.ORB) orb()).lookup_value_factory(repository_id);          return value;
         if (factory == null)  
           throw new MARSHAL("No factory");  
         return factory.read_value(this);  
155        }        }
156    }    }
157    
# Line 135  class noHeaderInput Line 160  class noHeaderInput
160     */     */
161    public Serializable read_value(Serializable value)    public Serializable read_value(Serializable value)
162    {    {
163      if (notFirst)      if (subsequentCalls)
164        return super.read_value(value);        return stream.read_value(value);
165      else      else
166        {        {
167          notFirst = true;          subsequentCalls = true;
168            value = (Serializable) Vio.readValue(this, NONE, value, null, null,
169              null, null);
170            return value;
171          }
172      }
173    
174          // The user-defines io operations are implemented.    /**
175          if (value instanceof CustomMarshal)     * Try to read when having an unitialised value.
176       */
177      public Serializable read_value(Class clz)
178      {
179        if (subsequentCalls)
180          return stream.read_value(clz);
181        else
182          {
183            try
184            {            {
185              CustomMarshal marsh = (CustomMarshal) value;              subsequentCalls = true;
186              try              Serializable value = (Serializable) Vio.instantiateAnyWay(clz);
187                {              value = (Serializable) Vio.readValue(this, NONE, value, null, null,
188                  marsh.unmarshal((DataInputStream) this);                null, null);
189                }              return value;
             catch (ClassCastException ex)  
               {  
                 Vio.incorrect_plug_in(ex);  
               }  
190            }            }
191          else          catch (Exception ex)
         // The IDL-generated io operations are implemented.  
         if (value instanceof Streamable)  
192            {            {
193              ((Streamable) value)._read(this);              MARSHAL m = new MARSHAL("Can't read an instance of "
194                  + clz.getName());
195                m.initCause(ex);
196                throw m;
197            }            }
         return value;  
198        }        }
199    }    }
200    
201      /**
202       * Delegates functionality to the underlying stream.
203       */
204      public int available()
205        throws IOException
206      {
207        return stream.available();
208      }
209    
210      /**
211       * Delegates functionality to the underlying stream.
212       */
213      public void close()
214        throws IOException
215      {
216        stream.close();
217      }
218    
219      /**
220       * Delegates functionality to the underlying stream.
221       */
222      public void mark(int readlimit)
223      {
224        stream.mark(readlimit);
225      }
226    
227      /**
228       * Delegates functionality to the underlying stream.
229       */
230      public boolean markSupported()
231      {
232        return stream.markSupported();
233      }
234    
235      /**
236       * Delegates functionality to the underlying stream.
237       */
238      public ORB orb()
239      {
240        return stream.orb();
241      }
242    
243      /**
244       * Delegates functionality to the underlying stream.
245       */
246      public Object read_abstract_interface()
247      {
248        return stream.read_abstract_interface();
249      }
250    
251      /**
252       * Delegates functionality to the underlying stream.
253       */
254      public Object read_abstract_interface(Class clz)
255      {
256        return stream.read_abstract_interface(clz);
257      }
258    
259      /**
260       * Delegates functionality to the underlying stream.
261       */
262      public Any read_any()
263      {
264        return stream.read_any();
265      }
266    
267      /**
268       * Delegates functionality to the underlying stream.
269       */
270      public void read_boolean_array(boolean[] value, int offset, int length)
271      {
272        stream.read_boolean_array(value, offset, length);
273      }
274    
275      /**
276       * Delegates functionality to the underlying stream.
277       */
278      public boolean read_boolean()
279      {
280        return stream.read_boolean();
281      }
282    
283      /**
284       * Delegates functionality to the underlying stream.
285       */
286      public void read_char_array(char[] value, int offset, int length)
287      {
288        stream.read_char_array(value, offset, length);
289      }
290    
291      /**
292       * Delegates functionality to the underlying stream.
293       */
294      public char read_char()
295      {
296        return stream.read_char();
297      }
298    
299      /**
300       * Delegates functionality to the underlying stream.
301       */
302      public Context read_Context()
303      {
304        return stream.read_Context();
305      }
306    
307      /**
308       * Delegates functionality to the underlying stream.
309       */
310      public void read_double_array(double[] value, int offset, int length)
311      {
312        stream.read_double_array(value, offset, length);
313      }
314    
315      /**
316       * Delegates functionality to the underlying stream.
317       */
318      public double read_double()
319      {
320        return stream.read_double();
321      }
322    
323      /**
324       * Delegates functionality to the underlying stream.
325       */
326      public BigDecimal read_fixed()
327      {
328        return stream.read_fixed();
329      }
330    
331      /**
332       * Delegates functionality to the underlying stream.
333       */
334      public void read_float_array(float[] value, int offset, int length)
335      {
336        stream.read_float_array(value, offset, length);
337      }
338    
339      /**
340       * Delegates functionality to the underlying stream.
341       */
342      public float read_float()
343      {
344        return stream.read_float();
345      }
346    
347      /**
348       * Delegates functionality to the underlying stream.
349       */
350      public void read_long_array(int[] value, int offset, int length)
351      {
352        stream.read_long_array(value, offset, length);
353      }
354    
355      /**
356       * Delegates functionality to the underlying stream.
357       */
358      public int read_long()
359      {
360        return stream.read_long();
361      }
362    
363      /**
364       * Delegates functionality to the underlying stream.
365       */
366      public void read_longlong_array(long[] value, int offset, int length)
367      {
368        stream.read_longlong_array(value, offset, length);
369      }
370    
371      /**
372       * Delegates functionality to the underlying stream.
373       */
374      public long read_longlong()
375      {
376        return stream.read_longlong();
377      }
378    
379      /**
380       * Delegates functionality to the underlying stream.
381       */
382      public org.omg.CORBA.Object read_Object()
383      {
384        return stream.read_Object();
385      }
386    
387      /**
388       * Delegates functionality to the underlying stream.
389       */
390      public org.omg.CORBA.Object read_Object(Class klass)
391      {
392        return stream.read_Object(klass);
393      }
394    
395      /**
396       * Delegates functionality to the underlying stream.
397       */
398      public void read_octet_array(byte[] value, int offset, int length)
399      {
400        stream.read_octet_array(value, offset, length);
401      }
402    
403      /**
404       * Delegates functionality to the underlying stream.
405       */
406      public byte read_octet()
407      {
408        return stream.read_octet();
409      }
410    
411      /**
412       * Delegates functionality to the underlying stream.
413       */
414      public Principal read_Principal()
415      {
416        return stream.read_Principal();
417      }
418    
419      /**
420       * Delegates functionality to the underlying stream.
421       */
422      public void read_short_array(short[] value, int offset, int length)
423      {
424        stream.read_short_array(value, offset, length);
425      }
426    
427      /**
428       * Delegates functionality to the underlying stream.
429       */
430      public short read_short()
431      {
432        return stream.read_short();
433      }
434    
435      /**
436       * Delegates functionality to the underlying stream.
437       */
438      public String read_string()
439      {
440        return stream.read_string();
441      }
442    
443      /**
444       * Delegates functionality to the underlying stream.
445       */
446      public TypeCode read_TypeCode()
447      {
448        return stream.read_TypeCode();
449      }
450    
451      /**
452       * Delegates functionality to the underlying stream.
453       */
454      public void read_ulong_array(int[] value, int offset, int length)
455      {
456        stream.read_ulong_array(value, offset, length);
457      }
458    
459      /**
460       * Delegates functionality to the underlying stream.
461       */
462      public int read_ulong()
463      {
464        return stream.read_ulong();
465      }
466    
467      /**
468       * Delegates functionality to the underlying stream.
469       */
470      public void read_ulonglong_array(long[] value, int offset, int length)
471      {
472        stream.read_ulonglong_array(value, offset, length);
473      }
474    
475      /**
476       * Delegates functionality to the underlying stream.
477       */
478      public long read_ulonglong()
479      {
480        return stream.read_ulonglong();
481      }
482    
483      /**
484       * Delegates functionality to the underlying stream.
485       */
486      public void read_ushort_array(short[] value, int offset, int length)
487      {
488        stream.read_ushort_array(value, offset, length);
489      }
490    
491      /**
492       * Delegates functionality to the underlying stream.
493       */
494      public short read_ushort()
495      {
496        return stream.read_ushort();
497      }
498    
499      /**
500       * Delegates functionality to the underlying stream.
501       */
502      public Serializable read_value()
503      {
504        return read_value((Serializable) null);
505      }
506    
507      /**
508       * Delegates functionality to the underlying stream.
509       */
510      public void read_wchar_array(char[] value, int offset, int length)
511      {
512        stream.read_wchar_array(value, offset, length);
513      }
514    
515      /**
516       * Delegates functionality to the underlying stream.
517       */
518      public char read_wchar()
519      {
520        return stream.read_wchar();
521      }
522    
523      /**
524       * Delegates functionality to the underlying stream.
525       */
526      public String read_wstring()
527      {
528        return stream.read_wstring();
529      }
530    
531      /**
532       * Delegates functionality to the underlying stream.
533       */
534      public int read()
535        throws IOException
536      {
537        return stream.read();
538      }
539    
540      /**
541       * Delegates functionality to the underlying stream.
542       */
543      public int read(byte[] b, int off, int len)
544        throws IOException
545      {
546        return stream.read(b, off, len);
547      }
548    
549      /**
550       * Delegates functionality to the underlying stream.
551       */
552      public int read(byte[] b)
553        throws IOException
554      {
555        return stream.read(b);
556      }
557    
558      /**
559       * Delegates functionality to the underlying stream.
560       */
561      public void reset()
562        throws IOException
563      {
564        stream.reset();
565      }
566    
567      /**
568       * Delegates functionality to the underlying stream.
569       */
570      public long skip(long n)
571        throws IOException
572      {
573        return stream.skip(n);
574      }
575    
576      /**
577       * Get a string representation.
578       */
579      public String toString()
580      {
581        return "noHeaderInput+" + stream.toString();
582      }
583    
584      /**
585       * Delegates functionality to the underlying stream.
586       */
587      public String[] _truncatable_ids()
588      {
589        return stream._truncatable_ids();
590      }
591    
592      /**
593       * Delegates functionality to the underlying stream.
594       */
595      public Object read_Abstract()
596      {
597        return stream.read_Abstract();
598      }
599    
600      /**
601       * Delegates functionality to the underlying stream.
602       */
603      public void read_any_array(AnySeqHolder holder, int offset, int length)
604      {
605        stream.read_any_array(holder, offset, length);
606      }
607    
608      /**
609       * Delegates functionality to the underlying stream.
610       */
611      public void read_boolean_array(BooleanSeqHolder holder, int offset, int length)
612      {
613        stream.read_boolean_array(holder, offset, length);
614      }
615    
616      /**
617       * Delegates functionality to the underlying stream.
618       */
619      public void read_char_array(CharSeqHolder holder, int offset, int length)
620      {
621        stream.read_char_array(holder, offset, length);
622      }
623    
624      /**
625       * Delegates functionality to the underlying stream.
626       */
627      public void read_double_array(DoubleSeqHolder holder, int offset, int length)
628      {
629        stream.read_double_array(holder, offset, length);
630      }
631    
632      /**
633       * Delegates functionality to the underlying stream.
634       */
635      public void read_float_array(FloatSeqHolder holder, int offset, int length)
636      {
637        stream.read_float_array(holder, offset, length);
638      }
639    
640      /**
641       * Delegates functionality to the underlying stream.
642       */
643      public void read_long_array(LongSeqHolder holder, int offset, int length)
644      {
645        stream.read_long_array(holder, offset, length);
646      }
647    
648      /**
649       * Delegates functionality to the underlying stream.
650       */
651      public void read_longlong_array(LongLongSeqHolder holder, int offset,
652        int length)
653      {
654        stream.read_longlong_array(holder, offset, length);
655      }
656    
657      /**
658       * Delegates functionality to the underlying stream.
659       */
660      public void read_octet_array(OctetSeqHolder holder, int offset, int length)
661      {
662        stream.read_octet_array(holder, offset, length);
663      }
664    
665      /**
666       * Delegates functionality to the underlying stream.
667       */
668      public void read_short_array(ShortSeqHolder holder, int offset, int length)
669      {
670        stream.read_short_array(holder, offset, length);
671      }
672    
673      /**
674       * Delegates functionality to the underlying stream.
675       */
676      public void read_ulong_array(ULongSeqHolder holder, int offset, int length)
677      {
678        stream.read_ulong_array(holder, offset, length);
679      }
680    
681      /**
682       * Delegates functionality to the underlying stream.
683       */
684      public void read_ulonglong_array(ULongLongSeqHolder holder, int offset,
685        int length)
686      {
687        stream.read_ulonglong_array(holder, offset, length);
688      }
689    
690      /**
691       * Delegates functionality to the underlying stream.
692       */
693      public void read_ushort_array(UShortSeqHolder holder, int offset, int length)
694      {
695        stream.read_ushort_array(holder, offset, length);
696      }
697    
698      /**
699       * Delegates functionality to read_value.
700       */
701      public Serializable read_Value()
702      {
703        return read_value();
704      }
705    
706      /**
707       * Delegates functionality to the underlying stream.
708       */
709      public void read_wchar_array(WCharSeqHolder holder, int offset, int length)
710      {
711        stream.read_wchar_array(holder, offset, length);
712      }
713    
714      /**
715       * Delegates functionality to the underlying stream.
716       */
717      public int getPosition()
718      {
719        return stream.getPosition();
720      }
721    
722      /**
723       * Delegates functionality to the underlying stream.
724       */
725      public gnuRuntime getRunTime()
726      {
727        return stream.runtime;
728      }
729    
730      /**
731       * Replace the instance of RunTime.
732       */
733      public void setRunTime(gnuRuntime a_runtime)
734      {
735        stream.runtime = a_runtime;
736      }
737    
738      /**
739       * Delegates functionality to the underlying stream.
740       */
741      public void seek(int position)
742      {
743        stream.seek(position);
744      }
745    
746  }  }

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2

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