KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > pdfbox > io > RandomAccess


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

31 package org.pdfbox.io;
32
33 import java.io.IOException JavaDoc;
34
35 /**
36  * An interface to allow PDF files to be stored completely in memory or
37  * to use a scratch file on the disk.
38  *
39  * @author <a HREF="mailto:ben@benlitchfield.com">Ben Litchfield</a>
40  * @version $Revision: 1.2 $
41  */

42 public interface RandomAccess
43 {
44
45     /**
46      * Release resources that are being held.
47      *
48      * @throws IOException If there is an error closing this resource.
49      */

50     public void close() throws IOException JavaDoc;
51
52     /**
53      * Seek to a position in the data.
54      *
55      * @param position The position to seek to.
56      * @throws IOException If there is an error while seeking.
57      */

58     public void seek(long position) throws IOException JavaDoc;
59
60     /**
61      * Read a single byte of data.
62      *
63      * @return The byte of data that is being read.
64      *
65      * @throws IOException If there is an error while reading the data.
66      */

67     public int read() throws IOException JavaDoc;
68
69     /**
70      * Read a buffer of data.
71      *
72      * @param b The buffer to write the data to.
73      * @param offset Offset into the buffer to start writing.
74      * @param length The amount of data to attempt to read.
75      * @return The number of bytes that were actually read.
76      * @throws IOException If there was an error while reading the data.
77      */

78     public int read(byte[] b, int offset, int length) throws IOException JavaDoc;
79
80     /**
81      * The total number of bytes that are available.
82      *
83      * @return The number of bytes available.
84      *
85      * @throws IOException If there is an IO error while determining the
86      * length of the data stream.
87      */

88     public long length() throws IOException JavaDoc;
89
90     /**
91      * Write a byte to the stream.
92      *
93      * @param b The byte to write.
94      * @throws IOException If there is an IO error while writing.
95      */

96     public void write(int b) throws IOException JavaDoc;
97
98     /**
99      * Write a buffer of data to the stream.
100      *
101      * @param b The buffer to get the data from.
102      * @param offset An offset into the buffer to get the data from.
103      * @param length The length of data to write.
104      * @throws IOException If there is an error while writing the data.
105      */

106     public void write(byte[] b, int offset, int length) throws IOException JavaDoc;
107
108 }
Popular Tags