Class GraphIOUtil
java.lang.Object
io.protostuff.GraphIOUtil
IO Utilities for graph objects (references and cyclic dependencies).
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> intmergeDelimitedFrom(DataInput in, T message, Schema<T> schema) Used by the code generated messages that implementExternalizable.static <T> intmergeDelimitedFrom(InputStream in, T message, Schema<T> schema) static <T> intmergeDelimitedFrom(InputStream in, T message, Schema<T> schema, LinkedBuffer buffer) static <T> voidMerges themessagewith the byte array using the givenschema.static <T> voidMerges themessagewith the byte array using the givenschema.static <T> voidmergeFrom(CodedInput input, T message, Schema<T> schema) static <T> voidmergeFrom(InputStream in, T message, Schema<T> schema) static <T> voidmergeFrom(InputStream in, T message, Schema<T> schema, LinkedBuffer buffer) static <T> booleanoptMergeDelimitedFrom(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> booleanoptMergeDelimitedFrom(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> intoptWriteDelimitedTo(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> byte[]toByteArray(T message, Schema<T> schema, LinkedBuffer buffer) Serializes themessageinto a byte array using the given schema.static <T> intwriteDelimitedTo(DataOutput out, T message, Schema<T> schema) Used by the code generated messages that implementExternalizable.static <T> intwriteDelimitedTo(OutputStream out, T message, Schema<T> schema, LinkedBuffer buffer) Serializes themessage, prefixed with its length, into anOutputStream.static <T> intwriteTo(LinkedBuffer buffer, T message, Schema<T> schema) Writes themessageinto theLinkedBufferusing the given schema.static <T> intwriteTo(OutputStream out, T message, Schema<T> schema, LinkedBuffer buffer) Serializes themessageinto anOutputStreamusing the given schema.
-
Constructor Details
-
GraphIOUtil
private GraphIOUtil()
-
-
Method Details
-
mergeFrom
Merges themessagewith the byte array using the givenschema. -
mergeFrom
Merges themessagewith the byte array using the givenschema. -
mergeFrom
- Throws:
IOException
-
mergeFrom
- Throws:
IOException
-
mergeFrom
public static <T> void mergeFrom(InputStream in, T message, Schema<T> schema, LinkedBuffer buffer) throws IOException Merges themessagefrom theInputStreamusing the givenschema.The
buffer's internal byte array will be used for reading the message.- Throws:
IOException
-
mergeDelimitedFrom
public static <T> int mergeDelimitedFrom(InputStream in, T message, Schema<T> schema) throws IOException - Returns:
- the size of the message
- Throws:
IOException
-
mergeDelimitedFrom
public static <T> int mergeDelimitedFrom(InputStream in, T message, Schema<T> schema, LinkedBuffer buffer) throws IOException Merges themessage(delimited) from theInputStreamusing the givenschema.The delimited message size must not be larger than the
buffer's size/capacity.ProtobufException"size limit exceeded" is thrown otherwise.- Returns:
- the size of the message
- Throws:
IOException
-
mergeDelimitedFrom
public static <T> int mergeDelimitedFrom(DataInput in, T message, Schema<T> schema) throws IOException Used by the code generated messages that implementExternalizable. Merges from theDataInput.- Returns:
- the size of the message
- Throws:
IOException
-
toByteArray
Serializes themessageinto a byte array using the given schema.- Returns:
- the byte array containing the data.
-
writeTo
Writes themessageinto theLinkedBufferusing the given schema.- Returns:
- the size of the message
-
writeTo
public static <T> int writeTo(OutputStream out, T message, Schema<T> schema, LinkedBuffer buffer) throws IOException Serializes themessageinto anOutputStreamusing the given schema.- Returns:
- the size of the message
- Throws:
IOException
-
writeDelimitedTo
public static <T> int writeDelimitedTo(OutputStream out, T message, Schema<T> schema, LinkedBuffer buffer) throws IOException Serializes themessage, prefixed with its length, into anOutputStream.- Returns:
- the size of the message
- Throws:
IOException
-
writeDelimitedTo
public static <T> int writeDelimitedTo(DataOutput out, T message, Schema<T> schema) throws IOException Used by the code generated messages that implementExternalizable. Writes to theDataOutput.- Returns:
- the size of the message.
- Throws:
IOException
-
optMergeDelimitedFrom
public static <T> boolean optMergeDelimitedFrom(InputStream in, T message, Schema<T> schema, LinkedBuffer buffer) throws IOException Optimal/Optional mergeDelimitedFrom - If the message does not fit the buffer, no merge is done and this method will return false.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.
- Throws:
IOException
-
optMergeDelimitedFrom
public static <T> boolean optMergeDelimitedFrom(InputStream in, T message, Schema<T> schema, boolean drainRemainingBytesIfTooLarge, LinkedBuffer buffer) throws IOException Optimal/Optional mergeDelimitedFrom - If the message does not fit the buffer, no merge is done and this method will return false.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).
- Throws:
IOException
-
optWriteDelimitedTo
public static <T> int optWriteDelimitedTo(OutputStream out, T message, Schema<T> schema, LinkedBuffer buffer) throws IOException Optimal writeDelimitedTo - The varint32 prefix is written to the buffer instead of directly writing to outputstream.- Returns:
- the size of the message
- Throws:
IOException
-