public class RdfProto extends StreamMarshaller
A pairing of RdfProtoSerializer and RdfProtoParser for RDF/PROTO binary format.
Examples:

// Serialize a bean or map to RDF/PROTO bytes byte[] bytes = RdfProto.of(myBean); // Parse RDF/PROTO bytes into a bean or map MyPojo parsed = RdfProto.to(bytes, MyPojo.class);

// Using instance methods RdfProto m = RdfProto.DEFAULT; bytes = m.write(myBean); parsed = m.read(bytes, MyPojo.class);

Output is binary (byte[]), Protocol Buffers format.

Complex structures (nested objects, arrays) serialize to equivalent RDF triples in binary form.

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

See Also:
  • Field Details

    • DEFAULT

      public static final RdfProto DEFAULT
      Default reusable instance.
  • Constructor Details

    • RdfProto

      public RdfProto()
      Constructor using defaults.
    • RdfProto

      Constructor with serializer and parser.
      Parameters:
      s - The serializer to use.
      Must not be null.
      p - The parser to use.
      Must not be null.
  • Method Details

    • of

      public static byte[] of(Object object) throws SerializeException
      Serializes a POJO to a byte[] using the DEFAULT marshaller.

      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

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

      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

      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.

      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.