java.lang.Object
de.haumacher.msgbuf.graph.AbstractSharedGraphNode
- All Implemented Interfaces:
ReflectiveDataObject,SharedGraphNode,Observable
Base class for generated code implementing
SharedGraphNodes.
This implementation is structurally equivalent to AbstractDataObject but adds a Scope to the method
signatures.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal intid()The ID of this node in it's defaultScope.protected voidinitId(int id) Assigns the given ID.readElement(Scope scope, JsonReader in, String field) Read an element of the repeated field with the given name.voidreadField(Scope scope, JsonReader in, String field) Reads the given field from the given input.final voidreadFields(Scope scope, JsonReader in) Reads all fields of this instance from the given input.Attaches the givenListenerto this object.toString()Removes the givenListenerfrom this object.final voidwriteData(Scope scope, JsonWriter out, int id) Writes the complete data of this node including type and ID to the given writer.voidwriteElement(Scope scope, JsonWriter out, String field, Object element) Writes the given element value that is compatible with the repeated field with the given name to the given output.protected voidwriteFields(Scope scope, JsonWriter out) Writes all fields of this instance to the given output.voidwriteFieldValue(Scope scope, JsonWriter out, String field) Writes a single value that is currently assigned to the field with the given name to the given writer.final voidwriteTo(Scope scope, JsonWriter out) Writes this node to the given writer.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface de.haumacher.msgbuf.data.ReflectiveDataObject
get, jsonType, properties, set
-
Field Details
-
_listener
-
-
Constructor Details
-
AbstractSharedGraphNode
public AbstractSharedGraphNode()
-
-
Method Details
-
id
public final int id()The ID of this node in it's defaultScope. -
initId
protected void initId(int id) Assigns the given ID.- See Also:
-
registerListener
Description copied from interface:ObservableAttaches the givenListenerto this object.If the given
Listeneris already attached, it is not attached again.- Specified by:
registerListenerin interfaceObservable- Parameters:
l- TheListenerto attach.- Returns:
- This object for call chaining.
-
unregisterListener
Description copied from interface:ObservableRemoves the givenListenerfrom this object.- Specified by:
unregisterListenerin interfaceObservable- Parameters:
l- TheListenerto remove.- Returns:
- This object for call chaining.
-
writeTo
Description copied from interface:SharedGraphNodeWrites this node to the given writer.Depending on the given
Scope, only a reference to this object is transmitted, if this node is already known by theScope. Otherwise, thecomplete objectdata is transmitted.- Specified by:
writeToin interfaceSharedGraphNode- Parameters:
scope- The shared graphScopethat handles object references.out- The writer to write to.- Throws:
IOException
-
writeData
Description copied from interface:SharedGraphNodeWrites the complete data of this node including type and ID to the given writer.Note: This method should only be called from a
Scope'sScope.writeRefOrData(JsonWriter, SharedGraphNode)if a fresh ID was assigned.- Specified by:
writeDatain interfaceSharedGraphNode- Parameters:
scope- The shared graphScopethat handles object references.out- The writer to write to.id- The ID to use for this node.- Throws:
IOException
-
writeFields
Writes all fields of this instance to the given output.- Parameters:
scope- The shared graphScope.out- The writer to write to.- Throws:
IOException- If writing fails.
-
readFields
Description copied from interface:SharedGraphNodeReads all fields of this instance from the given input.- Specified by:
readFieldsin interfaceSharedGraphNode- Parameters:
scope- The shared graphScopethat handles object references.in- The reader to take the input from.- Throws:
IOException
-
readField
Description copied from interface:SharedGraphNodeReads the given field from the given input.- Specified by:
readFieldin interfaceSharedGraphNode- Parameters:
scope- The shared graphScopethat handles object references.in- The reader to take the value from.field- The name of the field whose value should be read.- Throws:
IOException
-
writeElement
public void writeElement(Scope scope, JsonWriter out, String field, Object element) throws IOException Description copied from interface:SharedGraphNodeWrites the given element value that is compatible with the repeated field with the given name to the given output.- Specified by:
writeElementin interfaceSharedGraphNode- Parameters:
scope- The shared graphScopethat handles object references.out- The writer to write to.field- The name of the field whose element should be written.element- The element value of the given field.- Throws:
IOException
-
readElement
Description copied from interface:SharedGraphNodeRead an element of the repeated field with the given name.- Specified by:
readElementin interfaceSharedGraphNode- Parameters:
scope- The shared graphScopethat handles object references.in- The reader to take the value from.field- The repeated field where an element value should be read for.- Returns:
- The read element value.
- Throws:
IOException
-
writeFieldValue
Description copied from interface:SharedGraphNodeWrites a single value that is currently assigned to the field with the given name to the given writer.- Specified by:
writeFieldValuein interfaceSharedGraphNode- Parameters:
scope- The shared graphScopethat handles object references.out- The writer to write to.field- The name of the field whose value should be written.- Throws:
IOException
-
toString
-