Class AbstractCachedSeekableStream
java.lang.Object
java.io.InputStream
com.twelvemonkeys.io.SeekableInputStream
com.twelvemonkeys.io.AbstractCachedSeekableStream
- All Implemented Interfaces:
Seekable, Closeable, AutoCloseable
- Direct Known Subclasses:
FileCacheSeekableStream, MemoryCacheSeekableStream
Represents a cached seekable stream, that reads through a cache.
- Version:
- $Id: //depot/branches/personal/haraldk/twelvemonkeys/release-2/twelvemonkeys-core/src/main/java/com/twelvemonkeys/io/AbstractCachedSeekableStream.java#2 $
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static classAn abstract stream cache. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final InputStreamThe backing streamprotected longThe stream positon in the backing stream (stream)Fields inherited from class SeekableInputStream
closed, flushedPosition, markedPositions, position -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected -
Method Summary
Modifier and TypeMethodDescriptionintprotected voidprotected voidflushBeforeImpl(long pPosition) Discards the initial portion of the stream prior to the indicated postion.protected final AbstractCachedSeekableStream.StreamCachegetCache()final booleanisCached()Returns true if thisSeekablestream caches data itself in order to allow seeking backwards.abstract booleanReturns true if thisSeekablestream caches data itself in order to allow seeking backwards, and the cache is kept in a temporary file.abstract booleanReturns true if thisSeekablestream caches data itself in order to allow seeking backwards, and the cache is kept in main memory.intread()intread(byte[] pBytes, int pOffset, int pLength) protected voidseekImpl(long pPosition) protected final voidMethods inherited from class SeekableInputStream
checkOpen, close, finalize, flush, flushBefore, getFlushedPosition, getStreamPosition, mark, mark, markSupported, read, reset, seek, skipMethods inherited from class InputStream
nullInputStream, readAllBytes, readNBytes, readNBytes, skipNBytes, transferTo
-
Field Details
-
stream
The backing stream -
streamPosition
protected long streamPositionThe stream positon in the backing stream (stream) -
cache
-
-
Constructor Details
-
AbstractCachedSeekableStream
protected AbstractCachedSeekableStream(InputStream pStream, AbstractCachedSeekableStream.StreamCache pCache)
-
-
Method Details
-
getCache
-
available
- Overrides:
availablein classInputStream- Throws:
IOException
-
read
- Specified by:
readin classInputStream- Throws:
IOException
-
read
- Overrides:
readin classInputStream- Throws:
IOException
-
syncPosition
- Throws:
IOException
-
isCached
public final boolean isCached()Description copied from interface:SeekableReturns true if thisSeekablestream 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.- Returns:
trueif thisSeekablecaches data.- See Also:
-
isCachedMemory
public abstract boolean isCachedMemory()Description copied from interface:SeekableReturns true if thisSeekablestream 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.- Returns:
trueif thisSeekablecaches data in main memory.- See Also:
-
isCachedFile
public abstract boolean isCachedFile()Description copied from interface:SeekableReturns true if thisSeekablestream 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.- Returns:
trueif thisSeekablecaches data in a temporary file.- See Also:
-
seekImpl
- Specified by:
seekImplin classSeekableInputStream- Throws:
IOException
-
flushBeforeImpl
protected void flushBeforeImpl(long pPosition) Description copied from class:SeekableInputStreamDiscards the initial portion of the stream prior to the indicated postion.- Specified by:
flushBeforeImplin classSeekableInputStream- Parameters:
pPosition- the position to flush to- See Also:
-
closeImpl
- Specified by:
closeImplin classSeekableInputStream- Throws:
IOException
-