Class ProtonStreamUtils
- java.lang.Object
- 
- org.apache.qpid.protonj2.codec.decoders.ProtonStreamUtils
 
- 
 public abstract class ProtonStreamUtils extends Object Set of Utility methods useful when dealing with byte arrays and other primitive types.
- 
- 
Constructor SummaryConstructors Constructor Description ProtonStreamUtils()
 - 
Method SummaryAll Methods Static Methods Concrete Methods Modifier and Type Method Description static bytereadByte(InputStream stream)Reads a single byte from the givenInputStreamand thrown aDecodeExceptionif theInputStreamindicates an EOF condition was encountered.static byte[]readBytes(InputStream stream, int length)Reads the given number of bytes from the providedInputStreaminto an array and return that to the caller.static doublereadDouble(InputStream stream)Reads a double value from the givenInputStreamand thrown aDecodeExceptionif theInputStreamindicates an EOF condition was encountered.static bytereadEncodingCode(InputStream stream)Reads a single byte from the givenInputStreamand thrown aDecodeExceptionif theInputStreamindicates an EOF condition was encountered.static floatreadFloat(InputStream stream)Reads a float value from the givenInputStreamand thrown aDecodeExceptionif theInputStreamindicates an EOF condition was encountered.static intreadInt(InputStream stream)Reads a integer value from the givenInputStreamand thrown aDecodeExceptionif theInputStreamindicates an EOF condition was encountered.static longreadLong(InputStream stream)Reads a long value from the givenInputStreamand thrown aDecodeExceptionif theInputStreamindicates an EOF condition was encountered.static shortreadShort(InputStream stream)Reads a short value from the givenInputStreamand thrown aDecodeExceptionif theInputStreamindicates an EOF condition was encountered.static InputStreamreset(InputStream stream)Attempts to reset the providedInputStreamto a previously marked point.static InputStreamskipBytes(InputStream stream, long amount)Attempts to skip the given number of bytes from the providedInputStreaminstance and throws a DecodeException if an error occurs during the skip.static OutputStreamwriteByte(byte value, OutputStream stream)Write the givenByteto the targetOutputStream.static OutputStreamwriteInt(int value, OutputStream stream)Write the givenIntegerto the targetOutputStream.static OutputStreamwriteLong(long value, OutputStream stream)Write the givenLongto the targetOutputStream.static OutputStreamwriteShort(short value, OutputStream stream)Write the givenShortto the targetOutputStream.
 
- 
- 
- 
Method Detail- 
writeBytepublic static OutputStream writeByte(byte value, OutputStream stream) throws EncodeException Write the givenByteto the targetOutputStream.- Parameters:
- value- the value to write to the- OutputStream.
- stream- the- OutputStreamwhere the target value is to be written.
- Returns:
- the given OutputStreaminstance.
- Throws:
- EncodeException- if an error occurs while writing to the target- OutputStream.
 
 - 
writeShortpublic static OutputStream writeShort(short value, OutputStream stream) throws EncodeException Write the givenShortto the targetOutputStream.- Parameters:
- value- the value to write to the- OutputStream.
- stream- the- OutputStreamwhere the target value is to be written.
- Returns:
- the given OutputStreaminstance.
- Throws:
- EncodeException- if an error occurs while writing to the target- OutputStream.
 
 - 
writeIntpublic static OutputStream writeInt(int value, OutputStream stream) throws EncodeException Write the givenIntegerto the targetOutputStream.- Parameters:
- value- the value to write to the- OutputStream.
- stream- the- OutputStreamwhere the target value is to be written.
- Returns:
- the given OutputStreaminstance.
- Throws:
- EncodeException- if an error occurs while writing to the target- OutputStream.
 
 - 
writeLongpublic static OutputStream writeLong(long value, OutputStream stream) throws EncodeException Write the givenLongto the targetOutputStream.- Parameters:
- value- the value to write to the- OutputStream.
- stream- the- OutputStreamwhere the target value is to be written.
- Returns:
- the given OutputStreaminstance.
- Throws:
- EncodeException- if an error occurs while writing to the target- OutputStream.
 
 - 
readBytespublic static byte[] readBytes(InputStream stream, int length) throws DecodeException Reads the given number of bytes from the providedInputStreaminto an array and return that to the caller. If the requested number of bytes cannot be read from the stream anDecodeExceptionis thrown to indicate an underflow.- Parameters:
- stream- The- InputStreamwhere the bytes should be read from.
- length- The number of bytes to read from the given input stream.
- Returns:
- a byte array containing the requested number of bytes read from the given InputStream
- Throws:
- DecodeException- if an error occurs reading from the stream or insufficient bytes are available.
 
 - 
readEncodingCodepublic static byte readEncodingCode(InputStream stream) throws DecodeException Reads a single byte from the givenInputStreamand thrown aDecodeExceptionif theInputStreamindicates an EOF condition was encountered.- Parameters:
- stream- The- InputStreamwhere the bytes should be read from.
- Returns:
- the given byte that was read from the stream.
- Throws:
- DecodeException- if an error occurs during the read or EOF is reached.
 
 - 
readBytepublic static byte readByte(InputStream stream) throws DecodeException Reads a single byte from the givenInputStreamand thrown aDecodeExceptionif theInputStreamindicates an EOF condition was encountered.- Parameters:
- stream- The- InputStreamwhere the bytes should be read from.
- Returns:
- the given byte that was read from the stream.
- Throws:
- DecodeException- if an error occurs during the read or EOF is reached.
 
 - 
readShortpublic static short readShort(InputStream stream) Reads a short value from the givenInputStreamand thrown aDecodeExceptionif theInputStreamindicates an EOF condition was encountered.- Parameters:
- stream- The- InputStreamwhere the bytes should be read from.
- Returns:
- the given byte that was read from the stream.
- Throws:
- DecodeException- if an error occurs during the read or EOF is reached.
 
 - 
readIntpublic static int readInt(InputStream stream) Reads a integer value from the givenInputStreamand thrown aDecodeExceptionif theInputStreamindicates an EOF condition was encountered.- Parameters:
- stream- The- InputStreamwhere the bytes should be read from.
- Returns:
- the given byte that was read from the stream.
- Throws:
- DecodeException- if an error occurs during the read or EOF is reached.
 
 - 
readLongpublic static long readLong(InputStream stream) Reads a long value from the givenInputStreamand thrown aDecodeExceptionif theInputStreamindicates an EOF condition was encountered.- Parameters:
- stream- The- InputStreamwhere the bytes should be read from.
- Returns:
- the given byte that was read from the stream.
- Throws:
- DecodeException- if an error occurs during the read or EOF is reached.
 
 - 
readFloatpublic static float readFloat(InputStream stream) Reads a float value from the givenInputStreamand thrown aDecodeExceptionif theInputStreamindicates an EOF condition was encountered.- Parameters:
- stream- The- InputStreamwhere the bytes should be read from.
- Returns:
- the given byte that was read from the stream.
- Throws:
- DecodeException- if an error occurs during the read or EOF is reached.
 
 - 
readDoublepublic static double readDouble(InputStream stream) Reads a double value from the givenInputStreamand thrown aDecodeExceptionif theInputStreamindicates an EOF condition was encountered.- Parameters:
- stream- The- InputStreamwhere the bytes should be read from.
- Returns:
- the given byte that was read from the stream.
- Throws:
- DecodeException- if an error occurs during the read or EOF is reached.
 
 - 
skipBytespublic static InputStream skipBytes(InputStream stream, long amount) Attempts to skip the given number of bytes from the providedInputStreaminstance and throws a DecodeException if an error occurs during the skip.- Parameters:
- stream- The- InputStreamwhere the bytes should be read from.
- amount- The number of bytes that should be skipped.
- Returns:
- the InputStreaminstance that was passed.
- Throws:
- DecodeException- if an error occurs during the read or EOF is reached.
 
 - 
resetpublic static InputStream reset(InputStream stream) throws DecodeException Attempts to reset the providedInputStreamto a previously marked point. If an error occurs this method throws an DecodeException to describe the error.- Parameters:
- stream- The- InputStreamthat is to be reset.
- Returns:
- the InputStreaminstance that was passed.
- Throws:
- DecodeException- if an error occurs during the reset.
 
 
- 
 
-