Class BlobInputStream
- java.lang.Object
-
- java.io.InputStream
-
- org.postgresql.largeobject.BlobInputStream
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable
public class BlobInputStream extends java.io.InputStreamThis is an implementation of an InputStream from a large object.
-
-
Field Summary
Fields Modifier and Type Field Description private longaposThe absolute position.private intbposPosition within buffer.private intbsizeThe buffer size.private byte[]bufferBuffer used to improve performance.private longlimitThe limit.private LargeObjectloThe parent LargeObject.private longmposThe mark position.
-
Constructor Summary
Constructors Constructor Description BlobInputStream(LargeObject lo)BlobInputStream(LargeObject lo, int bsize)BlobInputStream(LargeObject lo, int bsize, long limit)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Closes this input stream and releases any system resources associated with the stream.private LargeObjectgetLo()voidmark(int readlimit)Marks the current position in this input stream.booleanmarkSupported()Tests if this input stream supports themarkandresetmethods.intread()The minimum required to implement input stream.voidreset()Repositions this stream to the position at the time themarkmethod was last called on this input stream.
-
-
-
Field Detail
-
lo
private LargeObject lo
The parent LargeObject.
-
apos
private long apos
The absolute position.
-
buffer
private byte[] buffer
Buffer used to improve performance.
-
bpos
private int bpos
Position within buffer.
-
bsize
private int bsize
The buffer size.
-
mpos
private long mpos
The mark position.
-
limit
private long limit
The limit.
-
-
Constructor Detail
-
BlobInputStream
public BlobInputStream(LargeObject lo)
- Parameters:
lo- LargeObject to read from
-
BlobInputStream
public BlobInputStream(LargeObject lo, int bsize)
- Parameters:
lo- LargeObject to read frombsize- buffer size
-
BlobInputStream
public BlobInputStream(LargeObject lo, int bsize, long limit)
- Parameters:
lo- LargeObject to read frombsize- buffer sizelimit- max number of bytes to read
-
-
Method Detail
-
read
public int read() throws java.io.IOExceptionThe minimum required to implement input stream.- Specified by:
readin classjava.io.InputStream- Throws:
java.io.IOException
-
close
public void close() throws java.io.IOExceptionCloses this input stream and releases any system resources associated with the stream.
The
closemethod ofInputStreamdoes nothing.- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable- Overrides:
closein classjava.io.InputStream- Throws:
java.io.IOException- if an I/O error occurs.
-
mark
public void mark(int readlimit)
Marks the current position in this input stream. A subsequent call to the
resetmethod repositions this stream at the last marked position so that subsequent reads re-read the same bytes.The
readlimitarguments tells this input stream to allow that many bytes to be read before the mark position gets invalidated.The general contract of
markis that, if the methodmarkSupportedreturnstrue, the stream somehow remembers all the bytes read after the call tomarkand stands ready to supply those same bytes again if and whenever the methodresetis called. However, the stream is not required to remember any data at all if more thanreadlimitbytes are read from the stream beforeresetis called.Marking a closed stream should not have any effect on the stream.
- Overrides:
markin classjava.io.InputStream- Parameters:
readlimit- the maximum limit of bytes that can be read before the mark position becomes invalid.- See Also:
InputStream.reset()
-
reset
public void reset() throws java.io.IOExceptionRepositions this stream to the position at the time themarkmethod was last called on this input stream. NB: If mark is not called we move to the beginning.- Overrides:
resetin classjava.io.InputStream- Throws:
java.io.IOException- See Also:
InputStream.mark(int),IOException
-
markSupported
public boolean markSupported()
Tests if this input stream supports themarkandresetmethods. ThemarkSupportedmethod ofInputStreamreturnsfalse.- Overrides:
markSupportedin classjava.io.InputStream- Returns:
trueif this true type supports the mark and reset method;falseotherwise.- See Also:
InputStream.mark(int),InputStream.reset()
-
getLo
private LargeObject getLo() throws java.io.IOException
- Throws:
java.io.IOException
-
-