org.sqlite.io
Class InputStreamAdapter

java.lang.Object
  extended by java.io.InputStream
      extended by org.sqlite.io.InputStreamAdapter
All Implemented Interfaces:
java.io.Closeable
Direct Known Subclasses:
BlobInputStream, MemoryInputStream

public abstract class InputStreamAdapter
extends java.io.InputStream


Constructor Summary
InputStreamAdapter(Closeable owner, long len)
          default constructor.
 
Method Summary
 int available()
          Returns the number of bytes that can be read (or skipped over) from this input stream without blocking by the next caller of a method for this input stream.
 void close()
          Closes this stream.
 void mark(int readlimit)
          Marks the current position in this input stream.
Note: The readlimit for this class has no meaning.
 boolean markSupported()
          mark() supported.
 int read()
          Reads the next byte of data from the input stream.
 int read(byte[] b)
          Reads some number of bytes from the input stream and stores them into the buffer array b.
 int read(byte[] b, int off, int len)
          Reads up to len bytes of data from the input stream into an array of bytes.
protected abstract  void read(long pos, byte[] b, int off, int len)
           
 void reset()
          Repositions this stream to the position at the time the mark method was last called on this input stream.
 long skip(long n)
          Skips over and discards n bytes of data from this input stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

InputStreamAdapter

public InputStreamAdapter(Closeable owner,
                          long len)
default constructor.

Parameters:
owner - the owner Closeable object
len - the number of bytes
Method Detail

available

public int available()
              throws java.io.IOException
Returns the number of bytes that can be read (or skipped over) from this input stream without blocking by the next caller of a method for this input stream.

Overrides:
available in class java.io.InputStream
Returns:
the number of bytes that can be read from this input stream without blocking.
Throws:
java.io.IOException - When this method is called on a closed stream.

close

public void close()
Closes this stream.

Specified by:
close in interface java.io.Closeable
Overrides:
close in class java.io.InputStream

mark

public void mark(int readlimit)
Marks the current position in this input stream.
Note: The readlimit for this class has no meaning.

Overrides:
mark in class java.io.InputStream
Parameters:
readlimit - ignored

markSupported

public boolean markSupported()
mark() supported.

Overrides:
markSupported in class java.io.InputStream
Returns:
true

read

public int read()
         throws java.io.IOException
Reads the next byte of data from the input stream.

Specified by:
read in class java.io.InputStream
Returns:
the next byte of data, or -1 if the end of the stream is reached.
Throws:
java.io.IOException - When this method is called on a closed stream.

read

public int read(byte[] b)
         throws java.io.IOException
Reads some number of bytes from the input stream and stores them into the buffer array b.

Overrides:
read in class java.io.InputStream
Parameters:
b - the buffer into which the data is read.
Returns:
the total number of bytes read into the buffer, or -1 is there is no more data because the end of the stream has been reached.
Throws:
java.io.IOException - When this method is called on a closed stream.

read

public int read(byte[] b,
                int off,
                int len)
         throws java.io.IOException
Reads up to len bytes of data from the input stream into an array of bytes.

Overrides:
read in class java.io.InputStream
Parameters:
b - the buffer into which the data is read.
off - the start offset in array b at which the data is written.
len - the maximum number of bytes to read.
Returns:
the total number of bytes read into the buffer, or -1 if there is no more data because the end of the stream has been reached.
Throws:
java.io.IOException - When this method is called on a closed stream.

reset

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

Overrides:
reset in class java.io.InputStream
Throws:
java.io.IOException - When this method is called on a closed stream.

skip

public long skip(long n)
          throws java.io.IOException
Skips over and discards n bytes of data from this input stream.

Overrides:
skip in class java.io.InputStream
Parameters:
n - the number of bytes to be skipped.
Returns:
the actual number of bytes skipped.
Throws:
java.io.IOException - When this method is called on a closed stream.

read

protected abstract void read(long pos,
                             byte[] b,
                             int off,
                             int len)
                      throws java.io.IOException
Throws:
java.io.IOException