com.yworks.yfiles.server.graphml.flexio.deserializer
Class ReflectionBasedDeserializer

java.lang.Object
  extended byy.io.graphml.input.AbstractDeserializer
      extended bycom.yworks.yfiles.server.graphml.flexio.deserializer.ReflectionBasedDeserializer
All Implemented Interfaces:
DeserializationHandler, java.util.EventListener

public class ReflectionBasedDeserializer
extends AbstractDeserializer

This deserializer can be used to deserialize objects of different class types based on reflection.

A target class to which an XML node shall be deserialized this way has to:

This class also handles deserialization of IEnum implementations.

See Also:
SymbolicPackageNameRegistry

Constructor Summary
ReflectionBasedDeserializer()
           
 
Method Summary
 boolean canHandle(DeserializationEvent e)
          Node elements whose namespace uri is contained in the SymbolicPackageNameRegistry and for which an instance can be created can be handled.
protected  java.lang.Object createInstance(org.w3c.dom.Node xmlNode)
          Returns a new instance of the object the XML node shall be deserialized to.
 java.lang.Object deserializeNode(org.w3c.dom.Node xmlNode, GraphMLParseContext context)
          The namespace URI of the xml node to deserialize has to be mapped to the package of the target class in the SymbolicPackageNameRegistry.
protected  java.lang.String getPropertyName(java.lang.String originalName)
           
 
Methods inherited from class y.io.graphml.input.AbstractDeserializer
onHandleDeserialization
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ReflectionBasedDeserializer

public ReflectionBasedDeserializer()
Method Detail

canHandle

public boolean canHandle(DeserializationEvent e)
Node elements whose namespace uri is contained in the SymbolicPackageNameRegistry and for which an instance can be created can be handled.

Parameters:
e - The deserialization event to check.
Returns:
true if the namespace uri of the element's xmlNode is contained in the SymbolicPackageNameRegistry and an instance of the target class can be created.
See Also:
SymbolicPackageNameRegistry, createInstance(org.w3c.dom.Node)

deserializeNode

public java.lang.Object deserializeNode(org.w3c.dom.Node xmlNode,
                                        GraphMLParseContext context)
                                 throws GraphMLParseException

The namespace URI of the xml node to deserialize has to be mapped to the package of the target class in the SymbolicPackageNameRegistry. The node name has to map the name of this target class.

If there is an ITypeConverter registered for the target class in TypeConverters which can convert from a String, it is used to deserialize the String returned by xmlNode.getTextContent().

Otherwise for all attributes and child nodes of the given XML element, the property type is looked up via reflection. For the attributes an appropriate ITypeConverter for their class type is looked up via TypeConverters.getTypeConverter and used. Child nodes are deserialized using an appropriate registered DeserializationHandler.

Throws:
GraphMLParseException
See Also:
TypeConverters, ITypeConverter, SymbolicPackageNameRegistry

createInstance

protected java.lang.Object createInstance(org.w3c.dom.Node xmlNode)
Returns a new instance of the object the XML node shall be deserialized to.

Parameters:
xmlNode - The node to deserialize.
Returns:
A new instance of the object to deserialize.

getPropertyName

protected java.lang.String getPropertyName(java.lang.String originalName)


Copyright © 2000-2013 yWorks GmbH. All rights reserved