com.intersys.objects
Class CacheInputStream

java.lang.Object
  extended byjava.io.InputStream
      extended bycom.intersys.objects.CacheInputStream
All Implemented Interfaces:
Serializable

public class CacheInputStream
extends InputStream
implements Serializable

A CacheInputStream obtains input bytes from a Cache Database. Usually it is mapped to some global in Cache. This is a wrapper class around GlobalBinaryStream. Note, that if you use this wrapper class it is not reommended to use direct calls to GlobalBinaryStream.

See Also:
Class BinaryStream in Cache , GlobalBinaryStream, Serialized Form

Constructor Summary
CacheInputStream(BinaryStream stream)
           
 
Method Summary
 int available()
           
 void close()
           
 void mark(int readlimit)
          Marks the current position in this input stream.
 boolean markSupported()
           
 int read()
           
 int read(byte[] b, int off, int len)
           
 byte[] read(int len)
           
 void reset()
          Repositions this stream to the position at the time the mark method was last called on this input stream.
 void rewind()
          Rewinds stream, so the next byte will be the first byte stored in this Cache Stream (the first byte stored in global).
 void seek(long pos)
          Repositions this stream to the given position.
 long skip(long n)
          Skips over and discards n bytes of data from this input stream.
 long tell()
          Returns the current position in the stream.
 
Methods inherited from class java.io.InputStream
read
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CacheInputStream

public CacheInputStream(BinaryStream stream)
                 throws CacheException
Method Detail

read

public int read(byte[] b,
                int off,
                int len)
         throws IOException
Throws:
IOException

read

public int read()
         throws IOException
Throws:
IOException

rewind

public void rewind()
            throws CacheException
Rewinds stream, so the next byte will be the first byte stored in this Cache Stream (the first byte stored in global).

Throws:
CacheException

tell

public long tell()
Returns the current position in the stream.

Note, this method works only if all calls to the underlying GlobalBinaryStream goes through this CacheInputStream object.

Returns:
Current position in Cache Stream.
See Also:
seek(long), rewind(), mark(int), reset(), GlobalBinaryStream

markSupported

public boolean markSupported()

mark

public void mark(int readlimit)
Marks the current position in this input stream. A subsequent call to the reset method repositions this stream at the last marked position so that subsequent reads re-read the same bytes.

Note, this method works only if all calls to the underlying GlobalBinaryStream goes through this CacheInputStream object.

Parameters:
readlimit - Ignored.
See Also:
seek(long), rewind(), tell(), reset()

reset

public void reset()
           throws IOException
Repositions this stream to the position at the time the mark method was last called on this input stream.

Note, this method works only if all calls to the underlying GlobalBinaryStream goes through this CacheInputStream object.

Throws:
IOException
See Also:
mark(int), seek(long), rewind(), tell()

seek

public void seek(long pos)
          throws IOException
Repositions this stream to the given position.

Note, this method works only if all calls to the underlying GlobalBinaryStream goes through this CacheInputStream object.

Parameters:
pos - New postition for the stream.
Throws:
IOException
See Also:
mark(int), seek(long), rewind(), tell()

skip

public long skip(long n)
          throws IOException
Skips over and discards n bytes of data from this input stream. The skip method may, for a variety of reasons, end up skipping over some smaller number of bytes, possibly 0. This may result from any of a number of conditions; reaching end of file before n bytes have been skipped is only one possibility. The actual number of bytes skipped is returned. If n is negative, no bytes are skipped.

Parameters:
n - the number of bytes to be skipped.
Returns:
the actual number of bytes skipped.
Throws:
IOException - if an I/O error occurs.

read

public byte[] read(int len)
            throws IOException
Throws:
IOException

available

public int available()
              throws IOException
Throws:
IOException

close

public void close()
           throws IOException
Throws:
IOException