Class BinaryReader

java.lang.Object
com.google.protobuf.BinaryReader
All Implemented Interfaces:
Reader
Direct Known Subclasses:
BinaryReader.SafeHeapReader

@CheckReturnValue @ExperimentalApi abstract class BinaryReader extends Object implements Reader
A Reader that reads from a buffer containing a message serialized with the binary protocol.
  • Field Details

  • Constructor Details

    • BinaryReader

      private BinaryReader()
      Only allow subclassing for inner classes.
  • Method Details

    • newInstance

      public static BinaryReader newInstance(ByteBuffer buffer, boolean bufferIsImmutable)
      Creates a new reader using the given buffer as input.
      Parameters:
      buffer - the input buffer. The buffer (including position, limit, etc.) will not be modified. To increment the buffer position after the read completes, use the value returned by getTotalBytesRead().
      bufferIsImmutable - if true the reader assumes that the content of buffer will never change and any allocated ByteString instances will by directly wrap slices of buffer.
      Returns:
      the reader
    • getTotalBytesRead

      public abstract int getTotalBytesRead()
      Returns the total number of bytes read so far from the input buffer.
    • shouldDiscardUnknownFields

      public boolean shouldDiscardUnknownFields()
      Specified by:
      shouldDiscardUnknownFields in interface Reader