Package co.nstant.in.cbor
Class CborEncoder
- java.lang.Object
-
- co.nstant.in.cbor.CborEncoder
-
public class CborEncoder extends Object
Encoder for the CBOR format based.
-
-
Constructor Summary
Constructors Constructor Description CborEncoder(OutputStream outputStream)Initialize a new encoder which writes the binary encoded data to anOutputStream.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidencode(DataItem dataItem)Encode a singleDataItem.voidencode(List<DataItem> dataItems)Encode a list ofDataItems, also known as a stream.booleanisCanonical()CborEncodernonCanonical()
-
-
-
Constructor Detail
-
CborEncoder
public CborEncoder(OutputStream outputStream)
Initialize a new encoder which writes the binary encoded data to anOutputStream.- Parameters:
outputStream- theOutputStreamto write the encoded data to
-
-
Method Detail
-
encode
public void encode(List<DataItem> dataItems) throws CborException
Encode a list ofDataItems, also known as a stream.- Parameters:
dataItems- a list ofDataItems- Throws:
CborException- if theDataItems could not be encoded or there was an problem with theOutputStream.
-
encode
public void encode(DataItem dataItem) throws CborException
Encode a singleDataItem.- Parameters:
dataItem- theDataItemto encode. If null, encoder encodes aSimpleValueNULL value.- Throws:
CborException- ifDataItemcould not be encoded or there was an problem with theOutputStream.
-
isCanonical
public boolean isCanonical()
-
nonCanonical
public CborEncoder nonCanonical()
-
-