Interface Scope

All Known Subinterfaces:
ScopeMixin
All Known Implementing Classes:
DefaultScope

public interface Scope
API for resolving cross-references in serialized object graphs.
  • Method Details

    • resolveOrFail

      SharedGraphNode resolveOrFail(int id)
      Looks up the object with the given ID.
      Parameters:
      id - The ID of the requested object.
      Returns:
      The object with the given ID.
      Throws:
      IllegalArgumentException - If there is no object with the requested ID.
    • writeRefOrData

      void writeRefOrData(JsonWriter out, SharedGraphNode node) throws IOException
      Writes the given graph node to the given writer.

      If the node has already an ID in this scope, only the ID is transmitted as plain numeric value. Otherwise, a fresh ID is assigned to the node and the the full data of the given node is transmitted (by calling back to SharedGraphNode.writeData(Scope, JsonWriter, int)).

      Parameters:
      out - The JsonWriter to write to.
      node - The graph node to transmit.
      Throws:
      IOException
    • readData

      void readData(SharedGraphNode node, int id, JsonReader in) throws IOException
      Reads object data of the given node and assigns the given ID to this node.
      Parameters:
      node - The node to read data for.
      id - The ID to assign ot the given node.
      Throws:
      IOException