KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > imagero > uio > RandomAccessRO


1 /*
2  * Copyright (c) Andrey Kuznetsov. All Rights Reserved.
3  *
4  * http://uio.imagero.com
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions are met:
8  *
9  * o Redistributions of source code must retain the above copyright notice,
10  * this list of conditions and the following disclaimer.
11  *
12  * o Redistributions in binary form must reproduce the above copyright notice,
13  * this list of conditions and the following disclaimer in the documentation
14  * and/or other materials provided with the distribution.
15  *
16  * o Neither the name of imagero Andrei Kouznetsov nor the names of
17  * its contributors may be used to endorse or promote products derived
18  * from this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
22  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
24  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
27  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
29  * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
30  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  */

32 package com.imagero.uio;
33
34 import java.io.DataInput JavaDoc;
35 import java.io.IOException JavaDoc;
36
37 /**
38  * Interface for read only access to data.
39  * Allows unified read access to data - arrays, files, streams and many other.
40  *
41  * @author Andrei Kouznetsov
42  * <br>
43  * Date: 08.11.2003
44  * Time: 12:59:40
45  */

46 public interface RandomAccessRO extends Input, DataInput JavaDoc {
47     final int BIG_ENDIAN = 0x4D4D;
48     final int LITTLE_ENDIAN = 0x4949;
49
50     /**
51      * Since this is an interface and is not restricted to files, "getFilePointer" is wrong name for this method.
52      * But I leaved it so for easier porting from RandomAccessFile
53      *
54      * @return current cursor position
55      *
56      * @throws IOException
57      */

58     long getFilePointer() throws IOException JavaDoc;
59
60     /**
61      * get length of data
62      *
63      * @return data length (in bytes)
64      *
65      * @throws IOException
66      */

67     long length() throws IOException JavaDoc;
68
69     /**
70      * set current cursor position to specified <code>offset</code>
71      *
72      * @param offset new cursor position
73      *
74      * @throws IOException
75      */

76     void seek(long offset) throws IOException JavaDoc;
77
78     /**
79      * get byte order
80      *
81      * @return RandomAccessFactory.BIG_ENDIAN or RandomAccessFactory.LITTLE_ENDIAN
82      *
83      * @see RandomAccessFactory#BIG_ENDIAN
84      * @see RandomAccessFactory#LITTLE_ENDIAN
85      */

86     int getByteOrder();
87
88     /**
89      * set byte order
90      *
91      * @param byteOrder
92      *
93      * @throws IOException
94      * @see RandomAccessFactory#BIG_ENDIAN
95      * @see RandomAccessFactory#LITTLE_ENDIAN
96      */

97     void setByteOrder(int byteOrder) throws IOException JavaDoc;
98
99     /**
100      * read data into short array
101      *
102      * @param dest buffer to store data
103      *
104      * @throws IOException
105      */

106     void readFully(short[] dest) throws IOException JavaDoc;
107
108     /**
109      * read data into short array
110      *
111      * @param dest buffer to store data
112      * @param byteOrder byte order
113      *
114      * @throws IOException
115      */

116     void readFully(short[] dest, int byteOrder) throws IOException JavaDoc;
117
118     /**
119      * read data into short array
120      *
121      * @param dest buffer to store data
122      * @param destOffset offset in buffer
123      * @param len number of shorts to read
124      *
125      * @throws IOException
126      */

127     void readFully(short[] dest, int destOffset, int len) throws IOException JavaDoc;
128
129     /**
130      * read data into short array
131      *
132      * @param dest buffer to store data
133      * @param destOffset offset in buffer
134      * @param len number of shorts to read
135      * @param byteOrder byte order
136      *
137      * @throws IOException
138      */

139     void readFully(short[] dest, int destOffset, int len, int byteOrder) throws IOException JavaDoc;
140
141     /**
142      * read data into char array
143      *
144      * @param dest buffer to store data
145      *
146      * @throws IOException
147      */

148     void readFully(char[] dest) throws IOException JavaDoc;
149
150     /**
151      * read data into char array
152      *
153      * @param dest buffer to store data
154      * @param byteOrder byte order
155      *
156      * @throws IOException
157      */

158     void readFully(char[] dest, int byteOrder) throws IOException JavaDoc;
159
160     /**
161      * read data into char array
162      *
163      * @param dest buffer to store data
164      * @param destOffset offset in buffer
165      * @param len number of chars to read
166      *
167      * @throws IOException
168      */

169     void readFully(char[] dest, int destOffset, int len) throws IOException JavaDoc;
170
171     /**
172      * read data into char array
173      *
174      * @param dest buffer to store data
175      * @param destOffset offset in buffer
176      * @param len number of chars to read
177      * @param byteOrder byte order
178      *
179      * @throws IOException
180      */

181     void readFully(char[] dest, int destOffset, int len, int byteOrder) throws IOException JavaDoc;
182
183     /**
184      * read data into int array
185      *
186      * @param dest buffer to store data
187      *
188      * @throws IOException
189      */

190     void readFully(int[] dest) throws IOException JavaDoc;
191
192     /**
193      * read data into int array
194      *
195      * @param dest buffer to store data
196      * @param byteOrder byte order
197      *
198      * @throws IOException
199      */

200     void readFully(int[] dest, int byteOrder) throws IOException JavaDoc;
201
202     /**
203      * read data into int array
204      *
205      * @param dest buffer to store data
206      * @param destOffset offset in buffer
207      * @param len number of ints to read
208      *
209      * @throws IOException
210      */

211     void readFully(int[] dest, int destOffset, int len) throws IOException JavaDoc;
212
213     /**
214      * read data into int array
215      *
216      * @param dest buffer to store data
217      * @param destOffset offset in buffer
218      * @param len number of ints to read
219      * @param byteOrder byte order
220      *
221      * @throws IOException
222      */

223     void readFully(int[] dest, int destOffset, int len, int byteOrder) throws IOException JavaDoc;
224
225     /**
226      * read data into long array
227      *
228      * @param dest buffer to store data
229      *
230      * @throws IOException
231      */

232     void readFully(long[] dest) throws IOException JavaDoc;
233
234     /**
235      * read data into long array
236      *
237      * @param dest buffer to store data
238      * @param byteOrder byte order
239      *
240      * @throws IOException
241      */

242     void readFully(long[] dest, int byteOrder) throws IOException JavaDoc;
243
244     /**
245      * read data into long array
246      *
247      * @param dest buffer to store data
248      * @param destOffset offset in buffer
249      * @param len number of longs to read
250      *
251      * @throws IOException
252      */

253     void readFully(long[] dest, int destOffset, int len) throws IOException JavaDoc;
254
255     /**
256      * read data into long array
257      *
258      * @param dest buffer to store data
259      * @param destOffset offset in buffer
260      * @param len number of longs to read
261      * @param byteOrder byte order
262      *
263      * @throws IOException
264      */

265     void readFully(long[] dest, int destOffset, int len, int byteOrder) throws IOException JavaDoc;
266
267     /**
268      * read data into float array
269      *
270      * @param dest buffer to store data
271      *
272      * @throws IOException
273      */

274     void readFully(float[] dest) throws IOException JavaDoc;
275
276     /**
277      * read data into float array
278      *
279      * @param dest buffer to store data
280      * @param byteOrder byte order
281      *
282      * @throws IOException
283      */

284     void readFully(float[] dest, int byteOrder) throws IOException JavaDoc;
285
286     /**
287      * read data into float array
288      *
289      * @param dest buffer to store data
290      * @param destOffset offset in buffer
291      * @param len number of floats to read
292      *
293      * @throws IOException
294      */

295     void readFully(float[] dest, int destOffset, int len) throws IOException JavaDoc;
296
297     /**
298      * read data into float array
299      *
300      * @param dest buffer to store data
301      * @param destOffset offset in buffer
302      * @param len number of floats to read
303      * @param byteOrder byte order
304      *
305      * @throws IOException
306      */

307     void readFully(float[] dest, int destOffset, int len, int byteOrder) throws IOException JavaDoc;
308
309     /**
310      * read data into double array
311      *
312      * @param dest buffer to store data
313      *
314      * @throws IOException
315      */

316     void readFully(double[] dest) throws IOException JavaDoc;
317
318     /**
319      * read data into double array
320      *
321      * @param dest buffer to store data
322      * @param byteOrder byte order
323      *
324      * @throws IOException
325      */

326     void readFully(double[] dest, int byteOrder) throws IOException JavaDoc;
327
328     /**
329      * read data into double array
330      *
331      * @param dest buffer to store data
332      * @param destOffset offset in buffer
333      * @param len number of doubles to read
334      *
335      * @throws IOException
336      */

337     void readFully(double[] dest, int destOffset, int len) throws IOException JavaDoc;
338
339     /**
340      * read data into double array
341      *
342      * @param dest buffer to store data
343      * @param destOffset offset in buffer
344      * @param len number of doubles to read
345      * @param byteOrder byte order
346      *
347      * @throws IOException
348      */

349     void readFully(double[] dest, int destOffset, int len, int byteOrder) throws IOException JavaDoc;
350
351     /**
352      * like readLine but returns byte array
353      * @return byte array
354      */

355     byte [] readByteLine() throws IOException JavaDoc;
356 }
357
Popular Tags