org.apache.jackrabbit.core.data.db
Class DbInputStream

java.lang.Object
  extended by java.io.InputStream
      extended by java.io.FilterInputStream
          extended by org.apache.commons.io.input.ProxyInputStream
              extended by org.apache.commons.io.input.AutoCloseInputStream
                  extended by org.apache.jackrabbit.core.data.db.DbInputStream
All Implemented Interfaces:
Closeable

public class DbInputStream
extends org.apache.commons.io.input.AutoCloseInputStream

This class represents an input stream backed by a database. The database objects are only acquired when reading from the stream, and stay open until the stream is closed, fully read, or garbage collected.

This class does not support mark/reset. It is always to be wrapped using a BufferedInputStream.


Field Summary
protected  boolean endOfStream
           
protected  DataIdentifier identifier
           
protected  ResultSet rs
           
protected  DbDataStore store
           
 
Fields inherited from class java.io.FilterInputStream
in
 
Constructor Summary
protected DbInputStream(DbDataStore store, DataIdentifier identifier)
          Create a database input stream for the given identifier.
 
Method Summary
 int available()
          
 void close()
           When the stream is consumed, the database objects held by the instance are closed.
 void mark(int readlimit)
          This method does nothing.
 boolean markSupported()
          Check whether mark and reset are supported.
protected  void openStream()
          Open the stream if required.
 int read()
           When the stream is consumed, the database objects held by the instance are closed.
 int read(byte[] b)
           When the stream is consumed, the database objects held by the instance are closed.
 int read(byte[] b, int off, int len)
           When the stream is consumed, the database objects held by the instance are closed.
 void reset()
          This method does nothing.
 long skip(long n)
          
 
Methods inherited from class org.apache.commons.io.input.AutoCloseInputStream
finalize
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

store

protected DbDataStore store

identifier

protected DataIdentifier identifier

endOfStream

protected boolean endOfStream

rs

protected ResultSet rs
Constructor Detail

DbInputStream

protected DbInputStream(DbDataStore store,
                        DataIdentifier identifier)
Create a database input stream for the given identifier. Database access is delayed until the first byte is read from the stream.

Parameters:
store - the database data store
identifier - the data identifier
Method Detail

openStream

protected void openStream()
                   throws IOException
Open the stream if required.

Throws:
IOException

read

public int read()
         throws IOException
When the stream is consumed, the database objects held by the instance are closed.

Overrides:
read in class org.apache.commons.io.input.AutoCloseInputStream
Throws:
IOException

read

public int read(byte[] b)
         throws IOException
When the stream is consumed, the database objects held by the instance are closed.

Overrides:
read in class org.apache.commons.io.input.AutoCloseInputStream
Throws:
IOException

read

public int read(byte[] b,
                int off,
                int len)
         throws IOException
When the stream is consumed, the database objects held by the instance are closed.

Overrides:
read in class org.apache.commons.io.input.AutoCloseInputStream
Throws:
IOException

close

public void close()
           throws IOException
When the stream is consumed, the database objects held by the instance are closed.

Specified by:
close in interface Closeable
Overrides:
close in class org.apache.commons.io.input.AutoCloseInputStream
Throws:
IOException

skip

public long skip(long n)
          throws IOException

Overrides:
skip in class org.apache.commons.io.input.ProxyInputStream
Throws:
IOException

available

public int available()
              throws IOException

Overrides:
available in class org.apache.commons.io.input.ProxyInputStream
Throws:
IOException

mark

public void mark(int readlimit)
This method does nothing.

Overrides:
mark in class org.apache.commons.io.input.ProxyInputStream

reset

public void reset()
           throws IOException
This method does nothing.

Overrides:
reset in class org.apache.commons.io.input.ProxyInputStream
Throws:
IOException

markSupported

public boolean markSupported()
Check whether mark and reset are supported.

Overrides:
markSupported in class org.apache.commons.io.input.ProxyInputStream
Returns:
false


Copyright © 2004-2010 The Apache Software Foundation. All Rights Reserved.