Class ProtoInputStream

  • All Implemented Interfaces:
    Drainable, KnownLength, java.io.Closeable, java.lang.AutoCloseable

    final class ProtoInputStream
    extends java.io.InputStream
    implements Drainable, KnownLength
    An InputStream backed by a protobuf.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private com.google.protobuf.MessageLite message  
      private com.google.protobuf.Parser<?> parser  
      private java.io.ByteArrayInputStream partial  
    • Constructor Summary

      Constructors 
      Constructor Description
      ProtoInputStream​(com.google.protobuf.MessageLite message, com.google.protobuf.Parser<?> parser)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int available()
      Returns the total number of bytes that can be read (or skipped over) from this object until all bytes have been read out.
      int drainTo​(java.io.OutputStream target)
      Transfers the entire contents of this stream to the specified target.
      (package private) com.google.protobuf.MessageLite message()  
      (package private) com.google.protobuf.Parser<?> parser()  
      int read()  
      int read​(byte[] b, int off, int len)  
      • Methods inherited from class java.io.InputStream

        close, mark, markSupported, read, reset, skip
      • Methods inherited from class java.lang.Object

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

      • message

        @Nullable
        private com.google.protobuf.MessageLite message
      • parser

        private final com.google.protobuf.Parser<?> parser
      • partial

        @Nullable
        private java.io.ByteArrayInputStream partial
    • Constructor Detail

      • ProtoInputStream

        ProtoInputStream​(com.google.protobuf.MessageLite message,
                         com.google.protobuf.Parser<?> parser)
    • Method Detail

      • drainTo

        public int drainTo​(java.io.OutputStream target)
                    throws java.io.IOException
        Description copied from interface: Drainable
        Transfers the entire contents of this stream to the specified target.
        Specified by:
        drainTo in interface Drainable
        Parameters:
        target - to write to.
        Returns:
        number of bytes written.
        Throws:
        java.io.IOException
      • read

        public int read()
        Specified by:
        read in class java.io.InputStream
      • read

        public int read​(byte[] b,
                        int off,
                        int len)
                 throws java.io.IOException
        Overrides:
        read in class java.io.InputStream
        Throws:
        java.io.IOException
      • available

        public int available()
        Description copied from interface: KnownLength
        Returns the total number of bytes that can be read (or skipped over) from this object until all bytes have been read out.
        Specified by:
        available in interface KnownLength
        Overrides:
        available in class java.io.InputStream
      • message

        com.google.protobuf.MessageLite message()
      • parser

        com.google.protobuf.Parser<?> parser()