com.levigo.jadice.document.io
Class UncloseableSeekableInputStream

java.lang.Object
  extended by java.io.InputStream
      extended by com.levigo.jadice.document.io.SeekableInputStream
          extended by com.levigo.jadice.document.io.UncloseableSeekableInputStream
All Implemented Interfaces:
Closeable, DataInput, ImageInputStream

public class UncloseableSeekableInputStream
extends SeekableInputStream

A SeekableInputStream implementation which ignores any calls of the close() method and delegates everything else to its delegate stream.


Field Summary
 
Fields inherited from class com.levigo.jadice.document.io.SeekableInputStream
bitOffset, byteOrder, flushedPos
 
Constructor Summary
UncloseableSeekableInputStream(SeekableInputStream delegate)
           
 
Method Summary
 void close()
          Closes this seekable input stream.
 void flushBefore(long pos)
           
 int getBitOffset()
           
 ByteOrder getByteOrder()
           
 long getFlushedPosition()
           
 long getSizeEstimate()
          A rough estimated size for this stream instance, which is used for internal cache management.
 long getStreamPosition()
           
 boolean isCached()
          Default implementation returns false.
 boolean isCachedFile()
          Default implementation returns false.
 boolean isCachedMemory()
          Default implementation returns false.
 long length()
          Returns the length of this stream contents, if available.
 void mark()
          Pushes the current stream position onto a stack of marked positions.
 int read()
          Reads a single byte from the stream and returns it as an int between 0 and 255.
 int read(byte[] b, int off, int len)
          Reads up to len bytes from the stream, and stores them into b starting at index off.
 void reset()
          Resets the current stream byte and bit positions from the stack of marked positions.
 void resetToInitialState()
          Resets the current stream byte, bit positions from the stack of marked positions, the flushed position and seeks to 0.
 void seek(long pos)
          Sets the current stream position, measured from the beginning of this data stream, at which the next read occurs.
 void setBitOffset(int bitOffset)
           
 void setByteOrder(ByteOrder byteOrder)
           
 
Methods inherited from class com.levigo.jadice.document.io.SeekableInputStream
checkClosed, finalize, flush, mark, read, readBit, readBits, readBoolean, readByte, readBytes, readChar, readDouble, readFloat, readFully, readFully, readFully, readFully, readFully, readFully, readFully, readFully, readInt, readInt, readLine, readLong, readShort, readUnsignedByte, readUnsignedInt, readUnsignedInt, readUnsignedShort, readUTF, skip, skipBytes, skipBytes
 
Methods inherited from class java.io.InputStream
available, markSupported
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

UncloseableSeekableInputStream

public UncloseableSeekableInputStream(SeekableInputStream delegate)
Method Detail

close

public void close()
           throws IOException
Description copied from class: SeekableInputStream
Closes this seekable input stream. Further attempts to read from it will throw IOExceptions. Additional attempts to SeekableInputStream.close(), however, have no effect.

Specified by:
close in interface Closeable
Specified by:
close in interface ImageInputStream
Overrides:
close in class SeekableInputStream
Throws:
IOException
See Also:
InputStream.close()

getStreamPosition

public long getStreamPosition()
                       throws IOException
Throws:
IOException

getSizeEstimate

public long getSizeEstimate()
Description copied from class: SeekableInputStream
A rough estimated size for this stream instance, which is used for internal cache management.

Specified by:
getSizeEstimate in class SeekableInputStream
Returns:
an estimated size

length

public long length()
            throws IOException
Description copied from class: SeekableInputStream
Returns the length of this stream contents, if available. Otherwise -1L will be returned.

Specified by:
length in interface ImageInputStream
Specified by:
length in class SeekableInputStream
Returns:
the length, measured in bytes or -1L if unknown.
Throws:
IOException - if an I/O error occurs.

read

public int read()
         throws IOException
Description copied from class: SeekableInputStream
Reads a single byte from the stream and returns it as an int between 0 and 255. If EOF is reached, -1 is returned.

Subclasses must provide an implementation for this method. The subclass implementation should update the stream position before exiting.

The bit offset within the stream must be reset to zero before the read occurs.

Specified by:
read in interface ImageInputStream
Specified by:
read in class SeekableInputStream
Returns:
the value of the next byte in the stream, or -1 if EOF is reached.
Throws:
IOException - if the stream has been closed.

read

public int read(byte[] b,
                int off,
                int len)
         throws IOException
Description copied from class: SeekableInputStream
Reads up to len bytes from the stream, and stores them into b starting at index off. If no bytes can be read because the end of the stream has been reached, -1 is returned.

The bit offset within the stream must be reset to zero before the read occurs.

Subclasses must provide an implementation for this method. The subclass implementation should update the stream position before exiting.

Specified by:
read in interface ImageInputStream
Specified by:
read in class SeekableInputStream
Parameters:
b - an array of bytes to be written to.
off - the starting position within b to write to.
len - the maximum number of bytes to read.
Returns:
the number of bytes actually read, or -1 to indicate EOF.
Throws:
IOException - if an I/O error occurs.

seek

public void seek(long pos)
          throws IOException
Description copied from class: SeekableInputStream
Sets the current stream position, measured from the beginning of this data stream, at which the next read occurs. The offset may be set beyond the end of this data stream. Setting the offset beyond the end does not change the data length, an EOFException will be thrown only if a read is performed. The bit offset is set to 0.

An IndexOutOfBoundsException will be thrown if pos is smaller than the flushed position (as returned by getflushedPosition).

It is legal to seek past the end of the file; an EOFException will be thrown only if a read is performed.

Specified by:
seek in interface ImageInputStream
Specified by:
seek in class SeekableInputStream
Parameters:
pos - a long containing the desired file pointer position.
Throws:
IOException - if any other I/O error occurs.

setByteOrder

public void setByteOrder(ByteOrder byteOrder)
Specified by:
setByteOrder in interface ImageInputStream
Overrides:
setByteOrder in class SeekableInputStream
See Also:
ImageInputStream.setByteOrder(java.nio.ByteOrder)

getByteOrder

public ByteOrder getByteOrder()
Specified by:
getByteOrder in interface ImageInputStream
Overrides:
getByteOrder in class SeekableInputStream
See Also:
ImageInputStream.getByteOrder()

setBitOffset

public void setBitOffset(int bitOffset)
                  throws IOException
Specified by:
setBitOffset in interface ImageInputStream
Overrides:
setBitOffset in class SeekableInputStream
Throws:
IOException
See Also:
ImageInputStream.setBitOffset(int)

getBitOffset

public int getBitOffset()
                 throws IOException
Specified by:
getBitOffset in interface ImageInputStream
Overrides:
getBitOffset in class SeekableInputStream
Throws:
IOException
See Also:
ImageInputStream.getBitOffset()

reset

public void reset()
           throws IOException
Description copied from class: SeekableInputStream
Resets the current stream byte and bit positions from the stack of marked positions.

An IOException will be thrown if the previous marked position lies in the discarded portion of the stream.

Specified by:
reset in interface ImageInputStream
Overrides:
reset in class SeekableInputStream
Throws:
IOException - if an I/O error occurs.

resetToInitialState

public void resetToInitialState()
                         throws IOException
Description copied from class: SeekableInputStream
Resets the current stream byte, bit positions from the stack of marked positions, the flushed position and seeks to 0.

Overrides:
resetToInitialState in class SeekableInputStream
Throws:
IOException - if an I/O error occurs.

mark

public void mark()
Description copied from class: SeekableInputStream
Pushes the current stream position onto a stack of marked positions.

Specified by:
mark in interface ImageInputStream
Overrides:
mark in class SeekableInputStream

isCached

public boolean isCached()
Description copied from class: SeekableInputStream
Default implementation returns false. Subclasses should override this if they cache data.

Specified by:
isCached in interface ImageInputStream
Overrides:
isCached in class SeekableInputStream
See Also:
ImageInputStream.isCached()

isCachedFile

public boolean isCachedFile()
Description copied from class: SeekableInputStream
Default implementation returns false. Subclasses should override this if they cache data in a temporary file.

Specified by:
isCachedFile in interface ImageInputStream
Overrides:
isCachedFile in class SeekableInputStream
See Also:
ImageInputStream.isCachedFile()

isCachedMemory

public boolean isCachedMemory()
Description copied from class: SeekableInputStream
Default implementation returns false. Subclasses should override this if they cache data in main memory.

Specified by:
isCachedMemory in interface ImageInputStream
Overrides:
isCachedMemory in class SeekableInputStream
See Also:
ImageInputStream.isCachedMemory()

flushBefore

public void flushBefore(long pos)
                 throws IOException
Specified by:
flushBefore in interface ImageInputStream
Overrides:
flushBefore in class SeekableInputStream
Throws:
IOException
See Also:
ImageInputStream.flushBefore(long)

getFlushedPosition

public long getFlushedPosition()
Specified by:
getFlushedPosition in interface ImageInputStream
Overrides:
getFlushedPosition in class SeekableInputStream
See Also:
ImageInputStream.getFlushedPosition()


Copyright © 1995-2020 levigo holding gmbh. All Rights Reserved.