Class ProtocolBuffers


  • @Beta
    public class ProtocolBuffers
    extends java.lang.Object
    Beta
    Utilities for protocol buffers.

    There is no official media type for protocol buffers registered with the IANA. CONTENT_TYPE and ALT_CONTENT_TYPE are some of the more popular choices being used today, but other media types are also in use.

    Since:
    1.5
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String ALT_CONTENT_TYPE
      "application/x-protobuffer" content type.
      static java.lang.String CONTENT_TYPE
      "application/x-protobuf" content type.
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private ProtocolBuffers()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static <T extends com.google.protobuf.MessageLite>
      T
      parseAndClose​(java.io.InputStream inputStream, java.lang.Class<T> messageClass)
      Parses protocol buffer content from an input stream (closing the input stream) into a protocol buffer message.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • CONTENT_TYPE

        public static final java.lang.String CONTENT_TYPE
        "application/x-protobuf" content type.
        See Also:
        Constant Field Values
      • ALT_CONTENT_TYPE

        public static final java.lang.String ALT_CONTENT_TYPE
        "application/x-protobuffer" content type.
        See Also:
        Constant Field Values
    • Constructor Detail

      • ProtocolBuffers

        private ProtocolBuffers()
    • Method Detail

      • parseAndClose

        public static <T extends com.google.protobuf.MessageLite> T parseAndClose​(java.io.InputStream inputStream,
                                                                                  java.lang.Class<T> messageClass)
                                                                           throws java.io.IOException
        Parses protocol buffer content from an input stream (closing the input stream) into a protocol buffer message.
        Type Parameters:
        T - destination message type
        Parameters:
        messageClass - destination message class that has a parseFrom(InputStream) public static method
        Returns:
        new instance of the parsed destination message class
        Throws:
        java.io.IOException