PackageappCoreLib.utils
Classpublic class ClassUtil

Contains methods for translating various object types to specific class instances and data types.

NOTE
In order for complex data types in arrays to correctly translate, you need to ensure to add the following to your project's compiler options: -keep-as3-metadata ArrayElementType

and any other custom metadata tags used in your project necessary for proper object translation.

Also you will need to add the ArrayElementType metadata tags to your classes.



Public Methods
 MethodDefined by
  
createClassFromObject(obj:Object, targetClass:Class):Object
[static] Creates a specified class instance from a generic object.
ClassUtil
  
createClassFromXMLObject(obj:XML, targetClass:Class):*
[static]
ClassUtil
  
createXMLfromObject(obj:Object, skipOnNullValues:Boolean = true):XML
[static] Creates an XML object from a target object.
ClassUtil
  
customCast(dataType:String, value:*):*
[static] Takes a value and cast to a specified type.
ClassUtil
Method detail
createClassFromObject()method
public static function createClassFromObject(obj:Object, targetClass:Class):Object

Creates a specified class instance from a generic object. If the object is an XML instance, then it will utilize createClassFromXMLObject.

Parameters
obj:Object — The object to translate into a class instance.
 
targetClass:Class — The class which the object is translated to.

Returns
Object — Object The class instance of the translated object.
createClassFromXMLObject()method 
public static function createClassFromXMLObject(obj:XML, targetClass:Class):*Parameters
obj:XML
 
targetClass:Class

Returns
*
createXMLfromObject()method 
public static function createXMLfromObject(obj:Object, skipOnNullValues:Boolean = true):XML

Creates an XML object from a target object.

Parameters
obj:Object — The target object to translate into XML.
 
skipOnNullValues:Boolean (default = true) — You can elect to not add XML nodes to the XML object if the target object's properties are null.

Returns
XML — An XML object representation of the target object
customCast()method 
public static function customCast(dataType:String, value:*):*

Takes a value and cast to a specified type.

Parameters
dataType:String — The desired object type to translate the value to.
 
value:* — The value to be cast.

Returns
* — the value cast to the specified dataType.