public class CBOREncoder
extends java.lang.Object
The encoder does not enforce map key ordering itself - callers writing maps are responsible for presenting keys in bytewise lexicographic order of their encodings. The structures defined for C509 (draft-ietf-cose-cbor-encoded-cert-21) use no maps.
| Constructor and Description |
|---|
CBOREncoder(java.io.OutputStream out)
Base constructor.
|
| Modifier and Type | Method and Description |
|---|---|
void |
writeArrayHeader(int count)
Write an array header (major type 4) for an array of the given number of elements.
|
void |
writeBoolean(boolean value)
Write a boolean simple value (0xf4 or 0xf5).
|
void |
writeByteString(byte[] bytes)
Write a byte string (major type 2).
|
void |
writeByteString(byte[] bytes,
int off,
int len)
Write a byte string (major type 2) from a slice of an array.
|
void |
writeEncoded(byte[] encodedItem)
Write a complete data item that has already been encoded.
|
void |
writeInteger(java.math.BigInteger value)
Write an integer (major type 0 or 1 according to sign) of any magnitude CBOR
supports (-2^64 to 2^64-1).
|
void |
writeInteger(long value)
Write an integer (major type 0 or 1 according to sign).
|
void |
writeMapHeader(int count)
Write a map header (major type 5) for a map of the given number of key/value
pairs.
|
void |
writeNull()
Write the simple value null (0xf6).
|
void |
writeTag(long tagNumber)
Write a tag (major type 6).
|
void |
writeTextString(java.lang.String text)
Write a text string (major type 3), encoded as UTF-8.
|
void |
writeUndefined()
Write the simple value undefined (0xf7).
|
void |
writeUnsignedInteger(long value)
Write an unsigned integer (major type 0).
|
public CBOREncoder(java.io.OutputStream out)
out - the stream the CBOR encoding is written to.public void writeUnsignedInteger(long value)
throws java.io.IOException
value - the value, which must be non-negative.java.io.IOExceptionpublic void writeInteger(long value)
throws java.io.IOException
java.io.IOExceptionpublic void writeInteger(java.math.BigInteger value)
throws java.io.IOException
java.io.IOExceptionpublic void writeByteString(byte[] bytes)
throws java.io.IOException
java.io.IOExceptionpublic void writeByteString(byte[] bytes,
int off,
int len)
throws java.io.IOException
java.io.IOExceptionpublic void writeTextString(java.lang.String text)
throws java.io.IOException
java.io.IOExceptionpublic void writeArrayHeader(int count)
throws java.io.IOException
java.io.IOExceptionpublic void writeMapHeader(int count)
throws java.io.IOException
java.io.IOExceptionpublic void writeTag(long tagNumber)
throws java.io.IOException
java.io.IOExceptionpublic void writeBoolean(boolean value)
throws java.io.IOException
java.io.IOExceptionpublic void writeNull()
throws java.io.IOException
java.io.IOExceptionpublic void writeUndefined()
throws java.io.IOException
java.io.IOExceptionpublic void writeEncoded(byte[] encodedItem)
throws java.io.IOException
CBORDecoder.readEncodedItem().java.io.IOException