Package io.protostuff

Class IOUtil


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

      Constructors 
      Modifier Constructor Description
      private IOUtil()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      (package private) static void fillBufferFrom​(java.io.InputStream in, byte[] buf, int offset, int len)
      Fills the byte buffer from the InputStream with the specified length.
      (package private) static int fillBufferWithDelimitedMessageFrom​(java.io.InputStream in, boolean drainRemainingBytesIfTooLarge, LinkedBuffer lb)
      Fills the buffer based from the varint32 read from the input stream.
      (package private) static <T> int mergeDelimitedFrom​(java.io.DataInput in, T message, Schema<T> schema, boolean decodeNestedMessageAsGroup)
      Used by the code generated messages that implement Externalizable.
      (package private) static <T> int mergeDelimitedFrom​(java.io.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​(java.io.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​(java.io.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​(java.io.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 Detail

      • IOUtil

        private IOUtil()
    • Method Detail

      • 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​(java.io.InputStream in,
                                  byte[] buf,
                                  T message,
                                  Schema<T> schema,
                                  boolean decodeNestedMessageAsGroup)
                           throws java.io.IOException
        Merges the message from the InputStream with the supplied buf to use.
        Throws:
        java.io.IOException
      • mergeFrom

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

        static <T> int mergeDelimitedFrom​(java.io.InputStream in,
                                          byte[] buf,
                                          T message,
                                          Schema<T> schema,
                                          boolean decodeNestedMessageAsGroup)
                                   throws java.io.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:
        java.io.IOException
      • mergeDelimitedFrom

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

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

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

        static int fillBufferWithDelimitedMessageFrom​(java.io.InputStream in,
                                                      boolean drainRemainingBytesIfTooLarge,
                                                      LinkedBuffer lb)
                                               throws java.io.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:
        java.io.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.