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, waitdeserializecreateDictionaryLookup, createDynamic, createSingle, createSingle, createWrapped, lookup, lookup, safeLookuppublic 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)
IParseContexttargetNode
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 IParseContextT - 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()
IParseContextObjectStack
or default(T) if the most current element is not of the desired target type.getCurrent in interface IParseContextdefault(T).public <T> T getDeserializationProperty(TypedKey<T> key)
IParseContextgetDeserializationProperty in interface IParseContextkey - The identifier for the propertynull if no such property exists.public final IGraph getGraph()
IParseContextgetGraph in interface IParseContextpublic final IListEnumerable<Object> getObjectStack()
IParseContextThe 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 IParseContextpublic final IParseContext getParentContext()
public final IParseEvents getParseEvents()
IParseContextIParseEvents that allows to subscribe to various events in the parse process.getParseEvents in interface IParseContextpublic <TLookup> TLookup lookup(Class<TLookup> type)
ILookupnull.
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)