2 Copyright (C) 2005 Free Software Foundation, Inc.
4 This file is part of GNU Classpath.
6 GNU Classpath is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
11 GNU Classpath is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GNU Classpath; see the file COPYING. If not, write to the
18 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21 Linking this library statically or dynamically with other modules is
22 making a combined work based on this library. Thus, the terms and
23 conditions of the GNU General Public License cover the whole
26 As a special exception, the copyright holders of this library give you
27 permission to link this library with independent modules to produce an
28 executable, regardless of the license terms of these independent
29 modules, and to copy and distribute the resulting executable under
30 terms of your choice, provided that you also meet, for each linked
31 independent module, the terms and conditions of the license of that
32 module. An independent module is a module which is not derived from
33 or based on this library. If you modify this library, you may extend
34 this exception to your version of the library, but you are not
35 obligated to do so. If you do not wish to do so, delete this
36 exception statement from your version. */
39 package gnu
.javax
.rmi
.CORBA
;
41 import gnu
.CORBA
.CDR
.gnuRuntime
;
43 import org
.omg
.CORBA_2_3
.portable
.InputStream
;
45 import java
.io
.DataInputStream
;
46 import java
.io
.IOException
;
47 import java
.io
.ObjectInput
;
48 import java
.io
.ObjectInputStream
;
49 import java
.io
.Serializable
;
52 * Converts calls on java ObjectOutputStream to calls on CORBA OutputStream. A
53 * class to substitute for objects using readObject method.
55 * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
57 public class CorbaInput
58 extends ObjectInputStream
59 implements ObjectInput
63 * The underlying CORBA stream from where the actual input is taken.
65 public InputStream stream
;
68 * The utility class to write the object fields in default way.
70 final RmiUtilities util
;
73 * The object currently being read.
78 * The offset of the object currently being read.
83 * The repository id of the object currently being read.
88 * The runtime, related to the object currently being read.
93 * Create an instance, delegating calls to the given CORBA stream.
95 public CorbaInput(InputStream an_input
, Object firstObject
,
96 RmiUtilities an_util
, int an_offset
, String a_rid
,
101 current
= firstObject
;
110 public int available()
113 return stream
.available();
125 public void defaultReadObject()
126 throws IOException
, ClassNotFoundException
128 util
.readFields(offset
, rid
, (Serializable
) current
, stream
, runtime
);
132 public void mark(int readlimit
)
134 stream
.mark(readlimit
);
138 public boolean markSupported()
140 return stream
.markSupported();
147 return stream
.read();
151 public int read(byte[] buf
, int off
, int len
)
154 return stream
.read(buf
, off
, len
);
158 public int read(byte[] b
)
161 return stream
.read(b
);
165 public boolean readBoolean()
168 return stream
.read_boolean();
172 public byte readByte()
175 return (byte) stream
.read();
179 public char readChar()
182 return stream
.read_char();
186 public double readDouble()
189 return stream
.read_double();
193 public float readFloat()
196 return stream
.read_float();
200 public void readFully(byte[] buf
, int off
, int len
)
203 // This class only reads from the buffered streams.
204 stream
.read(buf
, off
, len
);
208 public void readFully(byte[] buf
)
211 // This class only reads from the buffered streams.
219 return stream
.read_long();
223 public String
readLine()
226 return new DataInputStream(this).readLine();
230 public long readLong()
233 return stream
.read_longlong();
237 public short read_short()
240 return stream
.read_short();
244 public int readUnsignedByte()
247 return (stream
.read() & 0xFF);
251 public int readUnsignedShort()
254 return (stream
.read_short() & 0xFFFF);
258 * Read as wide string (not as UTF).
260 public String
readUTF()
263 return stream
.read_wstring();
274 public long skip(long n
)
277 return stream
.skip(n
);
281 public int skipBytes(int len
)
284 return (int) stream
.skip(len
);
288 * Objects are read as abstract interfaces.
290 protected Object
readObjectOverride()
291 throws IOException
, ClassNotFoundException
293 current
= stream
.read_abstract_interface();