aboutsummaryrefslogtreecommitdiffstats
path: root/java/src/main/java/com/google/protobuf/nano/MessageNano.java
diff options
context:
space:
mode:
Diffstat (limited to 'java/src/main/java/com/google/protobuf/nano/MessageNano.java')
-rw-r--r--java/src/main/java/com/google/protobuf/nano/MessageNano.java15
1 files changed, 9 insertions, 6 deletions
diff --git a/java/src/main/java/com/google/protobuf/nano/MessageNano.java b/java/src/main/java/com/google/protobuf/nano/MessageNano.java
index e95c514..82dc6cc 100644
--- a/java/src/main/java/com/google/protobuf/nano/MessageNano.java
+++ b/java/src/main/java/com/google/protobuf/nano/MessageNano.java
@@ -67,16 +67,20 @@ public abstract class MessageNano {
}
/**
- * Serializes the message and writes it to {@code output}. This does not
- * flush or close the stream.
+ * Serializes the message and writes it to {@code output}.
+ *
+ * @param output the output to receive the serialized form.
+ * @throws IOException if an error occurred writing to {@code output}.
*/
- abstract public void writeTo(CodedOutputByteBufferNano output) throws java.io.IOException;
+ public void writeTo(CodedOutputByteBufferNano output) throws IOException {
+ // Does nothing by default. Overridden by subclasses which have data to write.
+ }
/**
* Parse {@code input} as a message of this type and merge it with the
* message being built.
*/
- abstract public MessageNano mergeFrom(final CodedInputByteBufferNano input) throws IOException;
+ public abstract MessageNano mergeFrom(CodedInputByteBufferNano input) throws IOException;
/**
* Serialize to a byte array.
@@ -95,9 +99,8 @@ public abstract class MessageNano {
* write more than length bytes OutOfSpaceException will be thrown
* and if length bytes are not written then IllegalStateException
* is thrown.
- * @return byte array with the serialized data.
*/
- public static final void toByteArray(MessageNano msg, byte [] data, int offset, int length) {
+ public static final void toByteArray(MessageNano msg, byte[] data, int offset, int length) {
try {
final CodedOutputByteBufferNano output =
CodedOutputByteBufferNano.newInstance(data, offset, length);