Class AbstractBufferingStream
java.lang.Object
org.archive.streamcontext.AbstractBufferingStream
- All Implemented Interfaces:
Closeable,AutoCloseable,Stream
- Direct Known Subclasses:
ByteArrayWrappedStream,HDFSStream,HTTP11Stream,RandomAccessFileStream,SimpleStream
Class which implements the bulk of the functionality needed for Stream
behavior, leaving concrete subclasses to implement only 3 simple methods
beyond their constructors:
doSeek()
doRead()
doClose()
This class maintains a buffer of bytes read, and attempts to be efficient
about seeks within that buffer.
- Author:
- brad
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected booleanprotected byte[]protected intprotected intprotected booleanprotected static intprotected long -
Constructor Summary
ConstructorsConstructorDescriptionAbstractBufferingStream(long offset) AbstractBufferingStream(long offset, int readSize) -
Method Summary
-
Field Details
-
DEFAULT_READ_SIZE
protected static int DEFAULT_READ_SIZE -
offset
protected long offset -
closed
protected boolean closed -
atEof
protected boolean atEof -
buffer
protected byte[] buffer -
bufferRemaining
protected int bufferRemaining -
bufferCursor
protected int bufferCursor
-
-
Constructor Details
-
AbstractBufferingStream
public AbstractBufferingStream() -
AbstractBufferingStream
public AbstractBufferingStream(long offset) -
AbstractBufferingStream
public AbstractBufferingStream(long offset, int readSize)
-
-
Method Details
-
doRead
- Throws:
IOException
-
doSeek
- Throws:
IOException
-
doClose
- Throws:
IOException
-
atEof
-
getOffset
-
read
- Specified by:
readin interfaceStream- Throws:
IOException
-
setOffset
- Specified by:
setOffsetin interfaceStream- Throws:
IOException
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-