public class CborDecoder
extends java.lang.Object
InputStream.| Constructor and Description |
|---|
CborDecoder(java.io.InputStream is)
Creates a new
CborDecoder instance. |
| Modifier and Type | Method and Description |
|---|---|
protected long |
expectIntegerType(int ib)
Reads the next major type from the underlying input stream, and verifies whether it matches the given expectation.
|
CborType |
peekType()
Peeks in the input stream for the upcoming type.
|
long |
readArrayLength()
Prolog to reading an array value in CBOR format.
|
boolean |
readBoolean()
Reads a boolean value in CBOR format.
|
java.lang.Object |
readBreak()
Reads a "break"/stop value in CBOR format.
|
byte[] |
readByteString()
Reads a byte string value in CBOR format.
|
long |
readByteStringLength()
Prolog to reading a byte string value in CBOR format.
|
double |
readDouble()
Reads a double-precision float value in CBOR format.
|
float |
readFloat()
Reads a single-precision float value in CBOR format.
|
double |
readHalfPrecisionFloat()
Reads a half-precision float value in CBOR format.
|
long |
readInt()
Reads a signed or unsigned integer value in CBOR format.
|
int |
readInt16()
Reads a signed or unsigned 16-bit integer value in CBOR format.
|
long |
readInt32()
Reads a signed or unsigned 32-bit integer value in CBOR format.
|
long |
readInt64()
Reads a signed or unsigned 64-bit integer value in CBOR format.
|
int |
readInt8()
Reads a signed or unsigned 8-bit integer value in CBOR format.
|
protected int |
readMajorType(int majorType)
Reads the next major type from the underlying input stream, and verifies whether it matches the given expectation.
|
protected void |
readMajorTypeExact(int majorType,
int subtype)
Reads the next major type from the underlying input stream, and verifies whether it matches the given expectations.
|
protected long |
readMajorTypeWithSize(int majorType)
Reads the next major type from the underlying input stream, verifies whether it matches the given expectation, and decodes the payload into a size.
|
long |
readMapLength()
Prolog to reading a map of key-value pairs in CBOR format.
|
java.lang.Object |
readNull()
Reads a
null-value in CBOR format. |
byte |
readSimpleValue()
Reads a single byte value in CBOR format.
|
int |
readSmallInt()
Reads a signed or unsigned small (<= 23) integer value in CBOR format.
|
long |
readTag()
Reads a semantic tag value in CBOR format.
|
java.lang.String |
readTextString()
Reads an UTF-8 encoded string value in CBOR format.
|
long |
readTextStringLength()
Prolog to reading an UTF-8 encoded string value in CBOR format.
|
protected long |
readUInt(int length,
boolean breakAllowed)
Reads an unsigned integer with a given length-indicator.
|
protected int |
readUInt16()
Reads an unsigned 16-bit integer value.
|
protected long |
readUInt32()
Reads an unsigned 32-bit integer value.
|
protected long |
readUInt64()
Reads an unsigned 64-bit integer value.
|
protected int |
readUInt8()
Reads an unsigned 8-bit integer value.
|
protected long |
readUIntExact(int expectedLength,
int length)
Reads an unsigned integer with a given length-indicator.
|
java.lang.Object |
readUndefined()
Reads an undefined value in CBOR format.
|
public CborDecoder(java.io.InputStream is)
CborDecoder instance.is - the actual input stream to read the CBOR-encoded data from, cannot be null.public CborType peekType() throws java.io.IOException
null in case of an end-of-stream.java.io.IOException - in case of I/O problems reading the CBOR-type from the underlying input stream.public long readArrayLength()
throws java.io.IOException
java.io.IOException - in case of I/O problems reading the CBOR-encoded value from the underlying input stream.public boolean readBoolean()
throws java.io.IOException
java.io.IOException - in case of I/O problems reading the CBOR-encoded value from the underlying input stream.public java.lang.Object readBreak()
throws java.io.IOException
null.java.io.IOException - in case of I/O problems reading the CBOR-encoded value from the underlying input stream.public byte[] readByteString()
throws java.io.IOException
null. In case the encoded string has a length of 0, an empty string is returned.java.io.IOException - in case of I/O problems reading the CBOR-encoded value from the underlying input stream.public long readByteStringLength()
throws java.io.IOException
java.io.IOException - in case of I/O problems reading the CBOR-encoded value from the underlying input stream.public double readDouble()
throws java.io.IOException
Float.MIN_VALUE to Float.MAX_VALUE are supported.java.io.IOException - in case of I/O problems reading the CBOR-encoded value from the underlying input stream.public float readFloat()
throws java.io.IOException
Float.MIN_VALUE to Float.MAX_VALUE are supported.java.io.IOException - in case of I/O problems reading the CBOR-encoded value from the underlying input stream.public double readHalfPrecisionFloat()
throws java.io.IOException
Float.MIN_VALUE to Float.MAX_VALUE are supported.java.io.IOException - in case of I/O problems reading the CBOR-encoded value from the underlying input stream.public long readInt()
throws java.io.IOException
Long.MIN_VALUE to Long.MAX_VALUE are supported.java.io.IOException - in case of I/O problems reading the CBOR-encoded value from the underlying input stream.public int readInt16()
throws java.io.IOException
java.io.IOException - in case of I/O problems reading the CBOR-encoded value from the underlying output stream.public long readInt32()
throws java.io.IOException
java.io.IOException - in case of I/O problems reading the CBOR-encoded value from the underlying output stream.public long readInt64()
throws java.io.IOException
Long.MIN_VALUE to Long.MAX_VALUE are supported.java.io.IOException - in case of I/O problems reading the CBOR-encoded value from the underlying output stream.public int readInt8()
throws java.io.IOException
java.io.IOException - in case of I/O problems reading the CBOR-encoded value from the underlying output stream.public long readMapLength()
throws java.io.IOException
java.io.IOException - in case of I/O problems reading the CBOR-encoded value from the underlying input stream.public java.lang.Object readNull()
throws java.io.IOException
null-value in CBOR format.null.java.io.IOException - in case of I/O problems reading the CBOR-encoded value from the underlying input stream.public byte readSimpleValue()
throws java.io.IOException
java.io.IOException - in case of I/O problems reading the CBOR-encoded value from the underlying input stream.public int readSmallInt()
throws java.io.IOException
java.io.IOException - in case of I/O problems reading the CBOR-encoded value from the underlying output stream.public long readTag()
throws java.io.IOException
java.io.IOException - in case of I/O problems reading the CBOR-encoded value from the underlying input stream.public java.lang.String readTextString()
throws java.io.IOException
null. In case the encoded string has a length of 0, an empty string is returned.java.io.IOException - in case of I/O problems reading the CBOR-encoded value from the underlying input stream.public long readTextStringLength()
throws java.io.IOException
java.io.IOException - in case of I/O problems reading the CBOR-encoded value from the underlying input stream.public java.lang.Object readUndefined()
throws java.io.IOException
null.java.io.IOException - in case of I/O problems reading the CBOR-encoded value from the underlying input stream.protected long expectIntegerType(int ib)
throws java.io.IOException
ib - the the expected typejava.io.IOException - in case of I/O problems reading the CBOR-encoded value from the underlying input stream.protected int readMajorType(int majorType)
throws java.io.IOException
majorType - the expected major type, cannot be null (unchecked).java.io.IOException - in case of I/O problems reading the CBOR-encoded value from the underlying input stream.protected void readMajorTypeExact(int majorType,
int subtype)
throws java.io.IOException
majorType - the expected major type, cannot be null (unchecked);subtype - the expected subtype.java.io.IOException - in case of I/O problems reading the CBOR-encoded value from the underlying input stream.protected long readMajorTypeWithSize(int majorType)
throws java.io.IOException
majorType - the expected major type, cannot be null (unchecked).java.io.IOException - in case of I/O problems reading the CBOR-encoded value from the underlying input stream.protected long readUInt(int length,
boolean breakAllowed)
throws java.io.IOException
length - the length indicator to use;breakAllowed - if break is allowed.java.io.IOException - in case of I/O problems reading the unsigned integer from the underlying input stream.protected int readUInt16()
throws java.io.IOException
Long.MIN_VALUE to Long.MAX_VALUE are supported.java.io.IOException - in case of I/O problems writing the CBOR-encoded value to the underlying output stream.protected long readUInt32()
throws java.io.IOException
Long.MIN_VALUE to Long.MAX_VALUE are supported.java.io.IOException - in case of I/O problems writing the CBOR-encoded value to the underlying output stream.protected long readUInt64()
throws java.io.IOException
Long.MIN_VALUE to Long.MAX_VALUE are supported.java.io.IOException - in case of I/O problems writing the CBOR-encoded value to the underlying output stream.protected int readUInt8()
throws java.io.IOException
Long.MIN_VALUE to Long.MAX_VALUE are supported.java.io.IOException - in case of I/O problems writing the CBOR-encoded value to the underlying output stream.protected long readUIntExact(int expectedLength,
int length)
throws java.io.IOException
expectedLength - the expected length;length - the length indicator to use;java.io.IOException - in case of I/O problems reading the unsigned integer from the underlying input stream.