Top Description Fields Constructors Methods
com.mysql.cj.protocol.x

public Class ConfinedInputStream

extends FilterInputStream
Class Inheritance
Imports
java.io.FilterInputStream, .IOException, .InputStream

An InputStream wrapper that limits the number of bytes that can be read form the underlying InputStream.

Field Summary

Modifier and TypeField and Description
private boolean
private int
private int
Inherited from java.io.FilterInputStream:
in

Constructor Summary

AccessConstructor and Description
protected
protected

Method Summary

Modifier and TypeMethod and Description
public int

Returns:

the number of bytes available.
available
()

Overrides java.io.FilterInputStream.available.

Returns the number of bytes not yet consumed.

public void
close()

Overrides java.io.FilterInputStream.close.

Implements java.io.Closeable.close.

Closes this stream and throws away any bytes not consumed from the underlying InputStream.

protected long

Returns:

the number of bytes skipped.
dumpLeftovers
()

Skips the number bytes not yet consumed from the underlying InputStream.

private void
ensureOpen()

Ensures that this InputStream wasn't closed yet.

public int
read()

Overrides java.io.FilterInputStream.read.

Reads the next byte of data from the input stream.

public int
read(byte[]
the buffer into which the data is read.
b
)

Overrides java.io.FilterInputStream.read.

Forwards the read to read(byte[], int, int).

public int
read(byte[]
the buffer into which the data is read.
b
,
int
the start offset in array b at which the data is written.
off
,
int
the maximum number of bytes to read.
len
)

Overrides java.io.FilterInputStream.read.

Reads bytes from the underlying InputStream up to the number of bytes defined in this ConfinedInputStream limit.

public int

Returns:

the number of bytes not consumed before reseting the limit.
resetLimit
(int
the new length to set.
len
)

Resets this ConfinedInputStream limit so that it can be reused over the same underlying InputStream.

Inherited from java.io.FilterInputStream:
markmarkSupportedresetskip

Field Detail

closedback to summary
private boolean closed
consumedback to summary
private int consumed
limitback to summary
private int limit

Constructor Detail

ConfinedInputStreamback to summary
protected ConfinedInputStream(InputStream in)
ConfinedInputStreamback to summary
protected ConfinedInputStream(InputStream in, int lim)

Method Detail

availableback to summary
public int available() throws IOException

Overrides java.io.FilterInputStream.available.

Returns the number of bytes not yet consumed. Note that this method doen't care about the exact number of bytes that may or may not be available in the underlying InputStream

Returns:int

the number of bytes available.

Annotations
@Override
Exceptions
IOException:

Doc from java.io.FilterInputStream.available.

if an I/O error occurs.

See Also
FilterInputStream#available()
closeback to summary
public void close() throws IOException

Overrides java.io.FilterInputStream.close.

Implements java.io.Closeable.close.

Closes this stream and throws away any bytes not consumed from the underlying InputStream.

Annotations
@Override
Exceptions
IOException:

Doc from java.io.FilterInputStream.close.

if an I/O error occurs.

See Also
FilterInputStream#close()
dumpLeftoversback to summary
protected long dumpLeftovers() throws IOException

Skips the number bytes not yet consumed from the underlying InputStream.

Returns:long

the number of bytes skipped.

Exceptions
IOException:
if any of the underlying I/O operations fail.
ensureOpenback to summary
private void ensureOpen() throws IOException

Ensures that this InputStream wasn't closed yet.

Exceptions
IOException:
if this InputStream was closed.
readback to summary
public int read() throws IOException

Overrides java.io.FilterInputStream.read.

Doc from java.io.FilterInputStream.read.

Reads the next byte of data from the input stream. The value byte is returned as an int in the range 0 to 255. If no byte is available because the end of the stream has been reached, the value -1 is returned. This method blocks until input data is available, the end of the stream is detected, or an exception is thrown.

Returns:int

the next byte of data, or -1 if the end of the stream is reached.

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs.
See Also
FilterInputStream#read()
readback to summary
public int read(byte[] b) throws IOException

Overrides java.io.FilterInputStream.read.

Forwards the read to read(byte[], int, int).

Parameters
b:byte[]

Doc from java.io.FilterInputStream.read.

the buffer into which the data is read.

Returns:int

Doc from java.io.FilterInputStream.read.

the total number of bytes read into the buffer, or -1 if there is no more data because the end of the stream has been reached.

Annotations
@Override
Exceptions
IOException:

Doc from java.io.FilterInputStream.read.

if an I/O error occurs.

See Also
FilterInputStream#read(byte[])
readback to summary
public int read(byte[] b, int off, int len) throws IOException

Overrides java.io.FilterInputStream.read.

Reads bytes from the underlying InputStream up to the number of bytes defined in this ConfinedInputStream limit.

Parameters
b:byte[]

Doc from java.io.FilterInputStream.read.

the buffer into which the data is read.

off:int

Doc from java.io.FilterInputStream.read.

the start offset in array b at which the data is written.

len:int

Doc from java.io.FilterInputStream.read.

the maximum number of bytes to read.

Returns:int

Doc from java.io.FilterInputStream.read.

the total number of bytes read into the buffer, or -1 if there is no more data because the end of the stream has been reached.

Annotations
@Override
Exceptions
IOException:

Doc from java.io.FilterInputStream.read.

if an I/O error occurs.

See Also
FilterInputStream#read(byte[], int, int)
resetLimitback to summary
public int resetLimit(int len)

Resets this ConfinedInputStream limit so that it can be reused over the same underlying InputStream.

Parameters
len:int

the new length to set.

Returns:int

the number of bytes not consumed before reseting the limit.