public final class MemoryCacheSeekableStream extends SeekableInputStream
SeekableInputStream implementation that caches data in memory.
FileCacheSeekableStream| Modifier and Type | Class and Description |
|---|---|
static class |
AbstractCachedSeekableStream.StreamCache
An abstract stream cache.
|
| Modifier and Type | Field and Description |
|---|---|
protected InputStream |
stream
The backing stream
|
protected long |
streamPosition
The stream positon in the backing stream (stream)
|
markedPositions| Constructor and Description |
|---|
MemoryCacheSeekableStream(InputStream pStream)
Creates a
MemoryCacheSeekableStream, reading from the given
InputStream. |
| Modifier and Type | Method and Description |
|---|---|
int |
available() |
protected void |
closeImpl() |
protected void |
flushBeforeImpl(long pPosition)
Discards the initial portion of the stream prior to the indicated postion.
|
protected AbstractCachedSeekableStream.StreamCache |
getCache() |
boolean |
isCached()
Returns true if this
Seekable stream caches data itself in order
to allow seeking backwards. |
boolean |
isCachedFile()
Returns true if this
Seekable stream caches data itself in
order to allow seeking backwards, and the cache is kept in a
temporary file. |
boolean |
isCachedMemory()
Returns true if this
Seekable stream caches data itself in order
to allow seeking backwards, and the cache is kept in main memory. |
int |
read() |
int |
read(byte[] pBytes,
int pOffset,
int pLength) |
protected void |
seekImpl(long pPosition) |
protected void |
syncPosition() |
checkOpen, close, finalize, flush, flushBefore, getFlushedPosition, getStreamPosition, mark, mark, markSupported, read, reset, seek, skipprotected final InputStream stream
protected long streamPosition
public MemoryCacheSeekableStream(InputStream pStream)
MemoryCacheSeekableStream, reading from the given
InputStream. Data will be cached in memory.pStream - the InputStream to read from.public final boolean isCachedMemory()
SeekableSeekable stream caches data itself in order
to allow seeking backwards, and the cache is kept in main memory.
Applications may consult this in order to decide how frequently, or
whether, to flush in order to conserve cache resources.isCachedMemory in interface Seekabletrue if this Seekable caches data in main
memory.Seekable.isCached(),
Seekable.isCachedFile()public final boolean isCachedFile()
SeekableSeekable stream caches data itself in
order to allow seeking backwards, and the cache is kept in a
temporary file.
Applications may consult this in order to decide how frequently,
or whether, to flush in order to conserve cache resources.isCachedFile in interface Seekabletrue if this Seekable caches data in a
temporary file.Seekable.isCached(),
Seekable.isCachedMemory()protected final AbstractCachedSeekableStream.StreamCache getCache()
public int available()
throws IOException
available in class InputStreamIOExceptionpublic int read()
throws IOException
read in class InputStreamIOExceptionpublic int read(byte[] pBytes,
int pOffset,
int pLength)
throws IOException
read in class InputStreamIOExceptionprotected final void syncPosition()
throws IOException
IOExceptionpublic final boolean isCached()
SeekableSeekable stream caches data itself in order
to allow seeking backwards. Applications may consult this in order to
decide how frequently, or whether, to flush in order to conserve cache
resources.true if this Seekable caches data.Seekable.isCachedMemory(),
Seekable.isCachedFile()protected void seekImpl(long pPosition)
throws IOException
seekImpl in class SeekableInputStreamIOExceptionprotected void flushBeforeImpl(long pPosition)
SeekableInputStreamflushBeforeImpl in class SeekableInputStreampPosition - the position to flush toSeekableInputStream.flushBefore(long)protected void closeImpl()
throws IOException
closeImpl in class SeekableInputStreamIOExceptionCopyright © 2017. All Rights Reserved.