Class PrototextR


public class PrototextR extends Prototext
A Prototext variant that produces readable (whitespace-padded) Protobuf Text Format output.

This is the first-class facade form of the readable Prototext variant. It pairs PrototextSerializer.DEFAULT_READABLE with PrototextParser.DEFAULT and exposes the full static shortcut surface bound to its own DEFAULT instance.

Examples:

// Using static shortcuts. String proto = PrototextR.of(myPojo); MyPojo myPojo = PrototextR.to(proto, MyPojo.class);

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

    • DEFAULT

      public static final PrototextR DEFAULT
      Default reusable instance, readable format.
  • Constructor Details

    • PrototextR

      public PrototextR()
      Constructor.

      Uses PrototextSerializer.DEFAULT_READABLE and PrototextParser.DEFAULT.

  • Method Details

    • of

      public static String of(Object object) throws SerializeException
      Serializes a POJO to a String 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(String 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(String 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(Reader input, Class<T> type) throws ParseException
      Parses the contents of a Reader 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 reader.
      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(Reader input, Type type, Type... args) throws ParseException
      Parses the contents of a Reader 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 reader.
      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, Writer output) throws SerializeException
      Serializes a POJO to the specified Writer 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 writer to serialize to.
      Throws:
      SerializeException - If a problem occurred trying to convert the output or an I/O error occurred on the underlying stream.
    • 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.