Access keys

PackageInfo

Kind of class: class
Inherits from: BasicClass
Implements:
Author: Simon Wacker
Classpath: org.as2lib.env.reflect.PackageInfo
File last modified: Wednesday, 17 August 2005, 11:52:16
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());

Constructor

PackageInfo

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:
package:
the actual package this instance represents
name :
(optional) the name of the package
parent :
(optional) the parent package

Class methods

forName

static 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:
packageName:
the fully qualified name of the package to find
Returns:
the package info corresponding to the passed-in packageName
Throws:
org.as2lib.env.except.IllegalArgumentException if 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"
PackageNotFoundException if a package with the passed-in packageName
could not be found

forPackage

static 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:
package:
the package you wanna get the package info for
Returns:
the package info corresponding to the passed-in package
Throws:
org.as2lib.env.except.IllegalArgumentException if the passed-in package is null
or undefined

getPackageAlgorithm

static function getPackageAlgorithm (
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 org.as2lib.env.reflect.algorithm.PackageAlgorithm.

Returns:
the set or the default package algorithm

getPackageMemberAlgorithm

static function getPackageMemberAlgorithm (
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 org.as2lib.env.reflect.algorithm.PackageMemberAlgorithm.

Returns:
the set or the default member algorithm

getRootPackage

static function getRootPackage (
Void) : PackageInfo
Returns the root package of the package hierarchy.

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

Returns:
the root package of the package hierarchy.
See also:

setPackageAlgorithm

static 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:
newPackageAlgorithm:
the new algorithm to find packages

setPackageMemberAlgorithm

static 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:
newPackageMemberAlgorithm:
the new algorithm to find members of packages

setRootPackage

static 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 #getRootPackage method will return the default
root package.

Parameters:
newRootPackage:
the new root package of the package hierarchy
See also:

Instance methods

getFullName

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.
Returns:
the fully qualified name of the package

getMemberByMember

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:
concreteMember:
the concrete member to find
Returns:
the package member info instance corresponding to the concreteMember

getMemberByName

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:
memberName:
the name of the member to return
Returns:
the member corresponding to the passed-in memberName

getMemberClassByClass

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:
concreteClass:
the concrete class a corresponding class info shall be
returned
Returns:
the class info corresponding to the passed-in concreteClass

getMemberClassByName

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:
className:
the name of the class
Returns:
the class info corresponding to the passed-in className

getMemberClassesByFilter

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:
classFilter:
the filter that filters unwanted member classes out
Returns:
an array containing the remaining member classes of the represented
package

getMemberClassesByFlag

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
Returns:
an array containing the member classes of the represented package

getMemberPackageByName

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:
packageName:
the name of the package
Returns:
the package info corresponding to the passed-in packageName

getMemberPackageByPackage

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:
concretePackage:
the concrete package the corresponding package info shall
be returned for
Returns:
the package info corresponding to the passed-in concretePackage

getMemberPackagesByFilter

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:
packageFilter:
the filter that filters unwanted member packages out
Returns:
an array containing the remaining member packages of the represented
package

getMemberPackagesByFlag

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
Returns:
an array containing the member packages of the represented package

getMembersByFilter

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:
packageMemberFilter:
the filter that filters unwanted package members out
Returns:
an array containing the remaining members of the represented package

getMembersByFlag

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
Returns:
an array containing the members of the represented package

getName

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".

Returns:
the name of the represented package
See also:
Specified by:

getPackage

function getPackage (
Void)
Returns the actual package this instance represents.
Returns:
the actual package

getParent

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.

Returns:
the parent of the represented package

isParentPackage

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:
package:
package this package may be a parent of
Returns:
true if this package is the parent of the passed-in package

isRoot

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.

Returns:
true if this package info represents a root package else false

toString

function toString (
) : String
Returns the string representation of this instance.

The string representation is constructed as follows:

[reflection fullyQualifiedNameOfReflectedPackage]
Parameters:
displayContent:
(optional) a Boolean that determines whether to
render this package's content recursively true or not false
Returns:
this instance's string representation