|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object y.io.graphml.output.AbstractSerializer com.yworks.yfiles.server.graphml.flexio.serializer.ReflectionBasedSerializer
This serializer can be used to serialize complex objects based on reflection.
The package of a class whose instances shall be serialized this way has to be added to the
SymbolicPackageNameRegistry
together with the symbolic package name that should be used during the
serialization.
This serializer also handles serialization of IEnum
implementations.
SymbolicPackageNameRegistry
Constructor Summary | |
ReflectionBasedSerializer()
|
Method Summary | |
boolean |
canHandle(SerializationEvent e)
Predicate member method to determine whether this instance should react to a given SerializationEvent .
|
protected java.lang.String |
getNamespace(GraphMLWriteContext context,
java.lang.Object object)
|
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)
|
protected boolean |
isCollectionProperty(GraphMLWriteContext context,
java.lang.Object subject,
java.beans.PropertyDescriptor property)
Returns true if the property is a collection property that needs to be handled specially. |
protected void |
serializeContent(GraphMLWriteContext context,
java.lang.Object object,
XmlWriter writer,
java.lang.String symbolicPackageName,
java.lang.String tagName)
Writes the actual content of the GraphML element that corresponds to the serialization of 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 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 |
public ReflectionBasedSerializer()
Method Detail |
public boolean canHandle(SerializationEvent e)
SerializationEvent
.
Checks if the package of the class of the item in the event is registered in the SymbolicPackageNameRegistry
.
e
- The event data.
true
iff this instance should handle the event.public void serializeItem(java.lang.Object object, XmlWriter writer, GraphMLWriteContext context) throws GraphMLWriteException
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.
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.
GraphMLWriteException
TypeConverters
,
ITypeConverter
,
SymbolicPackageNameRegistry
protected void serializeContent(GraphMLWriteContext context, java.lang.Object object, XmlWriter writer, java.lang.String symbolicPackageName, java.lang.String tagName) throws GraphMLWriteException
object
.
Simply said: writes the XML between the start element and the end element.
context
- The current write context.object
- The current object to be serialized.writer
- The XML writer.symbolicPackageName
- The symbolic package name, i.e. the XML namespace.tagName
- The tag name.
GraphMLWriteException
protected java.lang.String getNamespace(GraphMLWriteContext context, java.lang.Object object)
protected java.lang.String getPropertyName(GraphMLWriteContext context, java.beans.PropertyDescriptor property)
context
- The current write contextproperty
- A property of the object that is currently being serialized.
protected boolean isCollectionProperty(GraphMLWriteContext context, java.lang.Object subject, java.beans.PropertyDescriptor property)
This implementations returns true
, if the property is assignable to YList
.
context
- The current write contextsubject
- The object that is to be serializedproperty
- The descriptor of the property
protected java.lang.String getTagName(GraphMLWriteContext context, java.lang.Object object)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |