Package io.protostuff
Class IOUtil
java.lang.Object
io.protostuff.IOUtil
Common io utils for the supported formats.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) static void
fillBufferFrom
(InputStream in, byte[] buf, int offset, int len) Fills the byte buffer from theInputStream
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 implementExternalizable
.(package private) static <T> int
mergeDelimitedFrom
(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
(InputStream in, T message, Schema<T> schema, boolean decodeNestedMessageAsGroup) (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
(InputStream in, byte[] buf, T message, Schema<T> schema, boolean decodeNestedMessageAsGroup) (package private) static <T> void
mergeFrom
(InputStream in, T message, Schema<T> schema, boolean decodeNestedMessageAsGroup) (package private) static int
putVarInt32AndGetOffset
(int value, byte[] buffer, int variableOffset) Returns the offset where the first byte is written.
-
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 themessage
with the byte array using the givenschema
. -
mergeFrom
static <T> void mergeFrom(InputStream in, byte[] buf, T message, Schema<T> schema, boolean decodeNestedMessageAsGroup) throws IOException - Throws:
IOException
-
mergeFrom
static <T> void mergeFrom(InputStream in, T message, Schema<T> schema, boolean decodeNestedMessageAsGroup) throws IOException - Throws:
IOException
-
mergeDelimitedFrom
static <T> int mergeDelimitedFrom(InputStream in, byte[] buf, T message, Schema<T> schema, boolean decodeNestedMessageAsGroup) throws 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:
IOException
-
mergeDelimitedFrom
static <T> int mergeDelimitedFrom(InputStream in, T message, Schema<T> schema, boolean decodeNestedMessageAsGroup) throws IOException - 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 implementExternalizable
. Merges from theDataInput
.- Throws:
IOException
-
fillBufferFrom
Fills the byte buffer from theInputStream
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 thevariableOffset
.
-