Packagetwaver
Classpublic class XMLSerializer
InheritanceXMLSerializer Inheritance Object

This class wrapps a XML serializer that is used to serialize or deserialize all data of a data box.

TWaver provides the ability to load network data from TWaver defined XML, or export network data to XML. These can be finished by using this XML serializer.

With XML serialization support, you can load/export network data in XML and transport to other non-flex platform like Java, .NET even mobile equipment that support XML. TWaver Java, TWaver SilverLight, TWaver Web and all TWaver branches are all support the unified XML format.

XML serializer always works with a data box container. You can specify a setting class with more parameters to control the detail behaviours of this XML serializer.

For example, following code serialize a data box data and display the result XML content in a text field:

	 var serializer:XMLSerializer = new XMLSerializer(databox);
	 textField.text = serializer.serialize();
	 



Public Properties
 PropertyDefined By
  dataBox : DataBox
The data box instance this XML serializer connected to.
XMLSerializer
  filterFunction : Function = null
A filter that is used to control what should be serialized/deserialized.
XMLSerializer
  idMap : Dictionary
A map contains all datas information
XMLSerializer
  refMap : Dictionary
A map contains the reference relationship for the data contains in the connecting data box.
XMLSerializer
  settings : SerializationSettings
The setting object contains all parameters for this serializer.
XMLSerializer
  xmlString : String
The xml content string.
XMLSerializer
Public Methods
 MethodDefined By
  
XMLSerializer(dataBox:DataBox, settings:SerializationSettings = null)
Create a XML serializer for the specified data box with given setting parameters.
XMLSerializer
  
deserialize(xmlString:String, rootParent:IData = null):void
Deserialize data from specified XML content and add into data box under given parent element.
XMLSerializer
  
deserializeClient(instance:Object, xml:XML, property:String):void
Deserialize client property from specified XML content.
XMLSerializer
  
deserializeProperty(instance:Object, xml:XML, property:String):void
Deserialize property from specified XML content.
XMLSerializer
  
deserializeStyle(instance:Object, xml:XML, property:String):void
Deserialize style property from specified XML content.
XMLSerializer
  
deserializeValue(xml:XML, type:String):Object
Deserialize value from specified XML content.
XMLSerializer
  
serialize():String
Serialize data of the data box into XML, then return the XML as a string.
XMLSerializer
  
serializeClient(instance:Object, client:String, newInstance:Object):void
Serialize a client property into XML.
XMLSerializer
  
serializeProperty(instance:Object, property:String, newInstance:Object):void
Serialize a property into XML.
XMLSerializer
  
serializeStyle(instance:Object, style:String, newInstance:Object):void
Serialize a style property into XML.
XMLSerializer
  
serializeValue(c:String, property:String, value:Object, newInstanceValue:Object, type:String, cdata:Boolean):void
Serialize value into XML.
XMLSerializer
Protected Methods
 MethodDefined By
  
isSerializable(data:IData):Boolean
Check whether this data is should serialized.
XMLSerializer
  
Serialize all data of data box and save in "xmlString" variable into a XML body.
XMLSerializer
  
serializeData(data:IData):void
Serialize specified data.
XMLSerializer
Property Detail
dataBoxproperty
public var dataBox:DataBox

The data box instance this XML serializer connected to.

filterFunctionproperty 
public var filterFunction:Function = null

A filter that is used to control what should be serialized/deserialized.

idMapproperty 
public var idMap:Dictionary

A map contains all datas information

refMapproperty 
public var refMap:Dictionary

A map contains the reference relationship for the data contains in the connecting data box.

settingsproperty 
public var settings:SerializationSettings

The setting object contains all parameters for this serializer.

xmlStringproperty 
public var xmlString:String

The xml content string.

Constructor Detail
XMLSerializer()Constructor
public function XMLSerializer(dataBox:DataBox, settings:SerializationSettings = null)

Create a XML serializer for the specified data box with given setting parameters.

Parameters
dataBox:DataBox — the data box this serializer will work for.
 
settings:SerializationSettings (default = null) — a setting object contains more parameters for the serialization.
Method Detail
deserialize()method
public function deserialize(xmlString:String, rootParent:IData = null):void

Deserialize data from specified XML content and add into data box under given parent element.

Parameters

xmlString:String — XML content contains data.
 
rootParent:IData (default = null) — the root parent of these deserialzed data in this data box.

deserializeClient()method 
public function deserializeClient(instance:Object, xml:XML, property:String):void

Deserialize client property from specified XML content.

Parameters

instance:Object — the host instance of this client property.
 
xml:XML — XML content.
 
property:String — client property name.

deserializeProperty()method 
public function deserializeProperty(instance:Object, xml:XML, property:String):void

Deserialize property from specified XML content.

Parameters

instance:Object — the host instance of this property.
 
xml:XML — XML content.
 
property:String — property name.

deserializeStyle()method 
public function deserializeStyle(instance:Object, xml:XML, property:String):void

Deserialize style property from specified XML content.

Parameters

instance:Object — the host instance of this style property.
 
xml:XML — XML content.
 
property:String — style property name.

deserializeValue()method 
public function deserializeValue(xml:XML, type:String):Object

Deserialize value from specified XML content.

Parameters

xml:XML — the XML content.
 
type:String — property class name.

Returns
Object — the deserialized value.
isSerializable()method 
protected function isSerializable(data:IData):Boolean

Check whether this data is should serialized. This can be controled by the filter function.

Parameters

data:IData — a data to be checked.

Returns
Boolean — true if should serialized, false otherwise.
serialize()method 
public function serialize():String

Serialize data of the data box into XML, then return the XML as a string.

Returns
String — the serialized XML contains data of the connecting data box.
serializeBody()method 
protected function serializeBody():void

Serialize all data of data box and save in "xmlString" variable into a XML body. The XML body contains all XML content except the root "twaver" XML tag.

serializeClient()method 
public function serializeClient(instance:Object, client:String, newInstance:Object):void

Serialize a client property into XML.

Parameters

instance:Object — the value instance to be serialized.
 
client:String — client property name.
 
newInstance:Object — a new instance that will be used to compare whether equal to the specified instance. If equal, then this value does not need to be serialized.

serializeData()method 
protected function serializeData(data:IData):void

Serialize specified data.

Parameters

data:IData — a data to be serialized.

serializeProperty()method 
public function serializeProperty(instance:Object, property:String, newInstance:Object):void

Serialize a property into XML.

Parameters

instance:Object — the value instance to be serialized.
 
property:String — the property name.
 
newInstance:Object — a new instance that will be used to compare whether equal to the specified instance. If equal, then this value does not need to be serialized.

serializeStyle()method 
public function serializeStyle(instance:Object, style:String, newInstance:Object):void

Serialize a style property into XML.

Parameters

instance:Object — the value instance to be serialized.
 
style:String — style property name.
 
newInstance:Object — a new instance that will be used to compare whether equal to the specified instance. If equal, then this value does not need to be serialized.

serializeValue()method 
public function serializeValue(c:String, property:String, value:Object, newInstanceValue:Object, type:String, cdata:Boolean):void

Serialize value into XML.

Parameters

c:String — the property type. It can be "p", "s" or "c" refer to property, style property or client property.
 
property:String — property name.
 
value:Object — property value.
 
newInstanceValue:Object — the default new instance value of this property. This will be used to compare whether equal to the specified instance. If equal, then this value does not need to be serialized.
 
type:String — class type. This can be: Consts.TYPE_DATA, Consts.TYPE_POINT, Consts.TYPE_COLLECTION_POINT, Consts.TYPE_COLLECTION_STRING, Consts.TYPE_RECTANGLE.
 
cdata:Boolean — whether this is XML cdata type data.