Class org.as2lib.env.reflect.PackageInfo

org.as2lib.core.BasicClass
   +--org.as2lib.env.reflect.PackageInfo

Implemented Interfaces

PackageMemberInfo

Description

PackageInfo represents a real package in the Flash environment. This class is used to get specific information about the package it represents.

You can use the static search methods forName and forPackage to get package infos for specific packages.

If you for example have a package you wanna get information about you first must retrieve the appropriate PackageInfo instance and you can then use its methods to get the wanted information. var packageInfo:PackageInfo = PackageInfo.forPackage(org.as2lib.core); trace("Package full name: " + packageInfo.getFullName()); trace("Parent package name: " + packageInfo.getParent().getName()); trace("Member classes: " + packageInfo.getMemberClasses()); trace("Member packages: " + packageInfo.getMemberPackages());

Method Index

new PackageInfo()

forName(), forPackage(), getFullName(), getMember(), getMemberByMember(), getMemberByName(), getMemberClass(), getMemberClassByClass(), getMemberClassByName(), getMemberClasses(), getMemberClassesByFilter(), getMemberClassesByFlag(), getMemberPackage(), getMemberPackageByName(), getMemberPackageByPackage(), getMemberPackages(), getMemberPackagesByFilter(), getMemberPackagesByFlag(), getMembers(), getMembersByFilter(), getMembersByFlag(), getName(), getPackage(), getPackageAlgorithm(), getPackageMemberAlgorithm(), getParent(), getRootPackage(), isParentPackage(), isRoot(), setPackageAlgorithm(), setPackageMemberAlgorithm(), setRootPackage(), toString()

Constructor Detail

PackageInfo

public function PackageInfo(package, name:String, parent:PackageInfo)

Constructs a new PackageInfo instance.

Note that you do not have to pass-in the concrete package. But if you do not pass it in some methods cannot do their job correctly.

If you do not pass-in the name or the parent they are resolved lazily when requested using the passed-in package.

Parameters

packagethe actual package this instance represents
name(optional) the name of the package
parent(optional) the parent package

Method Detail

forName

static public function forName(packageName:String):PackageInfo

Returns the package info corresponding to the passed-in packageName.

The passed-in packageName must be composed of the preceding path and the actual package name, that means it must be fully qualified. For example "org.as2lib.core".

This method first checks whether the package is already contained in the cache.

Parameters

packageNamethe fully qualified name of the package to find

Return

the package info corresponding to the passed-in packageName

Throws

IllegalArgumentExceptionif the passed-in packageName is null, undefined or an empty string or if the object corresponding to the passed-in packageName is not of type "object"
PackageNotFoundExceptionif a package with the passed-in packageName could not be found

forPackage

static public function forPackage(package):PackageInfo

Returns the package info corresponding to the passed-in package.

This method first checks whether the package info is already contained in the cache.

Parameters

packagethe package you wanna get the package info for

Return

the package info corresponding to the passed-in package

Throws

IllegalArgumentExceptionif the passed-in package is null or undefined

setPackageAlgorithm

static public function setPackageAlgorithm(newPackageAlgorithm:PackageAlgorithm):Void

Sets the algorithm used to find packages.

If newPackageAlgorithm is null or undefined, getPackageAlgorithm will return the default package algorithm.

Parameters

newPackageAlgorithmthe new algorithm to find packages

getPackageAlgorithm

static public function getPackageAlgorithm(Void):PackageAlgorithm

Returns the algorithm used to find packages.

Either the algorithm set via setPackageAlgorithm method will be returned or the default one which is an instance of class PackageAlgorithm.

Return

the set or the default package algorithm

setPackageMemberAlgorithm

static public function setPackageMemberAlgorithm(newPackageMemberAlgorithm:PackageMemberAlgorithm):Void

Sets the algorithm used to find members of packages.

Members of packages are classes, interfaces and packages.

If newPackageMemberAlgorithm is null or undefined, getPackageMemberAlgorithm will return the default package member algorithm.

Parameters

newPackageMemberAlgorithmthe new algorithm to find members of packages

getPackageMemberAlgorithm

static public function getPackageMemberAlgorithm(Void):PackageMemberAlgorithm

Returns the member algorithm used to find members of packages.

Either the algorithm set via setPackageMemberAlgorithm will be returned or the default one which is an instance of class PackageMemberAlgorithm.

Return

the set or the default member algorithm

getRootPackage

static public function getRootPackage(Void):PackageInfo

Returns the root package of the package hierarchy.

If you do not set a custom root package via the method, the default root package is returned that refers to _global.

Return

the root package of the package hierarchy.

setRootPackage

static public function setRootPackage(newRootPackage:PackageInfo):Void

Sets the new root package of the package hierarchy.

If the passed-in newRootPackage argument is null or undefined the method will return the default root package.

Parameters

newRootPackagethe new root package of the package hierarchy

getName

public function getName(Void):String

Returns the name of the represented package.

This does not include the package's path/namespace. If this package info represented for example the org.as2lib.core package the returned name would be "core".

Return

the name of the represented package

getFullName

public function getFullName(Void):String

Returns the fully qualified name of the represented package. This means the name of the package plus its package path/namespace.

The path is not included if:

  • The getParent method returns null or undefined.
  • The getParent method returns the root package, that means its isRoot method returns true.

Return

the fully qualified name of the package

Specified By

getFullName() in org.as2lib.env.reflect.PackageMemberInfo

getPackage

public function getPackage(Void)

Returns the actual package this instance represents.

Return

the actual package

getParent

public function getParent(Void):PackageInfo

Returns the parent of the represented package.

The parent is the package the represented package is contained in / a member of. The parent of the package org.as2lib.core is org.as2lib.

Return

the parent of the represented package

getMembers

public function getMembers():Array

getMembersByFlag

public function getMembersByFlag(filterSubPackages:Boolean):Array

Returns an array containing PackageMemberInfo instances representing the members of the package and maybe the ones of the sub-packages.

The members of the package are all types and packages contained in the represented package.

If filterSubPackages is null or undefined it is interpreted as true, that means sub-packages' package members will be filtered/excluded from the result by default.

null will be returned if

Parameters

filterSubPackages(optional) determines whether to filter the sub-packages' members

Return

an array containing the members of the represented package

getMembersByFilter

public function getMembersByFilter(packageMemberFilter:PackageMemberFilter):Array

Returns an array containing PackageMemberInfo instances representing the members of the package and sub-packages that are not filtered/excluded.

The members of this package are all types and packages contained in the represented package.

The PackageMemberFilter.filter method of the passed-in packageMemberFilter is invoked for every package member to determine whether it shall be contained in the result.

If the passed-in packageMemberFilter is null or undefined the result of the invocation of getMembersByFlag with argument true will be returned.

null will be returned if:

Parameters

packageMemberFilterthe filter that filters unwanted package members out

Return

an array containing the remaining members of the represented package

getMemberClasses

public function getMemberClasses():Array

getMemberClassesByFlag

public function getMemberClassesByFlag(filterSubPackages:Boolean):Array

Returns an array containing ClassInfo instances representing the member classes of the package and maybe the ones of the sub-packages.

If filterSubPackages is null or undefined it is interpreted as true, this means that sub-packages' classes are filtered by default.

null will be returned if:

Parameters

filterSubPackages(optional) determines whether to filter/exclude the sub-packages' member classes

Return

an array containing the member classes of the represented package

getMemberClassesByFilter

public function getMemberClassesByFilter(classFilter:PackageMemberFilter):Array

Returns an array containing ClassInfo instances representing the class members of the package and sub-packages that are not filtered/excluded.

The PackageMemberFilter.filter method of the passed-in classFilter is invoked for every member class to determine whether it shall be contained in the result.

If the passed-in clasFilter is null or undefined the result of an invocation of getMemberClassesByFlag with argument true will be returned.

null will be returned if:

Parameters

classFilterthe filter that filters unwanted member classes out

Return

an array containing the remaining member classes of the represented package

getMemberPackages

public function getMemberPackages():Array

getMemberPackagesByFlag

public function getMemberPackagesByFlag(filterSubPackages:Boolean):Array

Returns an array containing PackageInfo instances representing the member packages of the package and maybe the ones of the sub-packages.

If filterSubPackages is null or undefined it is interpreted as true, this means sub-packages' packages are filtered by default.

null will be returned if:

Parameters

filterSubPackages(optional) determines whether the sub-packages' member packages shall be filtered/excluded from or included in the result

Return

an array containing the member packages of the represented package

getMemberPackagesByFilter

public function getMemberPackagesByFilter(packageFilter:PackageMemberFilter):Array

Returns an array containing PackageInfo instances representing the package members of the package and sub-packages that are not filtered/excluded.

The PackageMemberFilter.filter method of the passed-in packageFilter is invoked for every member package to determine whether it shall be contained in the result.

If the passed-in packageFilter is null or undefined the result of the invocation of getMemberPackagesByFlag with argument true will be returned.

null will be returned if:

Parameters

packageFilterthe filter that filters unwanted member packages out

Return

an array containing the remaining member packages of the represented package

getMember

public function getMember():PackageMemberInfo

getMemberByName

public function getMemberByName(memberName:String):PackageMemberInfo

Returns the package member info corresponding to the passed-in memberName.

If the package member with the passed-in memberName cannot be found directly in the represented package its sub-packages are searched through.

null will be returned if:

  • The getMembers method returns null or undefined.
  • The passed-in memberName is null or undefined.
  • There is no member with the passed-in memberName.

Parameters

memberNamethe name of the member to return

Return

the member corresponding to the passed-in memberName

getMemberByMember

public function getMemberByMember(concreteMember):PackageMemberInfo

Returns the package member info corresponding to the passed-in concreteMember.

If the package member corresponding to the passed-in concreteMember cannot be found directly in the represented package its sub-packages are searched through.

null will be returned if:

  • The getMembers method returns null or undefined.
  • The passed-in concreteMember is null or undefined.
  • The member could not be found.

Parameters

concreteMemberthe concrete member to find

Return

the package member info instance corresponding to the concreteMember

getMemberClass

public function getMemberClass(clazz):ClassInfo

getMemberClassByName

public function getMemberClassByName(className:String):ClassInfo

Returns the class info corresponding to the passed-in className.

If the member class with the passed-in className cannot be found directly in the represented package its sub-packages are searched through.

null will be returned if:

  • The passed-in className is null or undefined.
  • There is no class with the passed-in className.

Parameters

classNamethe name of the class

Return

the class info corresponding to the passed-in className

getMemberClassByClass

public function getMemberClassByClass(concreteClass:Function):ClassInfo

Returns the class info corresponding to the passed-in concreteClass.

If the member class corresponding to the passed-in concreteClass cannot be found directly in the represented package its sub-packages are searched through.

null will be returned if:

  • The passed-in concreteClass is null or undefined.
  • There is no class matching the passed-in concreteClass in this package or any sub-packages.

Parameters

concreteClassthe concrete class a corresponding class info shall be returned

Return

the class info corresponding to the passed-in concreteClass

getMemberPackage

public function getMemberPackage(package):PackageInfo

getMemberPackageByName

public function getMemberPackageByName(packageName:String):PackageInfo

Returns the package info corresponding to the passed-in packageName.

If the member package with the passed-in packageName cannot be found directly in the represented package its sub-packages are searched through.

null will be returned if:

  • The passed-in packageName is null or undefined.
  • The getMemberPackages method returns null.
  • There is no package with the given packageName.

Parameters

packageNamethe name of the package

Return

the package info corresponding to the passed-in packageName

getMemberPackageByPackage

public function getMemberPackageByPackage(concretePackage):PackageInfo

Returns the package info corresponding to the passed-in concretePackage.

If the member package corresponding to the passed-in concretePackage cannot be found directly in the represented package its sub-packages are searched through.

null will be returned if:

  • The passed-in concretePackage is null or undefined.
  • The getMemberPackages method returns null.
  • A package matching the passed-in concretePackage could not be found.

Parameters

concretePackagethe concrete package the corresponding package info shall be returned for

Return

the package info corresponding to the passed-in concretePackage

isRoot

public function isRoot(Void):Boolean

Returns whether this package is a root package.

It is supposed to be a root package when its parent is null.

Return

true if this package info represents a root package else false

isParentPackage

public function isParentPackage(package:PackageInfo):Boolean

Returns true if this package is the parent package of the passed-in package.

false will be returned if:

  • The passed-in package is not a parent package of this package.
  • The passed-in package is null or undefined.
  • The passed-in package equals this package.
  • The passed-in package's isRoot method returns true.

Parameters

packagepackage this package may be a parent of

Return

true if this package is the parent of the passed-in package

toString

public function toString():String

Returns the string representation of this instance.

The string representation is constructed as follows:

   [reflection fullyQualifiedNameOfReflectedPackage]
 

Parameters

Return

this instance's string representation

Specified By

toString() in org.as2lib.core.BasicInterface

Overrides

toString() in org.as2lib.core.BasicClass