public final class ProtostuffIOUtil extends Object
| Modifier and Type | Method and Description |
|---|---|
static <T> int |
mergeDelimitedFrom(DataInput in,
T message,
Schema<T> schema)
Used by the code generated messages that implement
Externalizable. |
static <T> int |
mergeDelimitedFrom(InputStream in,
T message,
Schema<T> schema)
|
static <T> int |
mergeDelimitedFrom(InputStream in,
T message,
Schema<T> schema,
LinkedBuffer buffer)
|
static <T> void |
mergeFrom(byte[] data,
int offset,
int length,
T message,
Schema<T> schema)
Merges the
message with the byte array using the given schema. |
static <T> void |
mergeFrom(byte[] data,
T message,
Schema<T> schema)
Merges the
message with the byte array using the given schema. |
static <T> void |
mergeFrom(InputStream in,
T message,
Schema<T> schema)
|
static <T> void |
mergeFrom(InputStream in,
T message,
Schema<T> schema,
LinkedBuffer buffer)
|
static Pipe |
newPipe(byte[] data)
Creates a protostuff pipe from a byte array.
|
static Pipe |
newPipe(byte[] data,
int offset,
int len)
Creates a protostuff pipe from a byte array.
|
static Pipe |
newPipe(InputStream in)
Creates a protostuff pipe from an
InputStream. |
static <T> boolean |
optMergeDelimitedFrom(InputStream in,
T message,
Schema<T> schema,
boolean drainRemainingBytesIfTooLarge,
LinkedBuffer buffer)
Optimal/Optional mergeDelimitedFrom - If the message does not fit the buffer, no merge is done and this method
will return false.
|
static <T> boolean |
optMergeDelimitedFrom(InputStream in,
T message,
Schema<T> schema,
LinkedBuffer buffer)
Optimal/Optional mergeDelimitedFrom - If the message does not fit the buffer, no merge is done and this method
will return false.
|
static <T> int |
optWriteDelimitedTo(OutputStream out,
T message,
Schema<T> schema,
LinkedBuffer buffer)
Optimal writeDelimitedTo - The varint32 prefix is written to the buffer instead of directly writing to
outputstream.
|
static <T> List<T> |
parseListFrom(InputStream in,
Schema<T> schema)
|
static <T> byte[] |
toByteArray(T message,
Schema<T> schema,
LinkedBuffer buffer)
Serializes the
message into a byte array using the given schema. |
static <T> int |
writeDelimitedTo(DataOutput out,
T message,
Schema<T> schema)
Used by the code generated messages that implement
Externalizable. |
static <T> int |
writeDelimitedTo(OutputStream out,
T message,
Schema<T> schema,
LinkedBuffer buffer)
Serializes the
message, prefixed with its length, into an OutputStream. |
static <T> int |
writeListTo(OutputStream out,
List<T> messages,
Schema<T> schema,
LinkedBuffer buffer)
Serializes the
messages (delimited) into an OutputStream using the given schema. |
static <T> int |
writeTo(LinkedBuffer buffer,
T message,
Schema<T> schema)
Writes the
message into the LinkedBuffer using the given schema. |
static <T> int |
writeTo(OutputStream out,
T message,
Schema<T> schema,
LinkedBuffer buffer)
Serializes the
message into an OutputStream using the given schema. |
public static Pipe newPipe(byte[] data)
public static Pipe newPipe(byte[] data, int offset, int len)
public static Pipe newPipe(InputStream in)
InputStream.public static <T> void mergeFrom(byte[] data,
T message,
Schema<T> schema)
message with the byte array using the given schema.public static <T> void mergeFrom(byte[] data,
int offset,
int length,
T message,
Schema<T> schema)
message with the byte array using the given schema.public static <T> void mergeFrom(InputStream in, T message, Schema<T> schema) throws IOException
IOExceptionpublic static <T> void mergeFrom(InputStream in, T message, Schema<T> schema, LinkedBuffer buffer) throws IOException
message from the InputStream using the given schema.
The buffer's internal byte array will be used for reading the message.
IOExceptionpublic static <T> int mergeDelimitedFrom(InputStream in, T message, Schema<T> schema) throws IOException
IOExceptionpublic static <T> int mergeDelimitedFrom(InputStream in, T message, Schema<T> schema, LinkedBuffer buffer) throws IOException
message (delimited) from the InputStream using the given schema.
The delimited message size must not be larger than the buffer's size/capacity. ProtobufException
"size limit exceeded" is thrown otherwise.
IOExceptionpublic static <T> int mergeDelimitedFrom(DataInput in, T message, Schema<T> schema) throws IOException
Externalizable. Merges from the
DataInput.IOExceptionpublic static <T> byte[] toByteArray(T message,
Schema<T> schema,
LinkedBuffer buffer)
message into a byte array using the given schema.public static <T> int writeTo(LinkedBuffer buffer, T message, Schema<T> schema)
message into the LinkedBuffer using the given schema.public static <T> int writeTo(OutputStream out, T message, Schema<T> schema, LinkedBuffer buffer) throws IOException
message into an OutputStream using the given schema.IOExceptionpublic static <T> int writeDelimitedTo(OutputStream out, T message, Schema<T> schema, LinkedBuffer buffer) throws IOException
message, prefixed with its length, into an OutputStream.IOExceptionpublic static <T> int writeDelimitedTo(DataOutput out, T message, Schema<T> schema) throws IOException
Externalizable. Writes to the
DataOutput .IOExceptionpublic static <T> int writeListTo(OutputStream out, List<T> messages, Schema<T> schema, LinkedBuffer buffer) throws IOException
messages (delimited) into an OutputStream using the given schema.IOExceptionpublic static <T> List<T> parseListFrom(InputStream in, Schema<T> schema) throws IOException
IOExceptionpublic static <T> boolean optMergeDelimitedFrom(InputStream in, T message, Schema<T> schema, LinkedBuffer buffer) throws IOException
This is strictly for reading a single message from the stream because the buffer is aggressively filled when reading the delimited size (which could result into reading more bytes than it has to).
The remaining bytes will be drained (consumed and discared) when the message is too large.
IOExceptionpublic static <T> boolean optMergeDelimitedFrom(InputStream in, T message, Schema<T> schema, boolean drainRemainingBytesIfTooLarge, LinkedBuffer buffer) throws IOException
This is strictly for reading a single message from the stream because the buffer is aggressively filled when reading the delimited size (which could result into reading more bytes than it has to).
IOExceptionpublic static <T> int optWriteDelimitedTo(OutputStream out, T message, Schema<T> schema, LinkedBuffer buffer) throws IOException
IOExceptionCopyright © 2009–2022. All rights reserved.