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:
- java.io.Closeable,- java.lang.AutoCloseable
 
 public final class XdrInputStream extends java.io.FilterInputStreamXdrInputStreamis an input stream for reading in data that is in the XDR format. AnXdrInputStreaminstance is wrapped around an underlyingjava.io.InputStream.This class is not thread-safe. - Author:
- Alejandro Alberola, David Jencks, Mark Rotteveel
 
- 
- 
Constructor SummaryConstructors Constructor Description XdrInputStream(java.io.InputStream in)Create a new instance ofXdrInputStream.
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description voidenableDecompression()Wraps the underlying stream for zlib decompression.byte[]readBuffer()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.intreadShort()Read in ashort.java.lang.StringreadString(Encoding encoding)Read in aString.voidsetCipher(javax.crypto.Cipher cipher)intskipFully(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.FilterInputStreamavailable, close, mark, markSupported, read, read, read, reset, skip
 
- 
 
- 
- 
- 
Method Detail- 
skipPaddingpublic int skipPadding(int length) throws java.io.IOExceptionSkips 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:
- java.io.IOException- IOException if an error occurs while reading from the underlying input stream
- See Also:
- XdrOutputStream.writePadding(int, int)
 
 - 
skipFullypublic int skipFully(int numbytes) throws java.io.IOExceptionSkips 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:
- java.io.IOException- IOException if an error occurs while reading from the underlying input stream
 
 - 
readBufferpublic byte[] readBuffer() throws java.io.IOExceptionRead in a byte buffer.- Returns:
- The buffer that was read
- Throws:
- java.io.IOException- if an error occurs while reading from the underlying input stream
 
 - 
readRawBufferpublic byte[] readRawBuffer(int len) throws java.io.IOExceptionRead in a raw array of bytes.- Parameters:
- len- The number of bytes to read
- Returns:
- The byte buffer that was read
- Throws:
- java.io.IOException- if an error occurs while reading from the underlying input stream
 
 - 
readStringpublic java.lang.String readString(Encoding encoding) throws java.io.IOException Read in aString.- Returns:
- The Stringthat was read
- Throws:
- java.io.IOException- if an error occurs while reading from the underlying input stream
 
 - 
readLongpublic long readLong() throws java.io.IOExceptionRead in along.- Returns:
- The longthat was read
- Throws:
- java.io.IOException- if an error occurs while reading from the underlying input stream
 
 - 
readIntpublic int readInt() throws java.io.IOExceptionRead in anint.- Returns:
- The intthat was read
- Throws:
- java.io.IOException- if an error occurs while reading from the underlying input stream
 
 - 
readShortpublic int readShort() throws java.io.IOExceptionRead in ashort.- Returns:
- The shortthat was read
- Throws:
- java.io.IOException- if an error occurs while reading from the underlying input stream
 
 - 
readFullypublic void readFully(byte[] b, int off, int len) throws java.io.IOExceptionRead 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 read
- off- The offset at which to start storing data in- b
- len- The number of bytes to be read
- Throws:
- java.io.IOException- if an error occurs while reading from the underlying input stream
 
 - 
enableDecompression@InternalApi public void enableDecompression() throws java.io.IOException Wraps the underlying stream for zlib decompression.- Throws:
- java.io.IOException- If the underlying stream is already set up for decompression
 
 - 
setCipherpublic void setCipher(javax.crypto.Cipher cipher) throws java.io.IOException- Throws:
- java.io.IOException
 
 
- 
 
-