Package org.firebirdsql.gds.impl.wire
Class XdrInputStream
java.lang.Object
java.io.InputStream
java.io.FilterInputStream
org.firebirdsql.gds.impl.wire.XdrInputStream
- All Implemented Interfaces:
Closeable,AutoCloseable
XdrInputStream is 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.
- Version:
- 1.0
- Author:
- Alejandro Alberola, David Jencks, Mark Rotteveel
-
Field Summary
Fields inherited from class java.io.FilterInputStream
in -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidWraps the underlying stream for zlib decompression.byte[]Read in a byte buffer.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.intRead in ashort.readString(Encoding encoding) Read in aString.voidintskipFully(int numbytes) Skips the specified number of bytes.intskipPadding(int length) 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- The underlyingInputStreamto read from
-
-
Method Details
-
skipPadding
Skips the padding after a buffer of the specified length. The number of bytes to skip is calculated as(4 - length) & 3.- Parameters:
length- Length of the previously read buffer- Returns:
- Actual number of bytes skipped
- Throws:
IOException- IOException if an error occurs while reading from the underlying input stream- See Also:
-
skipFully
Skips the specified number of bytes.- Parameters:
numbytes- Number of bytes to skip.- Returns:
- Actual number of bytes skipped (usually
numbytes, unless the underlying input stream is closed). - Throws:
IOException- IOException if an error occurs while reading from the underlying input stream
-
readBuffer
Read in a byte buffer.- Returns:
- The buffer that was read
- Throws:
IOException- if an error occurs while reading from the underlying input stream
-
readRawBuffer
Read in a raw array of bytes.- Parameters:
len- The number of bytes to read- Returns:
- The byte buffer that was read
- Throws:
IOException- if an error occurs while reading from the underlying input stream
-
readString
Read in aString.- Returns:
- The
Stringthat was read - Throws:
IOException- if an error occurs while reading from the underlying input stream
-
readLong
Read in along.- Returns:
- The
longthat was read - Throws:
IOException- if an error occurs while reading from the underlying input stream
-
readInt
Read in anint.- Returns:
- The
intthat was read - Throws:
IOException- if an error occurs while reading from the underlying input stream
-
readShort
Read in ashort.- Returns:
- The
shortthat 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- The byte buffer to hold the data that is readoff- The offset at which to start storing data inblen- The 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
-