Packageorg.pranaframework.utils
Classpublic class ClassUtils

Provides utilities for working with Class objects.



Public Methods
 MethodDefined by
  
forInstance(instance:*, applicationDomain:ApplicationDomain = null):Class
[static] Returns a Class object that corresponds with the given instance.
ClassUtils
  
forName(name:String, applicationDomain:ApplicationDomain = null):Class
[static] Returns a Class object that corresponds with the given name.
ClassUtils
  
getParentClass(clazz:Class):Class
[static] Returns the class that the passed in clazz extends.
ClassUtils
  
isImplementationOf(clazz:Class, interfaze:Class):Boolean
[static] Returns whether the passed in Class object implements the given interface.
ClassUtils
  
isSubclassOf(clazz:Class, parentClass:Class):Boolean
[static] Returns whether the passed in Class object is a subclass of the passed in parent Class.
ClassUtils
  
newInstance(clazz:Class, args:Array = null):*
[static] Creates an instance of the given class and passes the arguments to the constructor.
ClassUtils
Method detail
forInstance()method
public static function forInstance(instance:*, applicationDomain:ApplicationDomain = null):Class

Returns a Class object that corresponds with the given instance. If no correspoding class was found, a ClassNotFoundError will be thrown.

Parameters
instance:* — the instance from which to return the class
 
applicationDomain:ApplicationDomain (default = null) — the optional applicationdomain where the instance's class resides

Returns
Class — the Class that corresponds with the given instance

See also

forName()method 
public static function forName(name:String, applicationDomain:ApplicationDomain = null):Class

Returns a Class object that corresponds with the given name. If no correspoding class was found in the applicationdomain tree, a ClassNotFoundError will be thrown.

Parameters
name:String — the name from which to return the class
 
applicationDomain:ApplicationDomain (default = null) — the optional applicationdomain where the instance's class resides

Returns
Class — the Class that corresponds with the given name

See also

getParentClass()method 
public static function getParentClass(clazz:Class):Class

Returns the class that the passed in clazz extends. If no parent class was found, in case of Object, null is returned.

Parameters
clazz:Class — the class to get the parent class from

Returns
Class
isImplementationOf()method 
public static function isImplementationOf(clazz:Class, interfaze:Class):Boolean

Returns whether the passed in Class object implements the given interface.

Parameters
clazz:Class — the class to check for an implemented interface
 
interfaze:Class — the interface that the clazz argument should implement

Returns
Boolean — true if the clazz object implements the given interface; false if not
isSubclassOf()method 
public static function isSubclassOf(clazz:Class, parentClass:Class):Boolean

Returns whether the passed in Class object is a subclass of the passed in parent Class.

Parameters
clazz:Class
 
parentClass:Class

Returns
Boolean
newInstance()method 
public static function newInstance(clazz:Class, args:Array = null):*

Creates an instance of the given class and passes the arguments to the constructor. TODO find a generic solution for this. Currently we support constructors with a maximum of 10 arguments.

Parameters
clazz:Class — the class from which an instance will be created
 
args:Array (default = null) — the arguments that need to be passed to the constructor

Returns
*