Packageorg.granite.util
Classpublic class ClassUtil

Static utility methods for Class manipulation.



Public Properties
 PropertyDefined by
  systemDomain : ApplicationDomain
[static][read-only] The Flash VM system application domain.
ClassUtil
Public Methods
 MethodDefined by
  
describeClass(clazz:Class):XML
[static] This method returns the XML description of the supplied class parameter.
ClassUtil
  
extractPackageName(name:String):String
[static] Returns the package name of the supplied class name parameter.
ClassUtil
  
extractSimpleName(name:String):String
[static] Returns the simple (without the package part) name of the supplied class name parameter.
ClassUtil
  
forInstance(o:*, domain:ApplicationDomain = null):Class
[static] Returns the Class of the supplied instance parameter.
ClassUtil
  
forName(name:String, domain:ApplicationDomain = null):Class
[static] Returns the Class denoted by the name parameter, in the optional application domain parameter.
ClassUtil
  
getName(clazz:Class):String
[static] Returns the fully qualified name of the supplied Class parameter in the form of "path.to::MyClass".
ClassUtil
  
getPackageName(clazz:Class):String
[static] Returns the package name of the supplied Class parameter.
ClassUtil
  
getSimpleName(clazz:Class):String
[static] Returns the simple (without the package part) name of the supplied Class parameter.
ClassUtil
  
getUnqualifiedClassName(o:Object):String
[static] Get the unqualified (simple) class name of the object passed as a parameter.
ClassUtil
  
hasDefinition(name:String, domain:ApplicationDomain = null):Boolean
[static] Test if a class name exists in the supplied domain or in the global system domain.
ClassUtil
  
isAnnotatedWith(o:*, annotationName:String):Boolean
[static] Tests if the supplied object class is annotated with a given annotation name.
ClassUtil
  
isFlashClass(clazz:Class):Boolean
[static] Tests if the supplied clazz parameter is a Flash class, ie.
ClassUtil
  
isMathClass(clazz:Class):Boolean
[static] Tests if the supplied clazz parameter is a GraniteDS Math class, ie.
ClassUtil
  
isMxClass(clazz:Class):Boolean
[static] Tests if the supplied clazz parameter is a Flex class, ie.
ClassUtil
  
isTopLevel(clazz:Class):Boolean
[static] Tests if the supplied clazz parameter is a Top Level class defined in the Flash 10 VM (including Vector).
ClassUtil
  
isVector(o:*):Boolean
[static] Tests if the supplied o parameter is an instance of the Flash 10 Vector class.
ClassUtil
  
parseQName(name:String, upperPolicy:Boolean = true):Array
[static] Split a name into a namespace prefix and a value.
ClassUtil
Property detail
systemDomainproperty
systemDomain:ApplicationDomain  [read-only]

The Flash VM system application domain.

Implementation
    public static function get systemDomain():ApplicationDomain
Method detail
describeClass()method
public static function describeClass(clazz:Class):XML

This method returns the XML description of the supplied class parameter.

It actually just calls the flash.utils.describeType builtin method (mx.utils.DescribeTypeCache is buggy and its caching startegy is unsuitable for multiple application domain support).

Parameters
clazz:Class — the class from which the XML description is to be returned.

Returns
XML — the XML description of the class.

See also

flash.utils.describeType
extractPackageName()method 
public static function extractPackageName(name:String):String

Returns the package name of the supplied class name parameter. The class name must be in the form of "path.to::MyClass".

Parameters
name:String — class name used for extraction.

Returns
String — the package name of the supplied class name.
extractSimpleName()method 
public static function extractSimpleName(name:String):String

Returns the simple (without the package part) name of the supplied class name parameter. The class name must be in the form of "path.to::MyClass".

Parameters
name:String — class name used for extraction.

Returns
String — the simple name of the supplied class name.
forInstance()method 
public static function forInstance(o:*, domain:ApplicationDomain = null):Class

Returns the Class of the supplied instance parameter.

Notes:

Parameters
o:* — the instance from which the Class is to be returned.
 
domain:ApplicationDomain (default = null) — the optional application domain to be used for getting the class definition.

Returns
Class — the Class of the supplied instance (or null if the o parameter is null).

Throws
— if o is a function or a class.
 
ClassNotFoundError — if no Class can be found in the supplied or system domain with this the given object class name.
forName()method 
public static function forName(name:String, domain:ApplicationDomain = null):Class

Returns the Class denoted by the name parameter, in the optional application domain parameter. If domain parameter is null, this method will try to use the Flash system domain.

Parameters
name:String — the class name.
 
domain:ApplicationDomain (default = null) — the optional application domain to be used for getting the class definition.

Returns
Class — the Class object denoted by the name parameter (or null if the name parameter is null).

Throws
ClassNotFoundError — if no Class can be found in the supplied or system domain with this name.
getName()method 
public static function getName(clazz:Class):String

Returns the fully qualified name of the supplied Class parameter in the form of "path.to::MyClass".

Parameters
clazz:Class — class whose name is to be returned.

Returns
String — the fully qualified name of the supplied Class.
getPackageName()method 
public static function getPackageName(clazz:Class):String

Returns the package name of the supplied Class parameter.

Parameters
clazz:Class — class whose package name is to be returned.

Returns
String — the package name of the supplied Class.
getSimpleName()method 
public static function getSimpleName(clazz:Class):String

Returns the simple (without the package part) name of the supplied Class parameter.

Parameters
clazz:Class — class whose name is to be returned.

Returns
String — the simple name of the supplied Class.
getUnqualifiedClassName()method 
public static function getUnqualifiedClassName(o:Object):String

Get the unqualified (simple) class name of the object passed as a parameter.

Parameters
o:Object — object whose class name is to be returned.

Returns
String — the unqualified class name of the supplied object.
hasDefinition()method 
public static function hasDefinition(name:String, domain:ApplicationDomain = null):Boolean

Test if a class name exists in the supplied domain or in the global system domain.

Parameters
name:String — the class name.
 
domain:ApplicationDomain (default = null) — the optional application domain to be used for testing the class definition.

Returns
Booleantrue if the class name exists in the supplied domain or, if domain is null, in the system domain; false otherwise.
isAnnotatedWith()method 
public static function isAnnotatedWith(o:*, annotationName:String):Boolean

Tests if the supplied object class is annotated with a given annotation name.

Parameters
o:* — the object (may be a class) to test.
 
annotationName:String — the annotation name to look for.

Returns
Booleantrue if the object is annotated with the given annotation name, false otherwise.
isFlashClass()method 
public static function isFlashClass(clazz:Class):Boolean

Tests if the supplied clazz parameter is a Flash class, ie. defined in the flash or air package or any of their subpackages.

Parameters
clazz:Class — the classe to be tested.

Returns
Booleantrue if clazz is a Flash class, false otherwise.
isMathClass()method 
public static function isMathClass(clazz:Class):Boolean

Tests if the supplied clazz parameter is a GraniteDS Math class, ie. in the org.granite.math package or any of its subpackages.

Parameters
clazz:Class — the classe to be tested.

Returns
Booleantrue if clazz is a big number class, false otherwise.
isMxClass()method 
public static function isMxClass(clazz:Class):Boolean

Tests if the supplied clazz parameter is a Flex class, ie. defined in the mx package or any of its subpackages.

Parameters
clazz:Class — the classe to be tested.

Returns
Booleantrue if clazz is a Flex class, false otherwise.
isTopLevel()method 
public static function isTopLevel(clazz:Class):Boolean

Tests if the supplied clazz parameter is a Top Level class defined in the Flash 10 VM (including Vector).

Parameters
clazz:Class — the classe to be tested.

Returns
Booleantrue if clazz is a top level class, false otherwise.
isVector()method 
public static function isVector(o:*):Boolean

Tests if the supplied o parameter is an instance of the Flash 10 Vector class. This method doesn't use directly the Vector class, so it is compatible with earlier Flash versions.

Parameters
o:* — the instance to test.

Returns
Booleantrue if o is a Vector instance, false otherwise.
parseQName()method 
public static function parseQName(name:String, upperPolicy:Boolean = true):Array

Split a name into a namespace prefix and a value. Returns an array of two Strings, the first one containing the prefix (possibly null or empty), the second one containing the associated value.

   ClassUtil.parseQName("path.to.MyClass"); // [null, "path.to.MyClass"]
   ClassUtil.parseQName("path.to::MyClass"); // [null, "path.to::MyClass"]
   ClassUtil.parseQName("::MyClass"); // [null, "::MyClass"]
   ClassUtil.parseQName(":MyClass"); // ["", "MyClass"]
   ClassUtil.parseQName("MyClass"); // ["", "MyClass"]
   ClassUtil.parseQName("MyClass.Inner"); // ["", "MyClass.Inner"]
   ClassUtil.parseQName("myClass.Inner"); // [null, "myClass.Inner"]
   ClassUtil.parseQName("MyClass", false)); // ["", "MyClass"]
   ClassUtil.parseQName("MyClass.Inner", false); // [null, "MyClass.Inner"]
   ClassUtil.parseQName("myClass.Inner", false); // [null, "myClass.Inner"]
   ClassUtil.parseQName("abc:MyClass"); // ["abc", "MyClass"]
   ClassUtil.parseQName("ABC:MyClass"); // ["ABC", "MyClass"]

Parameters
name:String — the name to be parsed for namespace prefix and value.
 
upperPolicy:Boolean (default = true) — should we consider a String without any ':' character but at least one '.' character and beginning by an uppercase letter as a qualified name in the default namespace?

Returns
Array — an array of two Strings, the first one containing the prefix (possibly null or empty), the second one containing the associated value.