java.lang.Object
java.io.InputStream
java.io.FilterInputStream
org.firebirdsql.gds.impl.wire.XdrInputStream
- All Implemented Interfaces:
Closeable,AutoCloseable
An input stream for reading in data that is in the XDR format. An
XdrInputStream instance is wrapped
around an underlying java.io.InputStream.
This class is not thread-safe.
- Author:
- Alejandro Alberola, David Jencks, Mark Rotteveel
-
Field Summary
Fields inherited from class java.io.FilterInputStream
in -
Constructor Summary
ConstructorsConstructorDescriptionCreate a new instance ofXdrInputStream.XdrInputStream(InputStream in, int size) Create a new instance ofXdrInputStream. -
Method Summary
Modifier and TypeMethodDescriptionvoidWraps the underlying stream for zlib decompression.byte[]Reads anintlength from the stream, reads and returns the buffer of that length and skips the padding.byte[]readBuffer(int len) Reads and returns the buffer oflenand skips the padding.voidreadFully(byte[] b, int off, int len) Read a given amount of data from the underlying input stream.intreadInt()Read in anint.longreadLong()Read in along.byte[]readRawBuffer(int len) Read in a raw array of bytes.readString(Encoding encoding) Read in aString.voidvoidSkips a buffer, by reading anintlength from the stream, and then skipping that length plus the padding.voidskipPadding(int len) Skips the padding after a buffer of the specified length.Methods inherited from class java.io.FilterInputStream
available, close, mark, markSupported, read, read, read, reset, skipMethods inherited from class java.io.InputStream
nullInputStream, readAllBytes, readNBytes, readNBytes, skipNBytes, transferTo
-
Constructor Details
-
XdrInputStream
Create a new instance ofXdrInputStream.- Parameters:
in- underlyingInputStreamto read from
-
XdrInputStream
Create a new instance ofXdrInputStream.- Parameters:
in- underlyingInputStreamto read fromsize- buffer size
-
-
Method Details
-
skipPadding
Skips the padding after a buffer of the specified length. The number of bytes to skip is calculated as(4 - len) & 3.- Parameters:
len- length of the previously read buffer- Throws:
IOException- if an error occurs while reading from the underlying input stream- See Also:
-
readBuffer
Reads anintlength from the stream, reads and returns the buffer of that length and skips the padding.- Returns:
- buffer that was read
- Throws:
IOException- if an error occurs while reading from the underlying input stream
-
readBuffer
Reads and returns the buffer oflenand skips the padding.- Parameters:
len- length of the buffer- Returns:
- buffer that was read
- Throws:
IOException- if an error occurs while reading from the underlying input stream
-
skipBuffer
Skips a buffer, by reading anintlength from the stream, and then skipping that length plus the padding.- Throws:
IOException- if an error occurs while reading from the underlying input stream
-
readRawBuffer
Read in a raw array of bytes.- Parameters:
len- number of bytes to read- Returns:
- byte buffer that was read
- Throws:
IOException- if an error occurs while reading from the underlying input stream
-
readString
Read in aString.- Parameters:
encoding- encoding to use for reading the string- Returns:
Stringthat was read- Throws:
IOException- if an error occurs while reading from the underlying input stream
-
readLong
Read in along.- Returns:
longthat was read- Throws:
IOException- if an error occurs while reading from the underlying input stream
-
readInt
Read in anint.- Returns:
intthat was read- Throws:
IOException- if an error occurs while reading from the underlying input stream
-
readFully
Read a given amount of data from the underlying input stream. The data that is read is stored inb, starting from offsetoff.- Parameters:
b- byte buffer to hold the data that is readoff- offset at which to start storing data inblen- number of bytes to be read- Throws:
IOException- if an error occurs while reading from the underlying input stream
-
enableDecompression
Wraps the underlying stream for zlib decompression.- Throws:
IOException- if the underlying stream is already set up for decompression
-
setCipher
- Throws:
IOException
-