Package | com.yworks.io.graphml.reader.deserializer |
Class | public class ReflectionBasedDeserializer |
Inheritance | ReflectionBasedDeserializer AbstractDeserializer Object |
IDeserializer
can be used to deserialize complex objects based
on reflection.
A target class to which an XML
node shall be deserialized this way has to:
XML
nodeXML
node mapped to it's package in the
SymbolicPackageNameRegistry
XML
nodeIf there exists a MarkupExtension
in the same package which is named like the XML
but with 'Extension' attached (e.g. MyClassExtension) it is tried to deserialize the XML
node into an
instance of this markup extension and return the result of it's provideValue
method.
This class also handles deserialization of .com.yworks.support.IEnum
instances.
See also
Property | Defined By | ||
---|---|---|---|
elementName : String [override] [read-only]
The local tag name that this Deserializer can claim to handle
| ReflectionBasedDeserializer | ||
instance : ReflectionBasedDeserializer [static] [read-only]
The shared instance of this deserializer
| ReflectionBasedDeserializer | ||
xmlNamespace : Namespace [override] [read-only]
The XmlNamespace that this Deserializer can claim to handle. | ReflectionBasedDeserializer |
Method | Defined By | ||
---|---|---|---|
canHandle(context:GraphMLParseContext, element:XML):Boolean [override]
Returns whether a deserializer can handle a specific xml element. | ReflectionBasedDeserializer | ||
deserialize(context:GraphMLParseContext, element:XML):Object [override]
Create a new instance from the
xml element
| ReflectionBasedDeserializer |
Method | Defined By | ||
---|---|---|---|
Parses and assigns the single element values in collectionContent to list
| ReflectionBasedDeserializer | ||
getTargetClass(symbolicPackageName:String, className:String):Class
Tries to lookup the given symbolicPackageName in the SymbolicPackageNameRegistry and to
resolve the resulting package name with the given className to a Class object. | ReflectionBasedDeserializer | ||
isCollectionProperty(context:GraphMLParseContext, instance:Object, propertyClass:Class):Boolean
Returns true, if the property is assignable to com.yworks.support.List. | ReflectionBasedDeserializer | ||
parseCollectionProperty(context:GraphMLParseContext, instance:Object, collectionChildren:XMLList, propertyName:String):void
Parses and applies collectionContent to a list property. | ReflectionBasedDeserializer |
elementName | property |
elementName:String
[read-only] [override] The local tag name that this Deserializer can claim to handle
public function get elementName():String
instance | property |
instance:ReflectionBasedDeserializer
[read-only] The shared instance of this deserializer
public static function get instance():ReflectionBasedDeserializer
xmlNamespace | property |
xmlNamespace:Namespace
[read-only] [override] The XmlNamespace that this Deserializer can claim to handle.
This method needs to be overridden by subclass implementations.
public function get xmlNamespace():Namespace
assignListValues | () | method |
protected function assignListValues(context:GraphMLParseContext, collectionContent:XMLList, list:List):void
Parses and assigns the single element values in collectionContent
to list
Parameters
context:GraphMLParseContext — The target list.
| |
collectionContent:XMLList — List of XML nodes forming the collection content.
| |
list:List — The current parse context.
|
canHandle | () | method |
override public function canHandle(context:GraphMLParseContext, element:XML):Boolean
Returns whether a deserializer can handle a specific xml element. This implementation returns true, if
elementName
xmlNamespace
refid
attribute.Parameters
context:GraphMLParseContext — The current parse context
| |
element:XML — The xml node to be parsed
|
Boolean — true if this deserializer can handle the given xml node.
|
deserialize | () | method |
override public function deserialize(context:GraphMLParseContext, element:XML):Object
Create a new instance from the xml element
Parameters
context:GraphMLParseContext — The current parse context
| |
element:XML — The current xml element
|
Object — A new instance
|
See also
The xml fragment may look like: <aaa:MyObject myIntProperty="100" xmlns:aaa="mySymbolicPackageName"> <aaa:MyObject.myComplexTypeProperty> ... serialization of this property </aaa:MyObject.myComplexTypeProperty> </aaa:MyObject> Therefore if 'mySymbolicPackageName' would be mapped to 'myClientPackage', an instance of myClientPackage.MyObject is initialized which has to have the following properties: - an int property with name 'myIntProperty' - a property of some complex type with name 'myComplexTypeProperty' for which a deserializer is registered The xml attribute 'myIntProperty' is read via an ITypeConverter and set in the new object. The xml child node 'MyObject.myComplexTypeProperty' is deserialized via the looked up deserializer and set as value of the property 'myComplexTypeProperty' of the new object.
getTargetClass | () | method |
protected function getTargetClass(symbolicPackageName:String, className:String):Class
Tries to lookup the given symbolicPackageName
in the SymbolicPackageNameRegistry
and to
resolve the resulting package name with the given className
to a Class
object.
If an extension class exists with 'Extension' appended to the given className
, the extension class
is returned instead of the class itself.
Parameters
symbolicPackageName:String — The symbolic package name to look up in the SymbolicPackageNameRegistry .
| |
className:String — The class name to resolve.
|
Class — A resolved class object or an extension class object or null if no class could be resolved.
|
isCollectionProperty | () | method |
protected function isCollectionProperty(context:GraphMLParseContext, instance:Object, propertyClass:Class):Boolean
Returns true
, if the property is assignable to com.yworks.support.List
.
Parameters
context:GraphMLParseContext — The current parse context
| |
instance:Object — The target instance
| |
propertyClass:Class — the property type
|
Boolean — true if the property is a collection property.
|
parseCollectionProperty | () | method |
protected function parseCollectionProperty(context:GraphMLParseContext, instance:Object, collectionChildren:XMLList, propertyName:String):void
Parses and applies collectionContent
to a list property.
Parameters
context:GraphMLParseContext — The current parse context.
| |
instance:Object — A list of child content that is inserted in the collection as single elements.
| |
collectionChildren:XMLList — The target instance.
| |
propertyName:String — the name of the list property
|
See also