Packagetwaver
Classpublic class Data
InheritanceData Inheritance flash.events.EventDispatcher
Implements IData
Subclasses Alarm, Element, Layer

This class defines an abstract network data that will be managed by DataBox. Element and alarm are all typical network data in TWaver Flex. This class defines very high level common basic data properties such as ID, children, parent etc. Also, this class extends from EventDispatcher so it has the ability to send event when property has been changed.



Public Properties
 PropertyDefined By
  children : ICollection
[read-only] Get all children data objects of this data object.
Data
  childrenCount : int
[read-only] Get all children total count for this data.
Data
  clientProperties : ICollection
[read-only] Get a ICollection that contians all client proerty name.
Data
  hasChildren : Boolean
[read-only] Check whether this data has children objects.
Data
  icon : String
Get icon value for this data.
Data
  id : Object
[read-only] Get the ID value of this data.
Data
  name : String
Get name of this data.
Data
  parent : IData
Get parent data object.
Data
  toolTip : String
Get the tooltip text of this data.
Data
Public Methods
 MethodDefined By
  
Data(id:Object = null)
Constructor.
Data
  
addChild(child:IData, index:int = -1):Boolean
Add a child data object for this data.
Data
  
addPropertyChangeListener(listener:Function, priority:int = 0, useWeakReference:Boolean = false):void
Add a property change listener to this data to monitoring property change event.
Data
  
clearChildren():Boolean
Clear all children from this data.
Data
  
deserializeXML(serializer:XMLSerializer, xml:XML):void
Deserialize given XML data to data objects.
Data
  
dispatchPropertyChangeEvent(property:String, oldValue:Object, newValue:Object):Boolean
Dispatch property change event to all installed listeners.
Data
  
getChildAt(index:int):IData
Get child as specified index location.
Data
  
getClient(clientProp:String):*
Get specified client property value.
Data
  
getPropertyValue(property:String):Object
Get specified property value from this data.
Data
  
hasOwnProperty(name:String):Boolean
Whether this data has specified property.
Data
  
isDescendantOf(data:IData):Boolean
Check whether this data is a descendant of the specified data object.
Data
  
isParentOf(data:IData):Boolean
Check whether this data is the parent of specified data.
Data
  
isRelatedTo(data:IData):Boolean
Check whether this data has descendant relationship with the specified data.
Data
  
removeChild(child:IData):Boolean
Remove the specified child object.
Data
  
removePropertyChangeListener(listener:Function):void
Remove the specified property change listener.
Data
  
serializeXML(serializer:XMLSerializer, newInstance:IData):void
Serialize this data object into XML.
Data
  
setClient(clientProp:String, newValue:*):IClient
Set client property for this data.
Data
  
setPropertyValue(property:String, value:Object):void
Set specified property name value on this data.
Data
  
toChildren(matchFunction:Function = null):ICollection
Iterate children collection by given callback function.
Data
  
toString():String
[override]
Data
Protected Methods
 MethodDefined By
  
deserializeClient(serializer:XMLSerializer, clientXML:XML, clientProp:String):void
Deserialize client property from given XML data.
Data
  
deserializeProperty(serializer:XMLSerializer, propertyXML:XML, property:String):void
Deserialize specified property from the given XML data contains property value.
Data
  
onChildAdded(child:IData, index:int):void
Called back when a child is added.
Data
  
onChildRemoved(child:IData, index:int):void
Called back when a child is removed.
Data
  
onChildrenCleared(children:Array):void
Called back when all children are cleared from this data.
Data
  
onClientChanged(styleProp:String, oldValue:*, newValue:*):void
Called when client property is changed.
Data
  
onParentChanged(oldParent:IData, newParent:IData):void
Called back when data parent changed.
Data
  
onPropertyChanged(property:String, oldValue:Object, newValue:Object):void
Called back when a property of this data is changed.
Data
  
serializeClient(serializer:XMLSerializer, clientPrope:String, newInstance:IData):void
Serialize given client property into the specified XML serializer.
Data
  
serializeProperty(serializer:XMLSerializer, property:String, newInstance:IData):void
Serialize given property into the specified XML serializer.
Data
Property Detail
childrenproperty
children:ICollection  [read-only]

Get all children data objects of this data object.


Implementation
    public function get children():ICollection
childrenCountproperty 
childrenCount:int  [read-only]

Get all children total count for this data.


Implementation
    public function get childrenCount():int
clientPropertiesproperty 
clientProperties:ICollection  [read-only]

Get a ICollection that contians all client proerty name.


Implementation
    public function get clientProperties():ICollection
hasChildrenproperty 
hasChildren:Boolean  [read-only]

Check whether this data has children objects.


Implementation
    public function get hasChildren():Boolean
iconproperty 
icon:String

Get icon value for this data. Please note the difference between icon and image of this data.


Implementation
    public function get icon():String
    public function set icon(value:String):void
idproperty 
id:Object  [read-only]

Get the ID value of this data.


Implementation
    public function get id():Object
nameproperty 
name:String

Get name of this data.


Implementation
    public function get name():String
    public function set name(value:String):void
parentproperty 
parent:IData

Get parent data object.


Implementation
    public function get parent():IData
    public function set parent(value:IData):void
toolTipproperty 
toolTip:String

Get the tooltip text of this data.


Implementation
    public function get toolTip():String
    public function set toolTip(value:String):void
Constructor Detail
Data()Constructor
public function Data(id:Object = null)

Constructor.

Parameters
id:Object (default = null) — the data identifier. This should be an unique object in one data box. If null value specified, TWaver Flex will create an value for it internally.
Method Detail
addChild()method
public function addChild(child:IData, index:int = -1):Boolean

Add a child data object for this data.

Parameters

child:IData — the child data object
 
index:int (default = -1) — the index of this children.

Returns
Boolean — true if success, false otherwise.
addPropertyChangeListener()method 
public function addPropertyChangeListener(listener:Function, priority:int = 0, useWeakReference:Boolean = false):void

Add a property change listener to this data to monitoring property change event.

Parameters

listener:Function — the listener object.
 
priority:int (default = 0) — listener priority
 
useWeakReference:Boolean (default = false) — whether use weak reference. Default value is false.

clearChildren()method 
public function clearChildren():Boolean

Clear all children from this data. Please note call this method will not move children from element box or databox. This is just cut the child-parent relationship between children data and this data.

Returns
Boolean — true if done, false otherwise.
deserializeClient()method 
protected function deserializeClient(serializer:XMLSerializer, clientXML:XML, clientProp:String):void

Deserialize client property from given XML data.

Parameters

serializer:XMLSerializer — the XML deserializer.
 
clientXML:XML — XML data contains client property
 
clientProp:String — client property name.

deserializeProperty()method 
protected function deserializeProperty(serializer:XMLSerializer, propertyXML:XML, property:String):void

Deserialize specified property from the given XML data contains property value.

Parameters

serializer:XMLSerializer — XML serializer
 
propertyXML:XML — XML data contains property value
 
property:String — property name will be deserialized.

deserializeXML()method 
public function deserializeXML(serializer:XMLSerializer, xml:XML):void

Deserialize given XML data to data objects.

Parameters

serializer:XMLSerializer — XML serializer
 
xml:XML — the XML data contains data objects.

dispatchPropertyChangeEvent()method 
public function dispatchPropertyChangeEvent(property:String, oldValue:Object, newValue:Object):Boolean

Dispatch property change event to all installed listeners.

Parameters

property:String — the property name of the changed property.
 
oldValue:Object — value before changed
 
newValue:Object — value after changed

Returns
Boolean — true if the event dispatched successfully, false otherwise.
getChildAt()method 
public function getChildAt(index:int):IData

Get child as specified index location.

Parameters

index:int — the child index location

Returns
IData — child at the specified index location
getClient()method 
public function getClient(clientProp:String):*

Get specified client property value.

Parameters

clientProp:String — client property name

Returns
* — value of this client property.
getPropertyValue()method 
public function getPropertyValue(property:String):Object

Get specified property value from this data. This can be a client property, or regular property. For client property, be ware use the Consts.PREFIX_CLIENT prefix to identify.

Parameters

property:String — the property name to get.

Returns
Object — the property value, if has
hasOwnProperty()method 
public function hasOwnProperty(name:String):Boolean

Whether this data has specified property.

Parameters

name:String — the property name

Returns
Boolean — true if has this property, false otherwise.
isDescendantOf()method 
public function isDescendantOf(data:IData):Boolean

Check whether this data is a descendant of the specified data object.

Parameters

data:IData — a data object need to check

Returns
Boolean — true if is descendant, false otherwise.
isParentOf()method 
public function isParentOf(data:IData):Boolean

Check whether this data is the parent of specified data.

Parameters

data:IData — the data object need to check

Returns
Boolean — true if this data is the parent of specified data, false otherwise.
isRelatedTo()method 
public function isRelatedTo(data:IData):Boolean

Check whether this data has descendant relationship with the specified data.

Parameters

data:IData — a data object to check.

Returns
Boolean — true if the two data has descendant relationship, false otherwise.
onChildAdded()method 
protected function onChildAdded(child:IData, index:int):void

Called back when a child is added. Subclasses can overwrite this method to do something.

Parameters

child:IData — the new added child data object
 
index:int — the index of the new added child data object

onChildRemoved()method 
protected function onChildRemoved(child:IData, index:int):void

Called back when a child is removed. Subclasses could overwrite this method to do something when a child is removed from this data.

Parameters

child:IData — the removed child data.
 
index:int — the index of the removed child data.

onChildrenCleared()method 
protected function onChildrenCleared(children:Array):void

Called back when all children are cleared from this data. Subclasses could overwrite this method to do something on children are all cleared.

Parameters

children:Array — all children data has just cleared.

onClientChanged()method 
protected function onClientChanged(styleProp:String, oldValue:*, newValue:*):void

Called when client property is changed.

Parameters

styleProp:String — property name
 
oldValue:* — old value before the change
 
newValue:* — new value after the change

onParentChanged()method 
protected function onParentChanged(oldParent:IData, newParent:IData):void

Called back when data parent changed. Subclasses could overwrite this method to do something when parent is changed.

Parameters

oldParent:IData — old parent before changed.
 
newParent:IData — new parent after changed.

onPropertyChanged()method 
protected function onPropertyChanged(property:String, oldValue:Object, newValue:Object):void

Called back when a property of this data is changed.

Parameters

property:String — property name changed
 
oldValue:Object — old value before property change
 
newValue:Object — new value after property change

removeChild()method 
public function removeChild(child:IData):Boolean

Remove the specified child object.

Parameters

child:IData — the child object to be removed

Returns
Boolean — true if removed, false otherwise.
removePropertyChangeListener()method 
public function removePropertyChangeListener(listener:Function):void

Remove the specified property change listener.

Parameters

listener:Function — the listener instance need to remove

serializeClient()method 
protected function serializeClient(serializer:XMLSerializer, clientPrope:String, newInstance:IData):void

Serialize given client property into the specified XML serializer.

Parameters

serializer:XMLSerializer — the XML serializer
 
clientPrope:String — the client property to be serialized
 
newInstance:IData — a brand new instance of current class with default values. This will be used during the XML serialization to compare the serializing object value and the default instance value. If the value is different, then serialize; otherwise, not serialize.

serializeProperty()method 
protected function serializeProperty(serializer:XMLSerializer, property:String, newInstance:IData):void

Serialize given property into the specified XML serializer.

Parameters

serializer:XMLSerializer — the XML serializer object
 
property:String — property to be serialized
 
newInstance:IData — a brand new instance of current class with default values. This will be used during the XML serialization to compare the serializing object value and the default instance value. If the value is different, then serialize; otherwise, not serialize.

serializeXML()method 
public function serializeXML(serializer:XMLSerializer, newInstance:IData):void

Serialize this data object into XML.

Parameters

serializer:XMLSerializer — the XML serializer.
 
newInstance:IData — a brand new instance of current class with default values. This will be used during the XML serialization to compare the serializing object value and the default instance value. If the value is different, then serialize; otherwise, not serialize.

setClient()method 
public function setClient(clientProp:String, newValue:*):IClient

Set client property for this data.

Parameters

clientProp:String — client property name.
 
newValue:* — client property value.

Returns
IClient — current data itself. This is possible to write code like data.setClient("a",a).setClient("b",b)...
setPropertyValue()method 
public function setPropertyValue(property:String, value:Object):void

Set specified property name value on this data.

Parameters

property:String — the property name to be set.
 
value:Object — the property value to be set.

toChildren()method 
public function toChildren(matchFunction:Function = null):ICollection

Iterate children collection by given callback function.

Parameters

matchFunction:Function (default = null) — the callback function of the iteration

Returns
ICollection — the collection of all children
toString()method 
override public function toString():String

Returns
String