Class Cbor
- Direct Known Subclasses:
CborBase64,CborNative,CborSpacedHex
CborSerializer and CborParser into a single class with convenience read/write methods.
Output is binary () in RFC 8949 CBOR format.
Examples:
See Also:
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic byte[]Serializes a POJO to ausing thebyte []DEFAULTmarshaller.static voidof(Object object, OutputStream output) Serializes a POJO to the specifiedOutputStreamusing theDEFAULTmarshaller.static RecordWriterofArrayRecords(Object output) Opens aRecordWriterthat wraps each written value as one element of a top-level wire array using theDEFAULTmarshaller.static RecordWriterOpens a low-levelRecordWritercursor over the specified output using theDEFAULTmarshaller.static TokenWriterOpens a low-levelTokenWritergenerator over the specified output using theDEFAULTmarshaller.static <T> TParses an input into the specified object type using theDEFAULTmarshaller.static <T> TParses an input into the specified parameterized object type using theDEFAULTmarshaller.static <T> Tto(InputStream input, Class<T> type) Parses the contents of anInputStreaminto the specified object type using theDEFAULTmarshaller.static <T> Tto(InputStream input, Type type, Type... args) Parses the contents of anInputStreaminto the specified parameterized object type using theDEFAULTmarshaller.static RecordReadertoArrayRecords(Object input) Opens aRecordReaderthat yields each element of a top-level wire array using theDEFAULTmarshaller.static RecordReaderOpens a low-levelRecordReadercursor over the specified input using theDEFAULTmarshaller.static TokenReaderOpens a low-levelTokenReadercursor over the specified input using theDEFAULTmarshaller.Methods inherited from class org.apache.juneau.marshall.marshaller.StreamMarshaller
read, read, writeMethods inherited from class org.apache.juneau.marshall.marshaller.Marshaller
getParser, getSerializer, read, read, readArrayRecords, readRecords, readTokens, write, writeArrayRecords, writeRecords, writeTokens
-
Field Details
-
DEFAULT
Default reusable instance.
-
-
Constructor Details
-
Cbor
public Cbor()Constructor.Uses
CborSerializer.DEFAULTandCborParser.DEFAULT. -
Cbor
Constructor.- Parameters:
s- The serializer to use for serializing output.p- The parser to use for parsing input.
-
-
Method Details
-
of
Serializes a POJO to ausing thebyte []DEFAULTmarshaller.A shortcut for calling
.DEFAULT .write(object )- Parameters:
object- The object to serialize.- Returns:
- The serialized object.
- Throws:
SerializeException- If a problem occurred trying to convert the output.
-
to
Parses an input into the specified object type using theDEFAULTmarshaller.A shortcut for calling
.DEFAULT .read(input ,type )- Type Parameters:
T- The class type of the object being created.- Parameters:
input- The input.type- The object type to create.- Returns:
- The parsed object.
- Throws:
ParseException- Malformed input encountered.
-
to
Parses an input into the specified parameterized object type using theDEFAULTmarshaller.A shortcut for calling
.DEFAULT .read(input ,type ,args )- Type Parameters:
T- The class type of the object to create.- Parameters:
input- The input.type- The object type to create.args- The type arguments of the class if it's a collection or map.- Returns:
- The parsed object.
- Throws:
ParseException- Malformed input encountered.
-
to
Parses the contents of anInputStreaminto the specified object type using theDEFAULTmarshaller.A shortcut for calling
that catches anyDEFAULT .read(input ,type )IOExceptionfrom the underlying stream and rethrows it as an uncheckedParseException, so the caller is not burdened with a checked exception.- Type Parameters:
T- The class type of the object being created.- Parameters:
input- The input stream.type- The object type to create.- Returns:
- The parsed object.
- Throws:
ParseException- Malformed input encountered or an I/O error occurred on the underlying stream.
-
to
Parses the contents of anInputStreaminto the specified parameterized object type using theDEFAULTmarshaller.A shortcut for calling
that catches anyDEFAULT .read(input ,type ,args )IOExceptionfrom the underlying stream and rethrows it as an uncheckedParseException, so the caller is not burdened with a checked exception.- Type Parameters:
T- The class type of the object to create.- Parameters:
input- The input stream.type- The object type to create.args- The type arguments of the class if it's a collection or map.- Returns:
- The parsed object.
- Throws:
ParseException- Malformed input encountered or an I/O error occurred on the underlying stream.
-
of
Serializes a POJO to the specifiedOutputStreamusing theDEFAULTmarshaller.A shortcut for calling
that catches anyDEFAULT .write(object ,output )IOExceptionfrom the underlying stream and rethrows it as an uncheckedSerializeException, so the caller is not burdened with a checked exception.- Parameters:
object- The object to serialize.output- The output stream to serialize to.- Throws:
SerializeException- If a problem occurred trying to convert the output or an I/O error occurred on the underlying stream.
-
toTokens
Opens a low-levelTokenReadercursor over the specified input using theDEFAULTmarshaller.A shortcut for calling
.DEFAULT .readTokens(input )- Parameters:
input- The input.- Returns:
- A new
TokenReader. - Throws:
IOException- If a problem occurred opening the underlying input.
-
ofTokens
Opens a low-levelTokenWritergenerator over the specified output using theDEFAULTmarshaller.A shortcut for calling
.DEFAULT .writeTokens(output )- Parameters:
output- The output.- Returns:
- A new
TokenWriter. - Throws:
IOException- If a problem occurred opening the underlying output.
-
toRecords
Opens a low-levelRecordReadercursor over the specified input using theDEFAULTmarshaller.A shortcut for calling
.DEFAULT .readRecords(input )- Parameters:
input- The input.- Returns:
- A new
RecordReader. - Throws:
IOException- If a problem occurred opening the underlying input.
-
ofRecords
Opens a low-levelRecordWritercursor over the specified output using theDEFAULTmarshaller.A shortcut for calling
.DEFAULT .writeRecords(output )- Parameters:
output- The output.- Returns:
- A new
RecordWriter. - Throws:
IOException- If a problem occurred opening the underlying output.
-
toArrayRecords
Opens aRecordReaderthat yields each element of a top-level wire array using theDEFAULTmarshaller.A shortcut for calling
.DEFAULT .readArrayRecords(input )- Parameters:
input- The input.- Returns:
- A new
RecordReader. - Throws:
IOException- If a problem occurred opening the underlying input.
-
ofArrayRecords
Opens aRecordWriterthat wraps each written value as one element of a top-level wire array using theDEFAULTmarshaller.A shortcut for calling
.DEFAULT .writeArrayRecords(output )- Parameters:
output- The output.- Returns:
- A new
RecordWriter. - Throws:
IOException- If a problem occurred opening the underlying output.
-