com.yworks.yfiles.server.graphml.flexio
Class DefaultReferenceResolver

java.lang.Object
  extended bycom.yworks.yfiles.server.graphml.flexio.DefaultReferenceResolver
All Implemented Interfaces:
ReferenceResolver, SharedReferenceElementProvider

public class DefaultReferenceResolver
extends java.lang.Object
implements ReferenceResolver, SharedReferenceElementProvider

Default implementation of a ReferenceResolver that resolves external or internal references.

By default, only internal references that are declared in the GraphML document are resolved. To resolve external references, the onResolveExternalOverrideReference(ResolveReferenceEvent) and onResolveExternalFallbackReference(ResolveReferenceEvent) callbacks can be used.


Constructor Summary
DefaultReferenceResolver()
          Initializes a new instance.
DefaultReferenceResolver(java.util.HashMap xmlReferenceMap)
          Create a new Resolver instance Dictionary that has pairs where the key is a id string and the value is the corresponding node from the sharedData section in the GraphML input.
 
Method Summary
 void addReferenceElement(java.lang.String id, org.w3c.dom.Node element)
          Add a reference node for the given refid.
 org.w3c.dom.Node getReferenceElement(java.lang.String id)
          Returns the XML element with the provided id, or null, if no XML element with the provided id was contained in the shared data section.
protected  void onResolveExternalFallbackReference(ResolveReferenceEvent evt)
          Resolve external references, if they couldn't be resolved using onResolveExternalOverrideReference(ResolveReferenceEvent) or onResolveInternalReference(ResolveReferenceEvent, DeserializationHandler).
protected  void onResolveExternalOverrideReference(ResolveReferenceEvent evt)
          Resolve an external reference.
protected  void onResolveInternalReference(ResolveReferenceEvent event, DeserializationHandler deserializer)
          Resolve inline references.
 java.lang.Object resolveReference(GraphMLParseContext context, java.lang.String refid)
          Convenience method that calls resolveReference(y.io.graphml.input.GraphMLParseContext, String, y.io.graphml.input.DeserializationHandler) with a null deserializer.
 java.lang.Object resolveReference(GraphMLParseContext context, java.lang.String refid, DeserializationHandler deserializer)
          Resolve an xml node to an object instance.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultReferenceResolver

public DefaultReferenceResolver(java.util.HashMap xmlReferenceMap)
Create a new Resolver instance

Dictionary that has pairs where the key is a id string and the value is the corresponding node from the sharedData section in the GraphML input. It is the caller's responsibility to ensure this is setup correctly.

Parameters:
xmlReferenceMap -

DefaultReferenceResolver

public DefaultReferenceResolver()
Initializes a new instance.

Method Detail

addReferenceElement

public void addReferenceElement(java.lang.String id,
                                org.w3c.dom.Node element)
Description copied from interface: ReferenceResolver
Add a reference node for the given refid.

Specified by:
addReferenceElement in interface ReferenceResolver
Parameters:
id - The reference id
element - DOM node that is referenced by the id.

getReferenceElement

public org.w3c.dom.Node getReferenceElement(java.lang.String id)
Description copied from interface: SharedReferenceElementProvider
Returns the XML element with the provided id, or null, if no XML element with the provided id was contained in the shared data section.

Specified by:
getReferenceElement in interface SharedReferenceElementProvider

resolveReference

public java.lang.Object resolveReference(GraphMLParseContext context,
                                         java.lang.String refid)
                                  throws GraphMLParseException
Convenience method that calls resolveReference(y.io.graphml.input.GraphMLParseContext, String, y.io.graphml.input.DeserializationHandler) with a null deserializer.

Parameters:
context - The current parse context.
refid - The refid of the shared element.
Returns:
The shared instance.
Throws:
GraphMLParseException
See Also:
resolveReference(y.io.graphml.input.GraphMLParseContext, String, y.io.graphml.input.DeserializationHandler)

resolveReference

public java.lang.Object resolveReference(GraphMLParseContext context,
                                         java.lang.String refid,
                                         DeserializationHandler deserializer)
                                  throws GraphMLParseException
Description copied from interface: ReferenceResolver
Resolve an xml node to an object instance.

This method returns shared instances for nodes with the same refid.

Specified by:
resolveReference in interface ReferenceResolver
Parameters:
context - The current parse context.
refid - The refid which should be resolved. Must not be null.
deserializer - Deserializer which should be used for deserialization of the shared element. Can be null when not called from a deserializer instance, in which case the resolver tries to find a matching deserializer itself.
Returns:
the referenced object
Throws:
GraphMLParseException

onResolveInternalReference

protected void onResolveInternalReference(ResolveReferenceEvent event,
                                          DeserializationHandler deserializer)
                                   throws GraphMLParseException
Resolve inline references.

This method is only called if onResolveExternalOverrideReference(ResolveReferenceEvent) could not already resolve the reference.

Parameters:
event - The current invocation state. Any event handler that can actually dereference the reference should set the value using ResolveReferenceEvent.setValue(Object)
deserializer - The deserializer that is to be used for deserialization of the shared element, or nulls
Throws:
GraphMLParseException

onResolveExternalOverrideReference

protected void onResolveExternalOverrideReference(ResolveReferenceEvent evt)
Resolve an external reference.

Parameters:
evt - The current invocation state. Any event handler that can actually dereference the reference should set the value using ResolveReferenceEvent.setValue(Object)

onResolveExternalFallbackReference

protected void onResolveExternalFallbackReference(ResolveReferenceEvent evt)
Resolve external references, if they couldn't be resolved using onResolveExternalOverrideReference(ResolveReferenceEvent) or onResolveInternalReference(ResolveReferenceEvent, DeserializationHandler).

Parameters:
evt - The current invocation state. Any event handler that can actually dereference the reference should set the value using ResolveReferenceEvent.setValue(Object)


Copyright © 2000-2013 yWorks GmbH. All rights reserved