Package | com.yworks.io.graphml.writer.serializer |
Class | public class ReflectionBasedSerializer |
Inheritance | ReflectionBasedSerializer Object |
Implements | ISerializer |
Subclasses | ExtensionBasedSerializer |
ISerializer
can be used to serialize objects of different class type based on reflection.
The package of a class of which 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.
If the given object implements the IMarkupExtensionFactory
interface, the markup extension
of the object will be serialized instead of the object itself.
This serializer also handles the serialization of com.yworks.support.IEnum
implementations.
Only public read- and writeable properties are serialized.
See also
Property | Defined By | ||
---|---|---|---|
elementName : String [read-only]
The element name of the toplevel XmlElement for the serialized representation of this object. | ReflectionBasedSerializer | ||
instance : ReflectionBasedSerializer [static] [read-only]
The shared instance of this serializer
| ReflectionBasedSerializer | ||
xmlNamespace : Namespace [read-only]
| ReflectionBasedSerializer |
Method | Defined By | ||
---|---|---|---|
canHandle(context:GraphMLWriteContext, object:Object):Boolean
Checks if the package of the class of the given object is registered in the SymbolicPackageNameRegistry. | ReflectionBasedSerializer | ||
Serialize the given style to a IXmlWriter. | ReflectionBasedSerializer |
Method | Defined By | ||
---|---|---|---|
getMemberSerializer(context:GraphMLWriteContext, subject:Object, currentValue:Object, propertyDesc:XML):ISerializer | ReflectionBasedSerializer | ||
getProperties(context:GraphMLWriteContext, subject:Object):XMLList
Returns a list of all properties that should be serialized. | ReflectionBasedSerializer | ||
getTagName(context:GraphMLWriteContext, subject:Object):String | ReflectionBasedSerializer | ||
getXmlNamespace(context:GraphMLWriteContext, subject:Object):Namespace | ReflectionBasedSerializer | ||
hasDefaultValue(context:GraphMLWriteContext, subject:Object, property:XML):Boolean
Returns true if a property has a default value and therefore should not be written at all. | ReflectionBasedSerializer | ||
isCollectionProperty(context:GraphMLWriteContext, subject:Object, property:XML):Boolean
Returns true if the property is a collection property that needs to be handled specially. | ReflectionBasedSerializer | ||
Write the content of the graphml element that corresponds to the serialization of subject. | ReflectionBasedSerializer | ||
shouldSerialize(context:GraphMLWriteContext, subject:Object, property:XML):Boolean
Returns true if property should be serialized. | ReflectionBasedSerializer | ||
shouldWriteMemberAsAttribute(context:GraphMLWriteContext, subject:Object, property:XML):Boolean
Determines whether property should be written as attribute value or as complete
element. | ReflectionBasedSerializer |
elementName | property |
elementName:String
[read-only] The element name of the toplevel XmlElement for the serialized representation of this object.
public function get elementName():String
instance | property |
instance:ReflectionBasedSerializer
[read-only] The shared instance of this serializer
public static function get instance():ReflectionBasedSerializer
xmlNamespace | property |
xmlNamespace:Namespace
[read-only]
public function get xmlNamespace():Namespace
canHandle | () | method |
public function canHandle(context:GraphMLWriteContext, object:Object):Boolean
Checks if the package of the class of the given object is registered in the SymbolicPackageNameRegistry
.
Parameters
context:GraphMLWriteContext — The GraphMLWriteContext of the serialization.
| |
object:Object — The object to serialize.
|
Boolean — true if the package is registered, false otherwise.
|
getMemberSerializer | () | method |
protected function getMemberSerializer(context:GraphMLWriteContext, subject:Object, currentValue:Object, propertyDesc:XML):ISerializer
Parameters
context:GraphMLWriteContext | |
subject:Object | |
currentValue:Object | |
propertyDesc:XML |
ISerializer |
getProperties | () | method |
protected function getProperties(context:GraphMLWriteContext, subject:Object):XMLList
Returns a list of all properties that should be serialized.
This implementation returns all public properties that are read/write, filtered
using shouldSerialize()
.
Parameters
context:GraphMLWriteContext — The current write context
| |
subject:Object — The object that should be serialized.
|
XMLList — A list of all properties that should be serialized
|
See also
getTagName | () | method |
protected function getTagName(context:GraphMLWriteContext, subject:Object):String
Parameters
context:GraphMLWriteContext | |
subject:Object |
String |
getXmlNamespace | () | method |
protected function getXmlNamespace(context:GraphMLWriteContext, subject:Object):Namespace
Parameters
context:GraphMLWriteContext | |
subject:Object |
Namespace |
hasDefaultValue | () | method |
protected function hasDefaultValue(context:GraphMLWriteContext, subject:Object, property:XML):Boolean
Returns true if a property has a default value and therefore should not be written at all.
This implementation just checks if the current property value is equal to the default value
specified using an optional [DefaultValue]
meta attribute
Parameters
context:GraphMLWriteContext — The current write context
| |
subject:Object — The object that should be serialized.
| |
property:XML — The XML description of the property.
|
Boolean — true if the property has a default value.
|
See also
isCollectionProperty | () | method |
protected function isCollectionProperty(context:GraphMLWriteContext, subject:Object, property:XML):Boolean
Returns true if the property is a collection property that needs to be handled specially.
This implementations returns true
, if the property is assignable to com.yworks.support.List
and to com.yworks.support.Iterable
.
Parameters
context:GraphMLWriteContext — The current write context
| |
subject:Object — The object that is to be serialized
| |
property:XML — The XML description of the property
|
Boolean — Whether the property is a collection property
|
See also
serialize | () | method |
public function serialize(context:GraphMLWriteContext, subject:Object, writer:IXmlWriter):void
Serialize the given style to a IXmlWriter
.
Parameters
context:GraphMLWriteContext — The current write context
| |
subject:Object — The actual object
| |
writer:IXmlWriter — An IXmlWriter instance where the
output is written
|
See also
int
property with name 'myIntProperty' and value 100SymbolicPackageNameRegistry.add('myPackage', 'mySymbolicPackage');
br/>
The resulting xml looks like:
<aaa:MyObject myIntProperty="100" xmlns:aaa="mySymbolicPackage"> <aaa:MyObject.myComplexTypeProperty> ... serialization of this property </aaa:MyObject.myComplexTypeProperty> </aaa:MyObject>
serializeContent | () | method |
protected function serializeContent(context:GraphMLWriteContext, subject:Object, writer:IXmlWriter):void
Write the content of the graphml element that corresponds to the serialization of subject
.
Parameters
context:GraphMLWriteContext — The current write context.
| |
subject:Object — The current object to be serialized.
| |
writer:IXmlWriter — The xml writer.
|
shouldSerialize | () | method |
protected function shouldSerialize(context:GraphMLWriteContext, subject:Object, property:XML):Boolean
Returns true if property
should be serialized.
This implementation returns true if it is a collection property (see isCollectionProperty()
),
or if all of the following are true:
hasDefaultValue()
)Parameters
context:GraphMLWriteContext — The current write context
| |
subject:Object — The object that should be serialized.
| |
property:XML — The XML descriptor of the property.
|
Boolean — true if the property should be serialized.
|
See also
shouldWriteMemberAsAttribute | () | method |
protected function shouldWriteMemberAsAttribute(context:GraphMLWriteContext, subject:Object, property:XML):Boolean
Determines whether property
should be written as attribute value or as complete
element.
Parameters
context:GraphMLWriteContext — The current write context.
| |
subject:Object — The object that should be serialized.
| |
property:XML — The XML description of the property.
|
Boolean — true iff the member should be written as an XML attribute value.
|