|
TrueZIP 6.8.3 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectde.schlichtherle.io.rof.AbstractReadOnlyFile
de.schlichtherle.io.rof.FilterReadOnlyFile
de.schlichtherle.io.rof.BufferedReadOnlyFile
public class BufferedReadOnlyFile
A ReadOnlyFile implementation which provides buffered random read
only access to another ReadOnlyFile.
Note: This class implements its own virtual file pointer.
Thus, if you would like to access the underlying ReadOnlyFile
again after you have finished working with an instance of this class,
you should synchronize their file pointers using the pattern as described
in FilterReadOnlyFile.
| Field Summary | |
|---|---|
private boolean |
closed
|
private long |
fp
The virtual file pointer in the file data. |
private long |
length
|
private byte[] |
window
The buffer window to the file data. |
static int |
WINDOW_LEN
The default buffer length of the window to the file. |
private long |
windowOff
The current offset in the read only file where the buffer window starts. |
| Fields inherited from class de.schlichtherle.io.rof.FilterReadOnlyFile |
|---|
rof |
| Constructor Summary | |
|---|---|
|
BufferedReadOnlyFile(File file)
Creates a new instance of BufferedReadOnlyFile. |
|
BufferedReadOnlyFile(File file,
int windowLen)
Creates a new instance of BufferedReadOnlyFile. |
|
BufferedReadOnlyFile(ReadOnlyFile rof)
Creates a new instance of BufferedReadOnlyFile. |
private |
BufferedReadOnlyFile(ReadOnlyFile rof,
File file,
int windowLen)
|
|
BufferedReadOnlyFile(ReadOnlyFile rof,
int windowLen)
Creates a new instance of BufferedReadOnlyFile. |
| Method Summary | |
|---|---|
void |
close()
Closes this read only file. |
protected ReadOnlyFile |
createReadOnlyFile(File file)
A factory method called by the constructor to get a read only file to access the contents of the read only file. |
private void |
ensureOpen()
Ensures that this file is open. |
long |
getFilePointer()
|
private void |
invalidateWindow()
Forces the window to be reloaded on the next call to positionWindow(). |
long |
length()
|
protected static long |
max(long a,
long b)
Returns the greater parameter. |
protected static long |
min(long a,
long b)
Returns the smaller parameter. |
private void |
positionWindow()
Ensures that the window is positioned so that the block containing the current virtual file pointer in the encrypted file is entirely contained in it. |
int |
read()
|
int |
read(byte[] buf,
int off,
int len)
Reads up to len bytes of data from this read only file into
the given array. |
void |
seek(long fp)
Sets the file pointer offset, measured from the beginning of this file, at which the next read occurs. |
| Methods inherited from class de.schlichtherle.io.rof.AbstractReadOnlyFile |
|---|
read, readFully, readFully, skipBytes |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final int WINDOW_LEN
private long length
private long fp
private long windowOff
private final byte[] window
private boolean closed
| Constructor Detail |
|---|
public BufferedReadOnlyFile(File file)
throws NullPointerException,
FileNotFoundException,
IOException
BufferedReadOnlyFile.
file - The file to read.
NullPointerException - If any of the parameters is null.
FileNotFoundException - If the file cannot get opened for reading.
IOException - On any other I/O related issue.
public BufferedReadOnlyFile(File file,
int windowLen)
throws NullPointerException,
FileNotFoundException,
IOException
BufferedReadOnlyFile.
file - The file to read.windowLen - The size of the buffer window in bytes.
NullPointerException - If any of the parameters is null.
FileNotFoundException - If the file cannot get opened for reading.
IOException - On any other I/O related issue.
public BufferedReadOnlyFile(ReadOnlyFile rof)
throws NullPointerException,
FileNotFoundException,
IOException
BufferedReadOnlyFile.
rof - The read only file to read.
NullPointerException - If any of the parameters is null.
FileNotFoundException - If the file cannot get opened for reading.
IOException - On any other I/O related issue.
public BufferedReadOnlyFile(ReadOnlyFile rof,
int windowLen)
throws NullPointerException,
FileNotFoundException,
IOException
BufferedReadOnlyFile.
rof - The read only file to read.windowLen - The size of the buffer window in bytes.
NullPointerException - If any of the parameters is null.
FileNotFoundException - If the file cannot get opened for reading.
IOException - On any other I/O related issue.
private BufferedReadOnlyFile(ReadOnlyFile rof,
File file,
int windowLen)
throws NullPointerException,
FileNotFoundException,
IOException
NullPointerException
FileNotFoundException
IOException| Method Detail |
|---|
protected static final long min(long a,
long b)
protected static final long max(long a,
long b)
protected ReadOnlyFile createReadOnlyFile(File file)
throws IOException
FileNotFoundException - If the file cannot get opened for reading.
IOException - On any other I/O related issue.
public long length()
throws IOException
length in interface ReadOnlyFilelength in class FilterReadOnlyFileIOException
public long getFilePointer()
throws IOException
getFilePointer in interface ReadOnlyFilegetFilePointer in class FilterReadOnlyFileIOException
public void seek(long fp)
throws IOException
ReadOnlyFileSimpleReadOnlyFile subclasses
RandomAccessFile and passes "r" as a
parameter to the superclass constructor.
On the Windows platform, this implementation allows to seek past the
end of file, but on the Linux platform it doesn't.
seek in interface ReadOnlyFileseek in class FilterReadOnlyFilefp - The offset position, measured in bytes from the beginning
of the file, at which to set the file pointer.
IOException - If pos is less than 0 or if
an I/O error occurs.
public int read()
throws IOException
read in interface ReadOnlyFileread in class FilterReadOnlyFileIOException
public int read(byte[] buf,
int off,
int len)
throws IOException
ReadOnlyFilelen bytes of data from this read only file into
the given array.
This method blocks until at least one byte of input is available.
read in interface ReadOnlyFileread in class FilterReadOnlyFilebuf - The buffer to fill with data.off - The start offset of the data.len - The maximum number of bytes to read.
-1 if there is
no more data because the end of the file has been reached.
IOException - On any I/O related issue.
public void close()
throws IOException
FilterReadOnlyFile.rof to null.
close in interface ReadOnlyFileclose in class FilterReadOnlyFileIOException
private final void ensureOpen()
throws IOException
IOException - If the preconditions do not hold.
private void positionWindow()
throws IOException
IOException - On any I/O related issue.
The window is invalidated in this case.private final void invalidateWindow()
positionWindow().
|
TrueZIP 6.8.3 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||