Package io.protostuff

Class IOUtil

java.lang.Object
io.protostuff.IOUtil

final class IOUtil extends Object
Common io utils for the supported formats.
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    private
     
  • Method Summary

    Modifier and Type
    Method
    Description
    (package private) static void
    fillBufferFrom(InputStream in, byte[] buf, int offset, int len)
    Fills the byte buffer from the InputStream with the specified length.
    (package private) static int
    fillBufferWithDelimitedMessageFrom(InputStream in, boolean drainRemainingBytesIfTooLarge, LinkedBuffer lb)
    Fills the buffer based from the varint32 read from the input stream.
    (package private) static <T> int
    mergeDelimitedFrom(DataInput in, T message, Schema<T> schema, boolean decodeNestedMessageAsGroup)
    Used by the code generated messages that implement Externalizable.
    (package private) static <T> int
    mergeDelimitedFrom(InputStream in, byte[] buf, T message, Schema<T> schema, boolean decodeNestedMessageAsGroup)
    The buf size limits the size of the message that must be read.
    (package private) static <T> int
    mergeDelimitedFrom(InputStream in, T message, Schema<T> schema, boolean decodeNestedMessageAsGroup)
    Merges the message (delimited) from the InputStream using the given schema.
    (package private) static <T> void
    mergeFrom(byte[] data, int offset, int length, T message, Schema<T> schema, boolean decodeNestedMessageAsGroup)
    Merges the message with the byte array using the given schema.
    (package private) static <T> void
    mergeFrom(InputStream in, byte[] buf, T message, Schema<T> schema, boolean decodeNestedMessageAsGroup)
    Merges the message from the InputStream with the supplied buf to use.
    (package private) static <T> void
    mergeFrom(InputStream in, T message, Schema<T> schema, boolean decodeNestedMessageAsGroup)
    Merges the message from the InputStream using the given schema.
    (package private) static int
    putVarInt32AndGetOffset(int value, byte[] buffer, int variableOffset)
    Returns the offset where the first byte is written.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • IOUtil

      private IOUtil()
  • Method Details

    • mergeFrom

      static <T> void mergeFrom(byte[] data, int offset, int length, T message, Schema<T> schema, boolean decodeNestedMessageAsGroup)
      Merges the message with the byte array using the given schema.
    • mergeFrom

      static <T> void mergeFrom(InputStream in, byte[] buf, T message, Schema<T> schema, boolean decodeNestedMessageAsGroup) throws IOException
      Merges the message from the InputStream with the supplied buf to use.
      Throws:
      IOException
    • mergeFrom

      static <T> void mergeFrom(InputStream in, T message, Schema<T> schema, boolean decodeNestedMessageAsGroup) throws IOException
      Merges the message from the InputStream using the given schema.
      Throws:
      IOException
    • mergeDelimitedFrom

      static <T> int mergeDelimitedFrom(InputStream in, byte[] buf, T message, Schema<T> schema, boolean decodeNestedMessageAsGroup) throws IOException
      The buf size limits the size of the message that must be read. A ProtobufException (sizeLimitExceeded) will be thrown if the size of the delimited message is larger.
      Throws:
      IOException
    • mergeDelimitedFrom

      static <T> int mergeDelimitedFrom(InputStream in, T message, Schema<T> schema, boolean decodeNestedMessageAsGroup) throws IOException
      Merges the message (delimited) from the InputStream using the given schema.
      Throws:
      IOException
    • mergeDelimitedFrom

      static <T> int mergeDelimitedFrom(DataInput in, T message, Schema<T> schema, boolean decodeNestedMessageAsGroup) throws IOException
      Used by the code generated messages that implement Externalizable. Merges from the DataInput.
      Throws:
      IOException
    • fillBufferFrom

      static void fillBufferFrom(InputStream in, byte[] buf, int offset, int len) throws IOException
      Fills the byte buffer from the InputStream with the specified length.
      Throws:
      IOException
    • fillBufferWithDelimitedMessageFrom

      static int fillBufferWithDelimitedMessageFrom(InputStream in, boolean drainRemainingBytesIfTooLarge, LinkedBuffer lb) throws IOException
      Fills the buffer based from the varint32 read from the input stream.

      The buffer's read offset is not set if the data (varint32 size + message size) is too large to fit in the buffer.

      Returns:
      the delimited size read.
      Throws:
      IOException
    • putVarInt32AndGetOffset

      static int putVarInt32AndGetOffset(int value, byte[] buffer, int variableOffset)
      Returns the offset where the first byte is written. This method assumes that 5 bytes will be writable starting at the variableOffset.