Top Description Fields Constructors Methods
org.jboss.marshalling

public Class LimitedByteInput

extends ByteInputStream
Class Inheritance
Imports
java.io.IOException

A limited byte input stream. Throws an exception if too many bytes are read.

Field Summary

Modifier and TypeField and Description
private long
private final long
Inherited from org.jboss.marshalling.ByteInputStream:
byteInput

Constructor Summary

AccessConstructor and Description
public
LimitedByteInput(final ByteInput
the byte input to read from
byteInput
,
final long
the maximum number of bytes to read
limit
)

Create a new instance.

Method Summary

Modifier and TypeMethod and Description
public int
read()

Overrides org.jboss.marshalling.ByteInputStream.read.

Implements org.jboss.marshalling.ByteInput.read.

Reads the next byte of data from the input stream.
public int
read(final byte[]
the destination array
b
,
final int
the offset into the array into which data should be read
off
,
final int
the number of bytes to attempt to fill in the destination array
len
)

Overrides org.jboss.marshalling.ByteInputStream.read.

Implements org.jboss.marshalling.ByteInput.read.

Read some bytes from the input stream into the given array.
public long
skip(final long
the number of bytes to attempt to skip
n
)

Overrides org.jboss.marshalling.ByteInputStream.skip.

Implements org.jboss.marshalling.ByteInput.skip.

Skips over and discards up to n bytes of data from this input stream.
Inherited from org.jboss.marshalling.ByteInputStream:
availablecloseread

Field Detail

countback to summary
private long count
limitback to summary
private final long limit

Constructor Detail

LimitedByteInputback to summary
public LimitedByteInput(final ByteInput byteInput, final long limit)

Create a new instance.

Parameters
byteInput:ByteInput

the byte input to read from

limit:long

the maximum number of bytes to read

Method Detail

readback to summary
public int read() throws IOException

Overrides org.jboss.marshalling.ByteInputStream.read.

Implements org.jboss.marshalling.ByteInput.read.

Doc from org.jboss.marshalling.ByteInputStream.read.

Reads the next byte of data from the input stream. 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

Doc from org.jboss.marshalling.ByteInput.read.

the next byte, or -1 if the end of stream has been reached

Exceptions
IOException:

Doc from org.jboss.marshalling.ByteInput.read.

if an error occurs

readback to summary
public int read(final byte[] b, final int off, final int len) throws IOException

Overrides org.jboss.marshalling.ByteInputStream.read.

Implements org.jboss.marshalling.ByteInput.read.

Doc from org.jboss.marshalling.ByteInputStream.read.

Read some bytes from the input stream into the given array. Returns the number of bytes actually read (possibly zero), or -1 if the end of stream has been reached.

Parameters
b:byte[]

Doc from org.jboss.marshalling.ByteInput.read.

the destination array

off:int

Doc from org.jboss.marshalling.ByteInput.read.

the offset into the array into which data should be read

len:int

Doc from org.jboss.marshalling.ByteInput.read.

the number of bytes to attempt to fill in the destination array

Returns:int

Doc from org.jboss.marshalling.ByteInput.read.

the number of bytes read (possibly zero), or -1 if the end of stream has been reached

Exceptions
IOException:

Doc from org.jboss.marshalling.ByteInput.read.

if an error occurs

skipback to summary
public long skip(final long n) throws IOException

Overrides org.jboss.marshalling.ByteInputStream.skip.

Implements org.jboss.marshalling.ByteInput.skip.

Doc from org.jboss.marshalling.ByteInputStream.skip.

Skips over and discards up to n bytes of data from this input stream. If the end of stream is reached, this method returns 0 in order to be consistent with java.io.InputStream#skip(long).

Parameters
n:long

Doc from org.jboss.marshalling.ByteInput.skip.

the number of bytes to attempt to skip

Returns:long

Doc from org.jboss.marshalling.ByteInput.skip.

the number of bytes skipped

Exceptions
IOException:

Doc from org.jboss.marshalling.ByteInput.skip.

if an error occurs