KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > jonathan > apis > presentation > UnMarshaller


1 /***
2  * Jonathan: an Open Distributed Processing Environment
3  * Copyright (C) 1999 France Telecom R&D
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18  *
19  * Release: 2.0
20  *
21  * Contact: jonathan@objectweb.org
22  *
23  * Author: Bruno Dumant
24  *
25  */

26
27
28 package org.objectweb.jonathan.apis.presentation;
29
30 import org.objectweb.jonathan.apis.kernel.JonathanException;
31 import org.objectweb.jonathan.apis.kernel.Context;
32 import java.io.InputStream JavaDoc;
33
34 /**
35  * UnMarshaller is the type of basic types unmarshallers. It should be used
36  * by protocols.
37  */

38 public interface UnMarshaller {
39
40    /**
41     * Reads a byte.
42     *
43     * @return a byte.
44     * @exception JonathanException if the format of the data is incompatible
45     * with the request.
46     */

47    byte readByte()
48       throws JonathanException;
49
50    /**
51     * Reads a boolean.
52     *
53     * @return a boolean.
54     * @exception JonathanException if the format of the data is incompatible
55     * with the request.
56     */

57    boolean readBoolean()
58       throws JonathanException;
59
60    /**
61     * Reads a 8 bits char.
62     *
63     * @return a char.
64     * @exception JonathanException if the format of the data is incompatible
65     * with the request.
66     */

67    char readChar8()
68       throws JonathanException;
69
70    /**
71     * Reads a 16 bits char.
72     *
73     * @return a char.
74     * @exception JonathanException if the format of the data is incompatible
75     * with the request.
76     */

77    char readChar16()
78       throws JonathanException;
79
80    /**
81     * Reads a short.
82     *
83     * @return a short.
84     * @exception JonathanException if the format of the data is incompatible
85     * with the request.
86     */

87    short readShort()
88       throws JonathanException;
89
90    /**
91     * Reads an int.
92     *
93     * @return an int.
94     * @exception JonathanException if the format of the data is incompatible
95     * with the request.
96     */

97    int readInt()
98       throws JonathanException;
99
100    /**
101     * Reads a long.
102     *
103     * @return a long.
104     * @exception JonathanException if the format of the data is incompatible
105     * with the request.
106     */

107    long readLong()
108       throws JonathanException;
109
110    /**
111     * Reads a float.
112     *
113     * @return a float.
114     * @exception JonathanException if the format of the data is incompatible
115     * with the request.
116     */

117    float readFloat()
118       throws JonathanException;
119
120    /**
121     * Reads a double.
122     *
123     * @return a double.
124     * @exception JonathanException if the format of the data is incompatible
125     * with the request.
126     */

127    double readDouble()
128       throws JonathanException;
129
130    /**
131     * Reads a string composed of 8 bits chars.
132     *
133     * @return a string.
134     * @exception JonathanException if the format of the data is incompatible
135     * with the request.
136     */

137    String JavaDoc readString8()
138       throws JonathanException;
139    
140    /**
141     * Reads a string composed of 16 bits chars.
142     *
143     * @return a string.
144     * @exception JonathanException if the format of the data is incompatible
145     * with the request.
146     */

147    String JavaDoc readString16()
148       throws JonathanException;
149
150
151    /**
152     * Reads a reference to an object.
153     *
154     * @return a reference to an object.
155     * @exception JonathanException if the format of the data is incompatible
156     * with the request.
157     */

158    Object JavaDoc readReference() throws JonathanException;
159    
160    /**
161     * Reads a value
162     *
163     * @return an object representing the read value
164     * @exception JonathanException if the format of the data is incompatible
165     * with the request.
166     */

167    Object JavaDoc readValue() throws JonathanException;
168    
169    /**
170     * Reads an array of bytes.
171     *
172     * @param array a byte array (of size >= offset + len)
173     * @param offset the position (in array) of the first byte to write
174     * @param len the total number of bytes to read;
175     * @exception JonathanException if the format of the data is incompatible
176     * with the request.
177     */

178    void readByteArray(byte[] array, int offset, int len)
179       throws JonathanException;
180
181    /**
182     * Returns an input stream to read data from the unmarshaller.
183     *
184     * Closing the returned input stream has the same effect as closing the actual
185     * unmarshaller.
186     *
187     * @return an input stream to read from the unmarshaller.
188     */

189    InputStream JavaDoc inputStream();
190
191
192    /**
193     * Returns true if this unmarshaller is little-endian, false otherwise.
194     *
195     * @return true if this unmarshaller is little-endian, false otherwise.
196     */

197    boolean isLittleEndian();
198
199
200    /**
201     * Sets the byte order (returned by {@link #isLittleEndian() isLittleEndian}) of
202     * the target unmarshaller
203     *
204     * @param little_endian the new byte order.
205     */

206    void setByteOrder(boolean little_endian);
207
208
209    /**
210     * Returns the number of bytes read since the beginning.
211     *
212     * @return the number of bytes read since the beginning.
213     */

214    int bytesRead();
215
216    /**
217     * Sets the number of bytes readable from the unmarshaller.
218     * <p>
219     * Once this method has been called, it won't be possible to read more than the
220     * <code>size</code> specified bytes from this unmarshaller. Knowing the exact
221     * number of readable bytes lets the unmarshaller free the resources (such as
222     * a chunk provider) that won't be used. This method may block until the
223     * expected number of bytes is readable.
224     *
225     * @param size the expected number of readable bytes.
226     * @exception JonathanException if something goes wrong.
227     */

228    void setSize(int size) throws JonathanException;
229
230    /**
231     * Closes the target unmarshaller, releasing all underlying resources
232     * (including a possible chunk provider).
233     */

234    void close();
235
236    /**
237     * Returns a {@link Context Context} associated with this unmarshaller.
238     * @return a {@link Context Context} associated with this unmarshaller.
239     */

240    Context getContext();
241 }
242
243
244
245
Popular Tags