Remove old autovect-branch by moving to "dead" directory.
[official-gcc.git] / old-autovect-branch / libjava / classpath / gnu / javax / rmi / CORBA / CorbaInput.java
blobe80cabf6b2b8bba9cc9499456a0a4f9a90b6494e
1 /* CorbaInput.java --
2 Copyright (C) 2005 Free Software Foundation, Inc.
4 This file is part of GNU Classpath.
6 GNU Classpath is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
9 any later version.
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
19 02110-1301 USA.
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
24 combination.
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;
51 /**
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
62 /**
63 * The underlying CORBA stream from where the actual input is taken.
65 public InputStream stream;
67 /**
68 * The utility class to write the object fields in default way.
70 final RmiUtilities util;
72 /**
73 * The object currently being read.
75 Object current;
77 /**
78 * The offset of the object currently being read.
80 int offset;
82 /**
83 * The repository id of the object currently being read.
85 String rid;
87 /**
88 * The runtime, related to the object currently being read.
90 gnuRuntime runtime;
92 /**
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,
97 gnuRuntime a_runtime)
98 throws Exception
100 stream = an_input;
101 current = firstObject;
102 util = an_util;
104 offset = an_offset;
105 rid = a_rid;
106 runtime = a_runtime;
109 /** @inheritDoc */
110 public int available()
111 throws IOException
113 return stream.available();
117 * No action.
119 public void close()
120 throws IOException
124 /** @inheritDoc */
125 public void defaultReadObject()
126 throws IOException, ClassNotFoundException
128 util.readFields(offset, rid, (Serializable) current, stream, runtime);
131 /** @inheritDoc */
132 public void mark(int readlimit)
134 stream.mark(readlimit);
137 /** @inheritDoc */
138 public boolean markSupported()
140 return stream.markSupported();
143 /** @inheritDoc */
144 public int read()
145 throws IOException
147 return stream.read();
150 /** @inheritDoc */
151 public int read(byte[] buf, int off, int len)
152 throws IOException
154 return stream.read(buf, off, len);
157 /** @inheritDoc */
158 public int read(byte[] b)
159 throws IOException
161 return stream.read(b);
164 /** @inheritDoc */
165 public boolean readBoolean()
166 throws IOException
168 return stream.read_boolean();
171 /** @inheritDoc */
172 public byte readByte()
173 throws IOException
175 return (byte) stream.read();
178 /** @inheritDoc */
179 public char readChar()
180 throws IOException
182 return stream.read_char();
185 /** @inheritDoc */
186 public double readDouble()
187 throws IOException
189 return stream.read_double();
192 /** @inheritDoc */
193 public float readFloat()
194 throws IOException
196 return stream.read_float();
199 /** @inheritDoc */
200 public void readFully(byte[] buf, int off, int len)
201 throws IOException
203 // This class only reads from the buffered streams.
204 stream.read(buf, off, len);
207 /** @inheritDoc */
208 public void readFully(byte[] buf)
209 throws IOException
211 // This class only reads from the buffered streams.
212 stream.read(buf);
215 /** @inheritDoc */
216 public int readInt()
217 throws IOException
219 return stream.read_long();
222 /** @inheritDoc */
223 public String readLine()
224 throws IOException
226 return new DataInputStream(this).readLine();
229 /** @inheritDoc */
230 public long readLong()
231 throws IOException
233 return stream.read_longlong();
236 /** @inheritDoc */
237 public short read_short()
238 throws IOException
240 return stream.read_short();
243 /** @inheritDoc */
244 public int readUnsignedByte()
245 throws IOException
247 return (stream.read() & 0xFF);
250 /** @inheritDoc */
251 public int readUnsignedShort()
252 throws IOException
254 return (stream.read_short() & 0xFFFF);
258 * Read as wide string (not as UTF).
260 public String readUTF()
261 throws IOException
263 return stream.read_wstring();
266 /** @inheritDoc */
267 public void reset()
268 throws IOException
270 stream.reset();
273 /** @inheritDoc */
274 public long skip(long n)
275 throws IOException
277 return stream.skip(n);
280 /** @inheritDoc */
281 public int skipBytes(int len)
282 throws IOException
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();
294 return current;