Package io.protostuff
Class IOUtil
- java.lang.Object
-
- io.protostuff.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 theInputStream
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 implementExternalizable
.(package private) static <T> int
mergeDelimitedFrom(java.io.InputStream in, byte[] buf, T message, Schema<T> schema, boolean decodeNestedMessageAsGroup)
Thebuf
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 themessage
(delimited) from theInputStream
using the givenschema
.(package private) static <T> void
mergeFrom(byte[] data, int offset, int length, T message, Schema<T> schema, boolean decodeNestedMessageAsGroup)
Merges themessage
with the byte array using the givenschema
.(package private) static <T> void
mergeFrom(java.io.InputStream in, byte[] buf, T message, Schema<T> schema, boolean decodeNestedMessageAsGroup)
Merges themessage
from theInputStream
with the suppliedbuf
to use.(package private) static <T> void
mergeFrom(java.io.InputStream in, T message, Schema<T> schema, boolean decodeNestedMessageAsGroup)
Merges themessage
from theInputStream
using the givenschema
.(package private) static int
putVarInt32AndGetOffset(int value, byte[] buffer, int variableOffset)
Returns the offset where the first byte is written.
-
-
-
Method Detail
-
mergeFrom
static <T> void mergeFrom(byte[] data, int offset, int length, T message, Schema<T> schema, boolean decodeNestedMessageAsGroup)
Merges themessage
with the byte array using the givenschema
.
-
mergeFrom
static <T> void mergeFrom(java.io.InputStream in, byte[] buf, T message, Schema<T> schema, boolean decodeNestedMessageAsGroup) throws java.io.IOException
Merges themessage
from theInputStream
with the suppliedbuf
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 themessage
from theInputStream
using the givenschema
.- 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
Thebuf
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 themessage
(delimited) from theInputStream
using the givenschema
.- 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 implementExternalizable
. Merges from theDataInput
.- 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 theInputStream
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 thevariableOffset
.
-
-