Class CompoundDocument.SeekableLittleEndianDataInputStream
- java.lang.Object
-
- java.io.InputStream
-
- java.io.FilterInputStream
-
- com.twelvemonkeys.io.LittleEndianDataInputStream
-
- com.twelvemonkeys.io.ole2.CompoundDocument.SeekableLittleEndianDataInputStream
-
- All Implemented Interfaces:
Seekable,java.io.Closeable,java.io.DataInput,java.lang.AutoCloseable
- Enclosing class:
- CompoundDocument
static class CompoundDocument.SeekableLittleEndianDataInputStream extends LittleEndianDataInputStream implements Seekable
-
-
Field Summary
Fields Modifier and Type Field Description private SeekableInputStreamseekable
-
Constructor Summary
Constructors Constructor Description SeekableLittleEndianDataInputStream(SeekableInputStream pInput)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidflush()Discards the initial position of the stream prior to the current stream position.voidflushBefore(long pPosition)Discards the initial portion of the stream prior to the indicated postion.longgetFlushedPosition()Returns the earliest position in the stream to which seeking may be performed.longgetStreamPosition()Returns the current byte position of the stream.booleanisCached()Returns true if thisSeekablestream caches data itself in order to allow seeking backwards.booleanisCachedFile()Returns true if thisSeekablestream caches data itself in order to allow seeking backwards, and the cache is kept in a temporary file.booleanisCachedMemory()Returns true if thisSeekablestream caches data itself in order to allow seeking backwards, and the cache is kept in main memory.voidmark()Marks a position in the stream to be returned to by a subsequent call to reset.voidreset()Returns the file pointer to its previous position, at the time of the most recent unmatched call to mark.voidseek(long pPosition)Sets the current stream position to the desired location.-
Methods inherited from class com.twelvemonkeys.io.LittleEndianDataInputStream
readBoolean, readByte, readChar, readDouble, readFloat, readFully, readFully, readInt, readLine, readLong, readShort, readUnsignedByte, readUnsignedShort, readUTF, skipBytes
-
Methods inherited from class java.io.FilterInputStream
available, close, mark, markSupported, read, read, read, skip
-
Methods inherited from class java.io.InputStream
nullInputStream, readAllBytes, readNBytes, readNBytes, transferTo
-
-
-
-
Field Detail
-
seekable
private final SeekableInputStream seekable
-
-
Constructor Detail
-
SeekableLittleEndianDataInputStream
public SeekableLittleEndianDataInputStream(SeekableInputStream pInput)
-
-
Method Detail
-
seek
public void seek(long pPosition) throws java.io.IOExceptionDescription copied from interface:SeekableSets the current stream position to the desired location. The next read will occur at this location.An
IndexOutOfBoundsExceptionwill be thrown if pPosition is smaller than the flushed position (as returned bySeekable.getFlushedPosition()).It is legal to seek past the end of the file; an
EOFExceptionwill be thrown only if a read is performed.
-
isCachedFile
public 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.- Specified by:
isCachedFilein interfaceSeekable- Returns:
trueif thisSeekablecaches data in a temporary file.- See Also:
Seekable.isCached(),Seekable.isCachedMemory()
-
isCachedMemory
public 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.- Specified by:
isCachedMemoryin interfaceSeekable- Returns:
trueif thisSeekablecaches data in main memory.- See Also:
Seekable.isCached(),Seekable.isCachedFile()
-
isCached
public 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.- Specified by:
isCachedin interfaceSeekable- Returns:
trueif thisSeekablecaches data.- See Also:
Seekable.isCachedMemory(),Seekable.isCachedFile()
-
getStreamPosition
public long getStreamPosition() throws java.io.IOExceptionDescription copied from interface:SeekableReturns the current byte position of the stream. The next read will take place starting at this offset.- Specified by:
getStreamPositionin interfaceSeekable- Returns:
- a
longcontaining the position of the stream. - Throws:
java.io.IOException- if an I/O error occurs.
-
getFlushedPosition
public long getFlushedPosition() throws java.io.IOExceptionDescription copied from interface:SeekableReturns the earliest position in the stream to which seeking may be performed. The returned value will be the maximum of all values passed into previous calls toflushBefore.- Specified by:
getFlushedPositionin interfaceSeekable- Returns:
- the earliest legal position for seeking, as a
long. - Throws:
java.io.IOException- if an I/O error occurs.
-
flushBefore
public void flushBefore(long pPosition) throws java.io.IOExceptionDescription copied from interface:SeekableDiscards the initial portion of the stream prior to the indicated postion. Attempting to seek to an offset within the flushed portion of the stream will result in anIndexOutOfBoundsException.Calling
flushBeforemay allow classes implementing this interface to free up resources such as memory or disk space that are being used to store data from the stream.- Specified by:
flushBeforein interfaceSeekable- Parameters:
pPosition- a long containing the length of the file prefix that may be flushed.- Throws:
java.io.IOException- if an I/O error occurs.
-
flush
public void flush() throws java.io.IOExceptionDescription copied from interface:SeekableDiscards the initial position of the stream prior to the current stream position. Equivalent toflushBefore(getStreamPosition()).
-
reset
public void reset() throws java.io.IOExceptionDescription copied from interface:SeekableReturns the file pointer to its previous position, at the time of the most recent unmatched call to mark.Calls to reset without a corresponding call to mark will either:
- throw an
IOException - or, reset to the beginning of the stream.
An
IOExceptionwill be thrown if the previous marked position lies in the discarded portion of the stream. - throw an
-
mark
public void mark()
Description copied from interface:SeekableMarks a position in the stream to be returned to by a subsequent call to reset. Unlike a standardInputStream, allSeekablestreams upport marking. Additionally, calls tomarkandresetmay be nested arbitrarily.Unlike the
markmethods declared by theReaderorInputStreaminterfaces, noreadLimitparameter is used. An arbitrary amount of data may be read following the call tomark.
-
-