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

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

public class DbInputStream
extends java.io.InputStream

This class represents an input stream backed by a database. It allows the stream to be used by keeping the database objects open until the stream is closed. When the stream is finished or closed, then the database objects are freed.


Field Summary
protected  ConnectionRecoveryManager conn
           
protected  boolean endOfStream
           
protected  DataIdentifier identifier
           
protected  java.io.InputStream in
           
protected  java.sql.ResultSet rs
           
protected  DbDataStore store
           
 
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)
          
 boolean markSupported()
          
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()
          
 long skip(long n)
          
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

store

protected DbDataStore store

identifier

protected DataIdentifier identifier

endOfStream

protected boolean endOfStream

in

protected java.io.InputStream in

conn

protected ConnectionRecoveryManager conn

rs

protected java.sql.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 java.io.IOException
Open the stream if required.

Throws:
java.io.IOException

read

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

Specified by:
read in class java.io.InputStream
Throws:
java.io.IOException

read

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

Overrides:
read in class java.io.InputStream
Throws:
java.io.IOException

read

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

Overrides:
read in class java.io.InputStream
Throws:
java.io.IOException

close

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

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

skip

public long skip(long n)
          throws java.io.IOException

Overrides:
skip in class java.io.InputStream
Throws:
java.io.IOException

available

public int available()
              throws java.io.IOException

Overrides:
available in class java.io.InputStream
Throws:
java.io.IOException

mark

public void mark(int readlimit)

Overrides:
mark in class java.io.InputStream

reset

public void reset()
           throws java.io.IOException

Overrides:
reset in class java.io.InputStream
Throws:
java.io.IOException

markSupported

public boolean markSupported()

Overrides:
markSupported in class java.io.InputStream


Copyright © 2004-2011 Apache Software Foundation. All Rights Reserved.