Class DbInputStream
- java.lang.Object
-
- java.io.InputStream
-
- java.io.FilterInputStream
-
- org.apache.commons.io.input.ProxyInputStream
-
- org.apache.commons.io.input.AutoCloseInputStream
-
- org.apache.jackrabbit.core.data.db.DbInputStream
-
- All Implemented Interfaces:
Closeable,AutoCloseable
public class DbInputStream extends org.apache.commons.io.input.AutoCloseInputStreamThis 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
Fields Modifier and Type Field Description protected booleanendOfStreamprotected DataIdentifieridentifierprotected ResultSetrsprotected DbDataStorestore-
Fields inherited from class java.io.FilterInputStream
in
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedDbInputStream(DbDataStore store, DataIdentifier identifier)Create a database input stream for the given identifier.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intavailable()voidclose()When the stream is consumed, the database objects held by the instance are closed.voidmark(int readlimit)This method does nothing.booleanmarkSupported()Check whether mark and reset are supported.protected voidopenStream()Open the stream if required.intread()When the stream is consumed, the database objects held by the instance are closed.intread(byte[] b)When the stream is consumed, the database objects held by the instance are closed.intread(byte[] b, int off, int len)When the stream is consumed, the database objects held by the instance are closed.voidreset()This method does nothing.longskip(long n)-
Methods inherited from class org.apache.commons.io.input.AutoCloseInputStream
afterRead, builder, finalize
-
Methods inherited from class org.apache.commons.io.input.ProxyInputStream
beforeRead, handleIOException, unwrap
-
Methods inherited from class java.io.InputStream
nullInputStream, readAllBytes, readNBytes, readNBytes, transferTo
-
-
-
-
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 storeidentifier- the data identifier
-
-
Method Detail
-
openStream
protected void openStream() throws IOExceptionOpen the stream if required.- Throws:
IOException
-
read
public int read() throws IOExceptionWhen the stream is consumed, the database objects held by the instance are closed.- Overrides:
readin classorg.apache.commons.io.input.ProxyInputStream- Throws:
IOException
-
read
public int read(byte[] b) throws IOExceptionWhen the stream is consumed, the database objects held by the instance are closed.- Overrides:
readin classorg.apache.commons.io.input.ProxyInputStream- Throws:
IOException
-
read
public int read(byte[] b, int off, int len) throws IOExceptionWhen the stream is consumed, the database objects held by the instance are closed.- Overrides:
readin classorg.apache.commons.io.input.ProxyInputStream- Throws:
IOException
-
close
public void close() throws IOExceptionWhen the stream is consumed, the database objects held by the instance are closed.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classorg.apache.commons.io.input.AutoCloseInputStream- Throws:
IOException
-
skip
public long skip(long n) throws IOException- Overrides:
skipin classorg.apache.commons.io.input.ProxyInputStream- Throws:
IOException
-
available
public int available() throws IOException- Overrides:
availablein classorg.apache.commons.io.input.ProxyInputStream- Throws:
IOException
-
mark
public void mark(int readlimit)
This method does nothing.- Overrides:
markin classorg.apache.commons.io.input.ProxyInputStream
-
reset
public void reset() throws IOExceptionThis method does nothing.- Overrides:
resetin classorg.apache.commons.io.input.ProxyInputStream- Throws:
IOException
-
markSupported
public boolean markSupported()
Check whether mark and reset are supported.- Overrides:
markSupportedin classorg.apache.commons.io.input.ProxyInputStream- Returns:
- false
-
-