Class ReadAheadBufferedStream
java.lang.Object
java.io.InputStream
java.io.FilterInputStream
org.mariadb.jdbc.internal.io.input.ReadAheadBufferedStream
- All Implemented Interfaces:
Closeable
,AutoCloseable
Permit to buffer socket data, reading not only asked bytes, but available number of bytes when
possible.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate byte[]
private static final int
private int
private int
Fields inherited from class java.io.FilterInputStream
in
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionint
void
close()
private void
fillBuffer
(int minNeededBytes) Fill buffer with required length, or available bytes.boolean
int
read()
Reading one byte from cache of socket if needed.int
read
(byte[] externalBuf, int off, int len) Returing byte array, from cache of reading socket if needed.void
reset()
long
skip
(long n) Methods inherited from class java.io.FilterInputStream
mark, read
Methods inherited from class java.io.InputStream
nullInputStream, readAllBytes, readNBytes, readNBytes, skipNBytes, transferTo
-
Field Details
-
BUF_SIZE
private static final int BUF_SIZE- See Also:
-
buf
private volatile byte[] buf -
end
private int end -
pos
private int pos
-
-
Constructor Details
-
ReadAheadBufferedStream
-
-
Method Details
-
read
Reading one byte from cache of socket if needed.- Overrides:
read
in classFilterInputStream
- Returns:
- byte value
- Throws:
IOException
- if socket reading error.
-
read
Returing byte array, from cache of reading socket if needed.- Overrides:
read
in classFilterInputStream
- Parameters:
externalBuf
- buffer to filloff
- offsetlen
- length to read- Returns:
- number of added bytes
- Throws:
IOException
- if exception during socket reading
-
fillBuffer
Fill buffer with required length, or available bytes.- Parameters:
minNeededBytes
- asked number of bytes- Throws:
IOException
- in case of failing reading stream.
-
skip
- Overrides:
skip
in classFilterInputStream
- Throws:
IOException
-
available
- Overrides:
available
in classFilterInputStream
- Throws:
IOException
-
reset
- Overrides:
reset
in classFilterInputStream
- Throws:
IOException
-
markSupported
public boolean markSupported()- Overrides:
markSupported
in classFilterInputStream
-
close
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Overrides:
close
in classFilterInputStream
- Throws:
IOException
-