com.yworks.yfiles.server.graphml.flexio.serializer
Class ExtensionBasedSerializer

java.lang.Object
  extended byy.io.graphml.output.AbstractSerializer
      extended bycom.yworks.yfiles.server.graphml.flexio.serializer.ReflectionBasedSerializer
          extended bycom.yworks.yfiles.server.graphml.flexio.serializer.ExtensionBasedSerializer
All Implemented Interfaces:
java.util.EventListener, SerializationHandler

public class ExtensionBasedSerializer
extends ReflectionBasedSerializer

Serializer implementation that produces output through the use of a MarkupExtension.

The target object is first converted to a MarkupExtension, which then gets serialized with the usual serialization mechanism (usually through ReflectionBasedSerializer.

To declare a type as serializable with a markup extension, a TypeConverter that is able to convert the type into a MarkupExtension has to be registered with the type converter registry.


Constructor Summary
ExtensionBasedSerializer()
           
 
Method Summary
 boolean canHandle(SerializationEvent e)
          Predicate member method to determine whether this instance should react to a given SerializationEvent.
protected  java.lang.String getPropertyName(GraphMLWriteContext context, java.beans.PropertyDescriptor property)
          Returns the string that should be used for the attribute or child element when a property is serialized.
protected  java.lang.String getTagName(GraphMLWriteContext context, java.lang.Object object)
           
 void serializeItem(java.lang.Object object, XmlWriter writer, GraphMLWriteContext context)
          The namespace for the serialized object consists of the symbolic package name as registered in the SymbolicPackageNameRegistry for the package of this object's class.
 
Methods inherited from class com.yworks.yfiles.server.graphml.flexio.serializer.ReflectionBasedSerializer
getNamespace, isCollectionProperty, serializeContent
 
Methods inherited from class y.io.graphml.output.AbstractSerializer
onHandleSerialization
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ExtensionBasedSerializer

public ExtensionBasedSerializer()
Method Detail

canHandle

public boolean canHandle(SerializationEvent e)
Description copied from class: ReflectionBasedSerializer
Predicate member method to determine whether this instance should react to a given SerializationEvent. Checks if the package of the class of the item in the event is registered in the SymbolicPackageNameRegistry.

Overrides:
canHandle in class ReflectionBasedSerializer
Parameters:
e - The event data.
Returns:
true iff this instance should handle the event.

serializeItem

public void serializeItem(java.lang.Object object,
                          XmlWriter writer,
                          GraphMLWriteContext context)
                   throws GraphMLWriteException
Description copied from class: ReflectionBasedSerializer

The namespace for the serialized object consists of the symbolic package name as registered in the SymbolicPackageNameRegistry for the package of this object's class.

The name of the serialized object maps the name of the object's class. If there is a ITypeConverter for the object's type registered in TypeConverters which can convert the object into a String, this String representation is written as text child node.

Otherwise all public read- and writable properties of the object are added to the xml node. If an appropriate ITypeConverter can be found via TypeConverters.getTypeConverter which can convert a property into a String, this property is written as an attributes of the resulting xml node. Otherwise it is written as a child node of the resulting xml node using an appropriate looked up serializer.

Overrides:
serializeItem in class ReflectionBasedSerializer
Throws:
GraphMLWriteException
See Also:
TypeConverters, ITypeConverter, SymbolicPackageNameRegistry

getTagName

protected java.lang.String getTagName(GraphMLWriteContext context,
                                      java.lang.Object object)
Overrides:
getTagName in class ReflectionBasedSerializer

getPropertyName

protected java.lang.String getPropertyName(GraphMLWriteContext context,
                                           java.beans.PropertyDescriptor property)
Description copied from class: ReflectionBasedSerializer
Returns the string that should be used for the attribute or child element when a property is serialized.

Overrides:
getPropertyName in class ReflectionBasedSerializer
Parameters:
context - The current write context
property - A property of the object that is currently being serialized.
Returns:
The string that should be used for the attribute or child element


Copyright © 2000-2013 yWorks GmbH. All rights reserved