/[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.1 by audriusa, Sun May 15 01:09:29 2005 UTC revision 1.2 by audriusa, Tue May 31 20:27:14 2005 UTC
# Line 62  import org.omg.CORBA.TypeCodePackage.Bou Line 62  import org.omg.CORBA.TypeCodePackage.Bou
62  import org.omg.CORBA.portable.InputStream;  import org.omg.CORBA.portable.InputStream;
63  import org.omg.CORBA.portable.ObjectImpl;  import org.omg.CORBA.portable.ObjectImpl;
64    
65    import java.io.DataInput;
66  import java.io.DataInputStream;  import java.io.DataInputStream;
67  import java.io.EOFException;  import java.io.EOFException;
68  import java.io.IOException;  import java.io.IOException;
# Line 93  public abstract class cdrInput Line 94  public abstract class cdrInput
94     * This instance is used to convert primitive data types into the     * This instance is used to convert primitive data types into the
95     * byte sequences.     * byte sequences.
96     */     */
97    protected DataInputStream b;    protected abstractDataInputStream b;
98    
99      /**
100       * The input stream, from where the data are actually
101       * being read.
102       */
103      protected java.io.InputStream actual_stream;
104    
105    /**    /**
106     * The associated orb, if any.     * The associated orb, if any.
# Line 137  public abstract class cdrInput Line 144  public abstract class cdrInput
144    private boolean wide_native;    private boolean wide_native;
145    
146    /**    /**
147     * Creates the stream.     * If true, the stream expect
148       * the multi-byte data in the form "less significant byte
149       * first" (Little Endian). This is the opposite to the
150       * java standard (Big Endian).
151       */
152      private boolean little_endian;
153    
154      /**
155       * Creates the stream. The stream reads Big Endian by
156       * default.
157     *     *
158     * @param readFrom a stream to read CORBA input from.     * @param readFrom a stream to read CORBA input from.
159     */     */
# Line 157  public abstract class cdrInput Line 173  public abstract class cdrInput
173    }    }
174    
175    /**    /**
176       * Set the Big Endian or Little Endian encoding.
177       * The stream reads Big Endian by default.
178       *
179       * @param use_little_endian if true, the stream expect
180       * the multi-byte data in the form "less significant byte
181       * first" (Little Endian). This is the opposite to the
182       * java standard (Big Endian).
183       */
184      public void setBigEndian(boolean use_big_endian)
185      {
186        little_endian = !use_big_endian;
187        setInputStream(actual_stream);
188      }
189    
190      /**
191     * Set the input stream that receives the CORBA input.     * Set the input stream that receives the CORBA input.
192     *     *
193     * @param readFrom the stream.     * @param readFrom the stream.
194     */     */
195    public void setInputStream(java.io.InputStream readFrom)    public void setInputStream(java.io.InputStream readFrom)
196    {    {
197      b = new DataInputStream(readFrom);      if (little_endian)
198          b = new LittleEndianInputStream(readFrom);
199        else
200          b = new BigEndianInputStream(readFrom);
201    
202        actual_stream = readFrom;
203    }    }
204    
205    /**    /**
# Line 436  public abstract class cdrInput Line 472  public abstract class cdrInput
472          if (narrow_native)          if (narrow_native)
473            return (char) b.read();            return (char) b.read();
474          else          else
475            return (char) new InputStreamReader(b, narrow_charset).read();            return (char) new InputStreamReader((InputStream) b, narrow_charset).read();
476        }        }
477      catch (EOFException ex)      catch (EOFException ex)
478        {        {
# Line 463  public abstract class cdrInput Line 499  public abstract class cdrInput
499            }            }
500          else          else
501            {            {
502              InputStreamReader reader = new InputStreamReader(b, narrow_charset);              InputStreamReader reader =
503                  new InputStreamReader((InputStream) b, narrow_charset);
504              reader.read(x, offset, length);              reader.read(x, offset, length);
505            }            }
506        }        }
# Line 524  public abstract class cdrInput Line 561  public abstract class cdrInput
561    }    }
562    
563    /**    /**
564     * Read the encapsulated stream. The endian flag is already extracted from     * Read the encapsulated stream.
565     * the returned stream.     * If the encapsulated sequence appears to be in the
566       * Little endian format, the flag of the returned stream
567       * is set to read Little endian.
568     */     */
569    public cdrBufInput read_encapsulation()    public cdrBufInput read_encapsulation()
570    {    {
# Line 546  public abstract class cdrInput Line 585  public abstract class cdrInput
585    
586          int endian = capsule.read_octet();          int endian = capsule.read_octet();
587    
         // TODO FIXME implement little endian.  
588          if (endian != 0)          if (endian != 0)
589            {            {
590              throw new NO_IMPLEMENT("Little endian not supported.");              capsule.setBigEndian(false);
591            }            }
592    
593          return capsule;          return capsule;
# Line 944  public abstract class cdrInput Line 982  public abstract class cdrInput
982          if (wide_native)          if (wide_native)
983            return (char) b.readShort();            return (char) b.readShort();
984          else          else
985            return (char) new InputStreamReader(b, wide_charset).read();            return (char) new InputStreamReader((InputStream) b, wide_charset).read();
986        }        }
987      catch (EOFException ex)      catch (EOFException ex)
988        {        {
# Line 974  public abstract class cdrInput Line 1012  public abstract class cdrInput
1012            }            }
1013          else          else
1014            {            {
1015              InputStreamReader reader = new InputStreamReader(b, wide_charset);              InputStreamReader reader =
1016                  new InputStreamReader((InputStream) b, wide_charset);
1017              reader.read(x, offset, length);              reader.read(x, offset, length);
1018            }            }
1019        }        }
# Line 1126  public abstract class cdrInput Line 1165  public abstract class cdrInput
1165    {    {
1166      return read_Object();      return read_Object();
1167    }    }
1168  }  }

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