public class ChildParseContext extends Object implements IParseContext
IParseContext
that delegates most calls to a ParentContext
, but
adds the capability to locally add lookup(Class)
results and
deserialization properties
.
Whenever it is necessary to locally modify some context properties, a new instance of this class should be created that wraps an existing one.
Constructor and Description |
---|
ChildParseContext(IParseContext parentContext)
Initializes a new instance of the
ChildParseContext class that delegates to the provided context. |
ChildParseContext(IParseContext parentContext,
Object currentObject)
Initializes a new instance of the
ChildParseContext class that delegates to the provided context and adds the currentObject
to the ObjectStack . |
Modifier and Type | Method and Description |
---|---|
<T> T |
deserialize(Class<T> targetType,
IParseContext context,
Node targetNode)
Deserialize the object representation in .
|
Object |
getCurrent()
Returns the most current (the last element) within the container hierarchy as it is returned by
ObjectStack
or default(T) if the most current element is not of the desired target type. |
<T> T |
getDeserializationProperty(TypedKey<T> key)
Get a property value that specifies information about how to handle specific cases.
|
IGraph |
getGraph()
Returns the currently active graph object.
|
IListEnumerable<Object> |
getObjectStack()
Returns the current nesting of created graphs and graph elements.
|
IParseContext |
getParentContext()
Gets the parent context.
|
IParseEvents |
getParseEvents()
Returns an implementation of
IParseEvents that allows to subscribe to various events in the parse process. |
<TLookup> TLookup |
lookup(Class<TLookup> type)
Returns an instance that implements the given type or
null . |
<T> void |
removeDeserializationProperty(TypedKey<T> key)
Removes a previously locally
set deserialization property. |
<T> void |
removeLookup(Class<T> tType)
Removes a local lookup override that has been added using
setLookup(Class, Object) . |
<T> void |
setDeserializationProperty(TypedKey<T> key,
T value)
Sets the local deserialization property for the given key to the value.
|
<T> void |
setLookup(Class<T> tType,
T value)
Adds another lookup result to the local lookup override.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
deserialize
createDictionaryLookup, createDynamic, createSingle, createSingle, createWrapped, lookup, lookup, safeLookup
public ChildParseContext(IParseContext parentContext)
ChildParseContext
class that delegates to the provided context.parentContext
- The parent context.public ChildParseContext(IParseContext parentContext, Object currentObject)
ChildParseContext
class that delegates to the provided context and adds the currentObject
to the ObjectStack
.parentContext
- The parent context.currentObject
- The current object to add to the ObjectStack
and return in getCurrent()
.public <T> T deserialize(Class<T> targetType, IParseContext context, Node targetNode)
IParseContext
targetNode
Client code should usually use the extension method IParseContext.deserialize(Class, Node)
instead to ensure the the correct
context
instance is used.
deserialize
in interface IParseContext
T
- The expected return type.targetType
- The expected return type.context
- The current parse context.targetNode
- The XML node that should be deserialized.targetNode
or an DeserializationNotSupportedException
if targetNode
could not be deserialized.IParseContext.deserialize(Class, Node)
public final Object getCurrent()
IParseContext
ObjectStack
or default(T)
if the most current element is not of the desired target type.getCurrent
in interface IParseContext
default(T)
.public <T> T getDeserializationProperty(TypedKey<T> key)
IParseContext
getDeserializationProperty
in interface IParseContext
key
- The identifier for the propertynull
if no such property exists.public final IGraph getGraph()
IParseContext
getGraph
in interface IParseContext
public final IListEnumerable<Object> getObjectStack()
IParseContext
The list contains the user objects which correspond to the GraphML elements which are ancestors of the current node in the DOM tree.
getObjectStack
in interface IParseContext
public final IParseContext getParentContext()
public final IParseEvents getParseEvents()
IParseContext
IParseEvents
that allows to subscribe to various events in the parse process.getParseEvents
in interface IParseContext
public <TLookup> TLookup lookup(Class<TLookup> type)
ILookup
null
.
Typically, this method will be called in order to obtain a different view or
aspect of the current instance. This is quite similar to casting or using
a super type or interface of this instance, but is not limited to inheritance or
compile time constraints. An instance implementing this method is not
required to return non-null
implementations for the types, nor does it
have to return the same instance any time. Also it depends on the
type and context whether the instance returned stays up to date or needs to
be reobtained for subsequent use.public <T> void removeDeserializationProperty(TypedKey<T> key)
set
deserialization property.key
- The key for which the local property override should be removed.public <T> void removeLookup(Class<T> tType)
setLookup(Class, Object)
.T
- The type key to remove.tType
- The type key to remove.public <T> void setDeserializationProperty(TypedKey<T> key, T value)
key
- The key to override.value
- The value.public <T> void setLookup(Class<T> tType, T value)
T
- The type to use as a key for the lookup.tType
- The type to use as a key for the lookup.value
- The value to provide for queries to T
.removeLookup(Class)