|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectedu.iris.Fissures.seed.director.ReadBuffer
public class ReadBuffer
This class is a generic file read buffer that takes on the
task of keeping a full byte array buffer available for Director
classes to extract from.
This class can be used for any file format.
This class does not perform the tasks of determining
record lengths or verification of the records it is reading in.
What it does is fill the buffer to its initialized capacity, which should be
the maximum possible logical record length, or even the
maximum possible physical record length of the volume.
Outside routines will examine the buffer and decide where to stop reading,
whether it is at the edge of a logical record, or otherwise.
When a portion of the buffer has been read, this class can be told to shift
the data by that amount to allow space for more data to be read in.
A good recommendation is to make the buffer size two times the expected
logical record length.
Field Summary | |
---|---|
protected byte[] |
buffer
Buffer holding the data from the input stream |
static int |
defaultBufSize
Default buffer capacity (32768) |
Constructor Summary | |
---|---|
ReadBuffer()
A default buffer size will be used here (defaultBufSize). |
|
ReadBuffer(int bufSize)
Create a ReadBuffer with the specified buffer size. |
Method Summary | |
---|---|
int |
bufSize()
Return the size of the buffer. |
void |
fill(java.io.DataInputStream inStream)
Fill the empty space of the buffer with new data |
int |
length()
Return the current length of data present. |
boolean |
reachedEOF()
Return true if the input stream is at EOF |
void |
shift(int amount)
Left-shift the data in the buffer by a certain number of bytes to make room for new incoming data |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected byte[] buffer
public static final int defaultBufSize
Constructor Detail |
---|
public ReadBuffer(int bufSize)
bufSize
- buffer size in bytespublic ReadBuffer()
Method Detail |
---|
public int length()
public int bufSize()
public void fill(java.io.DataInputStream inStream) throws SeedException, java.io.IOException
inStream
- input stream to fill the buffer with
SeedInputException
- if bufSize is less than dataLength
java.io.IOException
SeedException
public void shift(int amount)
amount
- number of bytes to shift the buffer bypublic boolean reachedEOF()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |