Class ReadAheadBufferedStream
- java.lang.Object
-
- java.io.InputStream
-
- java.io.FilterInputStream
-
- org.mariadb.jdbc.client.socket.impl.ReadAheadBufferedStream
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable
public class ReadAheadBufferedStream extends java.io.FilterInputStreamPermit to buf socket data, reading not only asked bytes, but available number of bytes when possible.
-
-
Constructor Summary
Constructors Constructor Description ReadAheadBufferedStream(java.io.InputStream in)Constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intavailable()voidclose()private voidfillingBuffer(int minNeededBytes)Fill buf with required length, or available bytes.booleanmarkSupported()intread()intread(byte[] externalBuf, int off, int len)Returning byte array, from cache of reading socket if needed.voidreset()longskip(long n)
-
-
-
Field Detail
-
BUF_SIZE
private static final int BUF_SIZE
- See Also:
- Constant Field Values
-
buf
private final byte[] buf
-
end
private int end
-
pos
private int pos
-
-
Method Detail
-
read
public int read(byte[] externalBuf, int off, int len) throws java.io.IOExceptionReturning byte array, from cache of reading socket if needed.- Overrides:
readin classjava.io.FilterInputStream- Parameters:
externalBuf- buf to filloff- offsetlen- length to read- Returns:
- number of added bytes
- Throws:
java.io.IOException- if exception during socket reading
-
fillingBuffer
private void fillingBuffer(int minNeededBytes) throws java.io.IOExceptionFill buf with required length, or available bytes.- Parameters:
minNeededBytes- asked number of bytes- Throws:
java.io.IOException- in case of failing reading stream.
-
markSupported
public boolean markSupported()
- Overrides:
markSupportedin classjava.io.FilterInputStream
-
close
public void close() throws java.io.IOException- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable- Overrides:
closein classjava.io.FilterInputStream- Throws:
java.io.IOException
-
available
public int available() throws java.io.IOException- Overrides:
availablein classjava.io.FilterInputStream- Throws:
java.io.IOException
-
read
public int read() throws java.io.IOException- Overrides:
readin classjava.io.FilterInputStream- Throws:
java.io.IOException
-
skip
public long skip(long n) throws java.io.IOException- Overrides:
skipin classjava.io.FilterInputStream- Throws:
java.io.IOException
-
reset
public void reset() throws java.io.IOException- Overrides:
resetin classjava.io.FilterInputStream- Throws:
java.io.IOException
-
-