Package org.jboss.marshalling
Class SimpleDataInput
java.lang.Object
java.io.InputStream
org.jboss.marshalling.SimpleByteInput
org.jboss.marshalling.ByteInputStream
org.jboss.marshalling.SimpleDataInput
- All Implemented Interfaces:
Closeable
,DataInput
,AutoCloseable
,ByteInput
- Direct Known Subclasses:
AbstractObjectInput
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final byte[]
The internal buffer.protected int
The buffer limit.protected int
The buffer position.Fields inherited from class org.jboss.marshalling.ByteInputStream
byteInput
-
Constructor Summary
ConstructorsConstructorDescriptionSimpleDataInput
(int bufferSize) Construct a new instance which wraps nothing.SimpleDataInput
(int bufferSize, ByteInput byteInput) Construct a new instance.SimpleDataInput
(ByteInput byteInput) Construct a new instance. -
Method Summary
Modifier and TypeMethodDescriptionint
Returns an estimate of the number of bytes that can be read (or skipped over) from this input stream without blocking by the next invocation of a method for this input stream.void
close()
private static EOFException
protected void
finish()
Finish reading from the current input.int
read()
Reads the next byte of data from the input stream.int
read
(byte[] b) Read some bytes from the input stream into the given array.int
read
(byte[] b, int off, int len) Read some bytes from the input stream into the given array.boolean
byte
readByte()
char
readChar()
double
float
void
readFully
(byte[] b) void
readFully
(byte[] b, int off, int len) int
readInt()
protected int
Read an int value.readLine()
long
readLong()
protected long
short
int
protected int
Read an unsigned byte directly.int
readUTF()
long
skip
(long n) Skips over and discards up ton
bytes of data from this input stream.int
skipBytes
(int n) protected void
Start reading from the given input.Methods inherited from class java.io.InputStream
mark, markSupported, nullInputStream, readAllBytes, readNBytes, readNBytes, reset, skipNBytes, transferTo
-
Field Details
-
buffer
protected final byte[] bufferThe internal buffer. -
position
protected int positionThe buffer position. -
limit
protected int limitThe buffer limit.
-
-
Constructor Details
-
SimpleDataInput
public SimpleDataInput(int bufferSize) Construct a new instance which wraps nothing.- Parameters:
bufferSize
- the internal buffer size to use
-
SimpleDataInput
Construct a new instance.- Parameters:
bufferSize
- the internal buffer size to usebyteInput
- the byte input to initially wrap
-
SimpleDataInput
Construct a new instance. A default buffer size is used.- Parameters:
byteInput
- the byte input to initially wrap
-
-
Method Details
-
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.- Specified by:
read
in interfaceByteInput
- Overrides:
read
in classByteInputStream
- Returns:
- the next byte, or -1 if the end of stream has been reached
- Throws:
IOException
- if an error occurs
-
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.- Specified by:
read
in interfaceByteInput
- Overrides:
read
in classByteInputStream
- Parameters:
b
- the destination array- Returns:
- the number of bytes read (possibly zero), or -1 if the end of stream has been reached
- Throws:
IOException
- if an error occurs
-
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.- Specified by:
read
in interfaceByteInput
- Overrides:
read
in classByteInputStream
- Parameters:
b
- the destination arrayoff
- the offset into the array into which data should be readlen
- the number of bytes to attempt to fill in the destination array- Returns:
- the number of bytes read (possibly zero), or -1 if the end of stream has been reached
- Throws:
IOException
- if an error occurs
-
skip
Skips over and discards up ton
bytes of data from this input stream. If the end of stream is reached, this method returns0
in order to be consistent withInputStream.skip(long)
.- Specified by:
skip
in interfaceByteInput
- Overrides:
skip
in classByteInputStream
- Parameters:
n
- the number of bytes to attempt to skip- Returns:
- the number of bytes skipped
- Throws:
IOException
- if an error occurs
-
available
Returns an estimate of the number of bytes that can be read (or skipped over) from this input stream without blocking by the next invocation of a method for this input stream.- Specified by:
available
in interfaceByteInput
- Overrides:
available
in classByteInputStream
- Returns:
- the number of bytes
- Throws:
IOException
- if an error occurs
-
eofOnRead
-
readFully
- Specified by:
readFully
in interfaceDataInput
- Throws:
IOException
-
readFully
- Specified by:
readFully
in interfaceDataInput
- Throws:
IOException
-
skipBytes
- Specified by:
skipBytes
in interfaceDataInput
- Throws:
IOException
-
readBoolean
- Specified by:
readBoolean
in interfaceDataInput
- Throws:
IOException
-
readByte
- Specified by:
readByte
in interfaceDataInput
- Throws:
IOException
-
readUnsignedByte
- Specified by:
readUnsignedByte
in interfaceDataInput
- Throws:
IOException
-
readShort
- Specified by:
readShort
in interfaceDataInput
- Throws:
IOException
-
readUnsignedShort
- Specified by:
readUnsignedShort
in interfaceDataInput
- Throws:
IOException
-
readUnsignedByteDirect
Read an unsigned byte directly.- Returns:
- the unsigned byte
- Throws:
IOException
- if an error occurs
-
readChar
- Specified by:
readChar
in interfaceDataInput
- Throws:
IOException
-
readInt
- Specified by:
readInt
in interfaceDataInput
- Throws:
IOException
-
readLong
- Specified by:
readLong
in interfaceDataInput
- Throws:
IOException
-
readLongDirect
- Throws:
IOException
-
readFloat
- Specified by:
readFloat
in interfaceDataInput
- Throws:
IOException
-
readIntDirect
Read an int value.- Returns:
- the value
- Throws:
IOException
- if an error occurs
-
readDouble
- Specified by:
readDouble
in interfaceDataInput
- Throws:
IOException
-
readLine
- Specified by:
readLine
in interfaceDataInput
- Throws:
IOException
-
readUTF
- Specified by:
readUTF
in interfaceDataInput
- Throws:
IOException
-
close
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Overrides:
close
in classByteInputStream
- Throws:
IOException
-
start
Start reading from the given input. The internal buffer is discarded.- Parameters:
byteInput
- the new input from which to read- Throws:
IOException
- not thrown by this implementation, but may be overridden to be thrown if a problem occurs
-
finish
Finish reading from the current input. The internal buffer is discarded, not flushed.- Throws:
IOException
- not thrown by this implementation, but may be overridden to be thrown if a problem occurs
-