public class Serialization extends Object
| Modifier and Type | Method and Description |
|---|---|
static byte |
readByte(InputStream input)
Read a single byte from the input stream.
|
static byte[] |
readDEROctetString(byte[] input) |
static byte[] |
readDEROctetString(InputStream input) |
static byte[] |
readFixedBytes(InputStream input,
int length)
Read a fixed number of bytes from the input stream.
|
static byte[][] |
readList(byte[] input,
int listWidth,
int elemWidth) |
static byte[][] |
readList(InputStream input,
int listWidth,
int elemWidth)
Read a variable length vector of variable sized elements as described by RFC5246 section 4.3.
|
static long |
readLong(InputStream input,
int width)
Read a number in big endian format from the input stream.
|
static int |
readNumber(InputStream input,
int width)
Read a number in big endian format from the input stream.
|
static byte[] |
readVariableBytes(InputStream input,
int width)
Read a length-prefixed sequence of bytes.
|
static void |
writeFixedBytes(OutputStream output,
byte[] data)
Write a fixed number sequence of bytes to the ouput stream.
|
static void |
writeNumber(OutputStream output,
long value,
int width)
Write a number to the output stream.
|
static void |
writeVariableBytes(OutputStream output,
byte[] data,
int width)
Write length prefixed sequence of bytes to the ouput stream.
|
public static byte[] readDEROctetString(byte[] input)
throws SerializationException
SerializationExceptionpublic static byte[] readDEROctetString(InputStream input) throws SerializationException
SerializationExceptionpublic static byte[][] readList(byte[] input,
int listWidth,
int elemWidth)
throws SerializationException
SerializationExceptionpublic static byte[][] readList(InputStream input, int listWidth, int elemWidth) throws SerializationException
listWidth - the width of the vector's length field, in bytes.elemWidth - the width of each element's length field, in bytes.SerializationException - if EOF is encountered.public static byte[] readVariableBytes(InputStream input, int width) throws SerializationException
width - the width of the length prefix, in bytes.SerializationException - if EOF is encountered, or if width is negative or
greater than 4public static byte[] readFixedBytes(InputStream input, int length) throws SerializationException
length - the number of bytes to read.SerializationException - if EOF is encountered.public static int readNumber(InputStream input, int width) throws SerializationException
width - the width of the number, in bytes.SerializationException - if EOF is encountered, or if width is negative or
greater than 4public static long readLong(InputStream input, int width) throws SerializationException
width - the width of the number, in bytes.SerializationException - if EOF is encountered.IllegalArgumentException - if width is negative or greater than 8public static byte readByte(InputStream input) throws SerializationException
SerializationException - if EOF is encountered.public static void writeVariableBytes(OutputStream output, byte[] data, int width) throws SerializationException
data - the data to be written.width - the width of the length prefix, in bytes.SerializationException - if the length of data is too large to fit in
width bytes or width is negative.public static void writeFixedBytes(OutputStream output, byte[] data) throws SerializationException
data - the data to be written.SerializationExceptionpublic static void writeNumber(OutputStream output, long value, int width) throws SerializationException
value - the value to be written.width - the width of the encoded number, in bytesSerializationException - if the number is too large to fit in width bytes or
width is negative.