Search this API

y.io.graphml.input
Class ChildParseContext

java.lang.Object
  extended by y.io.graphml.input.ChildParseContext
All Implemented Interfaces:
GraphMLParseContext, Lookup

public class ChildParseContext
extends java.lang.Object
implements GraphMLParseContext

An implementation of GraphMLParseContext that delegates most calls to a getParentContext(), but adds the capability to locally add lookup results and deserialization properties.

 

Constructor Summary
ChildParseContext(GraphMLParseContext parentContext)
          Initializes a new instance of the ChildParseContext class that delegates to the provided context.
ChildParseContext(GraphMLParseContext parentContext, java.lang.Object currentObject)
          Initializes a new instance of the ChildParseContext class that delegates to the provided context and adds the currentObject to the getObjectStack().
 
Method Summary
 java.lang.Object deserialize(GraphMLParseContext context, org.w3c.dom.Node targetNode, java.lang.Class targetType)
          Deserialize the Object representation in targetNode.
 java.lang.Object deserialize(org.w3c.dom.Node targetNode)
          Deserialize the Object representation in targetNode.
 java.lang.Object getCurrentObject()
          Returns the most current (i.e. the last element) within the container hierarchy as it is returned by GraphMLParseContext.getObjectStack()
 java.lang.Object getDeserializationProperty(java.lang.Object key)
          Get a property value that specifies information about how to handle specific cases
 Graph getGraph()
          Returns the currently active graph object.
 java.util.Collection getObjectStack()
          Returns the current nesting of graphs and graph elements.
 GraphMLParseContext getParentContext()
          Gets the parent context.
 ParseEventHandler getParseEvents()
          Returns an implementation of ParseEventHandler that allows to subscribe to various events in the parse process.
 java.lang.Object lookup(java.lang.Class type)
          Returns an instance that implements the given type or null.
 void removeDeserializationProperty(java.lang.Object key)
          Removes a previously set local deserialization property.
 void removeLookup(java.lang.Class t)
          Removes a local lookup override that has been added
 void setDeserializationProperty(java.lang.Object key, java.lang.Object value)
          Sets the local deserialization property for the given key to the value.
 void setLookup(java.lang.Class t, java.lang.Object value)
          Adds another lookup result to the local lookup override.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ChildParseContext

public ChildParseContext(GraphMLParseContext parentContext,
                         java.lang.Object currentObject)
Initializes a new instance of the ChildParseContext class that delegates to the provided context and adds the currentObject to the getObjectStack().

Parameters:
parentContext - The parent context.
currentObject - The current Object to add to the getObjectStack() and assign to getCurrentObject().
See Also:
getParentContext(), getObjectStack(), getCurrentObject()

ChildParseContext

public ChildParseContext(GraphMLParseContext parentContext)
Initializes a new instance of the ChildParseContext class that delegates to the provided context.

Parameters:
parentContext - The parent context.
See Also:
getParentContext()
Method Detail

getParentContext

public GraphMLParseContext getParentContext()
Gets the parent context.

Returns:
The parent context.

lookup

public java.lang.Object lookup(java.lang.Class type)
Description copied from interface: Lookup
Returns an instance that implements the given type or 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 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. Additionally, it depends on the type and context whether the instance returned stays up to date or needs to be retrieved again for subsequent use.

Specified by:
lookup in interface Lookup
Parameters:
type - the type for which an instance shall be returned
Returns:
an instance that is assignable to type or null

setLookup

public void setLookup(java.lang.Class t,
                      java.lang.Object value)
Adds another lookup result to the local lookup override.

Parameters:
t - The class type for which the value should be registered.
value - The value to provide for queries to t, needs to be assignable to that type.
See Also:
removeLookup(Class), lookup(Class)

removeLookup

public void removeLookup(java.lang.Class t)
Removes a local lookup override that has been added

Parameters:
t - The type key to remove.
See Also:
setLookup(Class,Object), lookup(Class)

getObjectStack

public java.util.Collection getObjectStack()
Description copied from interface: GraphMLParseContext
Returns the current nesting of graphs and graph elements.

The list contains the user objects which correspond to the graphml elements which are ancestors of the current node in the DOM tree. The list is appended to at the start, i.e. the most current element is at list index 0.

Specified by:
getObjectStack in interface GraphMLParseContext
Returns:
A view on the current nesting.

getCurrentObject

public java.lang.Object getCurrentObject()
Description copied from interface: GraphMLParseContext
Returns the most current (i.e. the last element) within the container hierarchy as it is returned by GraphMLParseContext.getObjectStack()

Specified by:
getCurrentObject in interface GraphMLParseContext
Returns:
The current graph element in the container hierarchy.

getParseEvents

public ParseEventHandler getParseEvents()
Description copied from interface: GraphMLParseContext
Returns an implementation of ParseEventHandler that allows to subscribe to various events in the parse process.

Specified by:
getParseEvents in interface GraphMLParseContext
Returns:
A ParseEventHandler implementation.

getGraph

public Graph getGraph()
Description copied from interface: GraphMLParseContext
Returns the currently active graph object.

Specified by:
getGraph in interface GraphMLParseContext
Returns:
The current graph object.

getDeserializationProperty

public java.lang.Object getDeserializationProperty(java.lang.Object key)
Get a property value that specifies information about how to handle specific cases

Specified by:
getDeserializationProperty in interface GraphMLParseContext
Parameters:
key - The identifier for the property
Returns:
The property value, or null if no such property exists.
See Also:
setDeserializationProperty(Object,Object), removeDeserializationProperty(Object)

setDeserializationProperty

public void setDeserializationProperty(java.lang.Object key,
                                       java.lang.Object value)
Sets the local deserialization property for the given key to the value.

Parameters:
key - The key to override.
value - The value.
See Also:
getDeserializationProperty(Object), removeDeserializationProperty(Object)

removeDeserializationProperty

public void removeDeserializationProperty(java.lang.Object key)
Removes a previously set local deserialization property.

Parameters:
key - The key for which the local property override should be removed.
See Also:
getDeserializationProperty(Object), setDeserializationProperty(Object,Object)

deserialize

public java.lang.Object deserialize(GraphMLParseContext context,
                                    org.w3c.dom.Node targetNode,
                                    java.lang.Class targetType)
                             throws GraphMLParseException
Description copied from interface: GraphMLParseContext
Deserialize the Object representation in targetNode.

This method is reserved for special use cases. Usually, you should just call GraphMLParseContext.deserialize(Node) instead.

Specified by:
deserialize in interface GraphMLParseContext
Parameters:
context - The current parse context.
targetNode - The XML node that should be deserialized.
targetType - The type the result is expected to have, or null if deserialization handlers should determine this information automatically.
Returns:
The deserialized object from targetNode
Throws:
GraphMLParseException

deserialize

public java.lang.Object deserialize(org.w3c.dom.Node targetNode)
                             throws GraphMLParseException
Description copied from interface: GraphMLParseContext
Deserialize the Object representation in targetNode.

Specified by:
deserialize in interface GraphMLParseContext
Parameters:
targetNode - The XML node that should be deserialized.
Returns:
The deserialized object from targetNode
Throws:
GraphMLParseException

© Copyright 2000-2022,
yWorks GmbH.
All rights reserved.