public static final class DOFType.Context
extends java.lang.Object
DOFType
instances.
The context is conceptually simple, but difficult in practice. The problem is that
the order in which the different references are required is not strictly defined.
This means that reading a type from the context may immediately require that a type
found later in the context, and the recursion must be handled correctly.
The implementation must also guard against improper wire formats that contain self-references
which would cause infinite recursion.
WARNING: None of the methods in this class are thread-safe. Therefore any potential for
use of a Context object by more than one Thread must be synchronized.Modifier and Type | Class and Description |
---|---|
static interface |
DOFType.Context.Resolver
In order to resolve forward references, classes must register the routine
that will be called by the context when the type is finally read in.
|
Modifier and Type | Method and Description |
---|---|
DOFType |
create(boolean fully_define,
DOFPacket packet)
Create a type from a buffer that is pointing to a reference to the type in the context.
|
DOFType |
create(boolean fully_define,
DOFType.Context.Resolver resolver,
DOFPacket packet)
Create a type from a buffer that is pointing to a reference to the type in the context.
|
boolean |
isFullyDefined()
Return whether or not the context is operating in fully-defined mode (returning only
fully defined types).
|
void |
marshal(DOFPacket packet)
Write the context to the specified packet.
|
void |
marshal(DOFType type,
DOFPacket packet)
Write a reference to the specified type into a packet.
|
public DOFType create(boolean fully_define, DOFType.Context.Resolver resolver, DOFPacket packet) throws DOFMarshalException
DOFType.Context.Resolver
to finalize the
type when the referenced type is read.
Note that there is no recursion in this routine.fully_define
- true
if only fully defined types should be returned.resolver
- The Resolver to be used if the type is not currently defined.packet
- The packet that is pointing at a reference.DOFMarshalException
- Thrown if the type could not be read.public boolean isFullyDefined()
true
if the context returns only fully-defined types, false
otherwise.public DOFType create(boolean fully_define, DOFPacket packet) throws DOFMarshalException
fully_define
- true
if only fully defined types should be returned.packet
- The packet that is pointing at a reference.DOFMarshalException
- Thrown if the type could not be read.public void marshal(DOFType type, DOFPacket packet) throws DOFMarshalException
type
- The type to write the reference to. The type is added to the context.packet
- The packet that the reference is written to.DOFMarshalException
- Thrown if a failure occurs writing the reference.public void marshal(DOFPacket packet) throws DOFMarshalException
packet
- The packet to write the context to.DOFMarshalException
- Thrown if the context cannot be written.