Class CborBase64


public class CborBase64 extends Cbor
A Cbor variant that represents binary values as Base64 text instead of raw CBOR bytes.

This is the first-class facade form of the Base64 CBOR variant. It pairs CborSerializer.DEFAULT_BASE64 with CborParser.DEFAULT_BASE64 and exposes the full static shortcut surface bound to its own DEFAULT instance.

Examples:

// Using static shortcuts. byte[] bytes = CborBase64.of(myPojo); MyPojo myPojo = CborBase64.to(bytes, MyPojo.class);

Notes:
  • Because Java hides (does not override) static members, this class redeclares the entire static shortcut surface of Cbor so that every shortcut is bound to this class's Base64 DEFAULT rather than the Cbor.DEFAULT.
See Also:
  • Field Details

    • DEFAULT

      public static final CborBase64 DEFAULT
      Default reusable instance, Base64 format.
  • Constructor Details

  • Method Details

    • of

      public static byte[] of(Object object) throws SerializeException
      Serializes a POJO to a byte[] using the DEFAULT marshaller.
      Parameters:
      object - The object to serialize.
      Returns:
      The serialized object.
      Throws:
      SerializeException - If a problem occurred trying to convert the output.
    • to

      public static <T> T to(byte[] input, Class<T> type) throws ParseException
      Parses an input into the specified object type using the DEFAULT marshaller.
      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

      public static <T> T to(byte[] input, Type type, Type... args) throws ParseException
      Parses an input into the specified parameterized object type using the DEFAULT marshaller.
      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

      public static <T> T to(InputStream input, Class<T> type) throws ParseException
      Parses the contents of an InputStream into the specified object type using the DEFAULT marshaller.

      Catches any IOException from the underlying stream and rethrows it as an unchecked ParseException.

      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

      public static <T> T to(InputStream input, Type type, Type... args) throws ParseException
      Parses the contents of an InputStream into the specified parameterized object type using the DEFAULT marshaller.

      Catches any IOException from the underlying stream and rethrows it as an unchecked ParseException.

      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

      public static void of(Object object, OutputStream output) throws SerializeException
      Serializes a POJO to the specified OutputStream using the DEFAULT marshaller.

      Catches any IOException from the underlying stream and rethrows it as an unchecked SerializeException.

      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

      public static TokenReader toTokens(Object input) throws IOException
      Opens a low-level TokenReader cursor over the specified input using the DEFAULT marshaller.
      Parameters:
      input - The input.
      Returns:
      A new TokenReader.
      Throws:
      IOException - If a problem occurred opening the underlying input.
    • ofTokens

      public static TokenWriter ofTokens(Object output) throws IOException
      Opens a low-level TokenWriter generator over the specified output using the DEFAULT marshaller.
      Parameters:
      output - The output.
      Returns:
      A new TokenWriter.
      Throws:
      IOException - If a problem occurred opening the underlying output.
    • toRecords

      public static RecordReader toRecords(Object input) throws IOException
      Opens a low-level RecordReader cursor over the specified input using the DEFAULT marshaller.
      Parameters:
      input - The input.
      Returns:
      A new RecordReader.
      Throws:
      IOException - If a problem occurred opening the underlying input.
    • ofRecords

      public static RecordWriter ofRecords(Object output) throws IOException
      Opens a low-level RecordWriter cursor over the specified output using the DEFAULT marshaller.
      Parameters:
      output - The output.
      Returns:
      A new RecordWriter.
      Throws:
      IOException - If a problem occurred opening the underlying output.
    • toArrayRecords

      public static RecordReader toArrayRecords(Object input) throws IOException
      Opens a RecordReader that yields each element of a top-level wire array using the DEFAULT marshaller.
      Parameters:
      input - The input.
      Returns:
      A new RecordReader.
      Throws:
      IOException - If a problem occurred opening the underlying input.
    • ofArrayRecords

      public static RecordWriter ofArrayRecords(Object output) throws IOException
      Opens a RecordWriter that wraps each written value as one element of a top-level wire array using the DEFAULT marshaller.
      Parameters:
      output - The output.
      Returns:
      A new RecordWriter.
      Throws:
      IOException - If a problem occurred opening the underlying output.