- java.lang.Object
-
- de.haumacher.msgbuf.data.AbstractDataObject
-
- All Implemented Interfaces:
DataObject
- Direct Known Subclasses:
Command
public abstract class AbstractDataObject extends Object implements DataObject
Base class forDataObjectimplementations.
-
-
Constructor Summary
Constructors Constructor Description AbstractDataObject()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidreadContent(JsonReader in)Reads a JSON object containing keys for all fields of this object.protected voidreadField(JsonReader in, String field)Reads the given field from the given input.protected voidreadFields(JsonReader in)Reads all fields of this instance from the given input.StringtoString()voidwriteContent(JsonWriter out)Writes a JSON object containing keys for all fields of this object.protected voidwriteFields(JsonWriter out)Writes all fields of this instance to the given output.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface de.haumacher.msgbuf.data.DataObject
writeTo
-
-
-
-
Method Detail
-
writeContent
public final void writeContent(JsonWriter out) throws IOException
Description copied from interface:DataObjectWrites a JSON object containing keys for all fields of this object.In contrast to
DataObject.writeTo(JsonWriter), the resulting object contains no type information. Therefore, this method must only be called directly, if the reader knows the type of the object to read from the context. For reading the data, a per-type generatedread[type-name]()method must be called.- Specified by:
writeContentin interfaceDataObject- Parameters:
out- The writer to write to.- Throws:
IOException
-
writeFields
protected void writeFields(JsonWriter out) throws IOException
Writes all fields of this instance to the given output.- Parameters:
out- The writer to write to.- Throws:
IOException- If writing fails.
-
readContent
public final void readContent(JsonReader in) throws IOException
Description copied from interface:DataObjectReads a JSON object containing keys for all fields of this object.This method does not consider type information contained in the stream.
- Specified by:
readContentin interfaceDataObject- Parameters:
in- The writer to write to.- Throws:
IOException
-
readFields
protected final void readFields(JsonReader in) throws IOException
Reads all fields of this instance from the given input.- Parameters:
in- The reader to take the input from.- Throws:
IOException
-
readField
protected void readField(JsonReader in, String field) throws IOException
Reads the given field from the given input.- Parameters:
in- The reader to take the value from.field- The name of the field whose value should be read.- Throws:
IOException
-
-