Access keys

PackageMemberAlgorithm

Kind of class: class
Inherits from: BasicClass
Author: Simon Wacker
Classpath: org.as2lib.env.reflect.algorithm.PackageMemberAlgorithm
File last modified: Monday, 23 May 2005, 11:23:54
PackageMemberAlgorithm searches for members, that means types and packages,
of a specific package.
Sub-packages are not searched through.

This class is mostly used internally. If you wanna obtain the members of a
package you need its representing PackageInfo. You can then also use the
org.as2lib.env.reflect.PackageInfo.getMembers, org.as2lib.env.reflect.PackageInfo.getMemberClasses and
org.as2lib.env.reflect.PackageInfo.getMemberPackages methods directly and do not have to make
the detour over this method. The PackageInfo's methods are also easier to use and
offer some extra functionalities.

If you nevertheless want to use this class here is how it works.

var packageInfo:PackageInfo = PackageInfo.forPackage(org.as2lib.core);
var packageMemberAlgorithm:PackageMemberAlgorithm = new PackageMemberAlgorithm();
var members:Array = packageMemberAlgorithm.execute(packageInfo);

Refer to the execute method for details on how to get data from the
members array appropriately.

Summary

Instance methods
Instance methods inherited from BasicClass

Constructor

PackageMemberAlgorithm

function PackageMemberAlgorithm (
Void)
Constructs a new PackageMemberAlgorithm instance.

Instance methods

execute

function execute (
p:PackageInfo) : Array
Executes the search for the members, that means member types and packages, in
the passed-in package p.

The resulting array contains instances of type org.as2lib.env.reflect.PackageMemberInfo, that
is either of type org.as2lib.env.reflect.ClassInfo or org.as2lib.env.reflect.PackageInfo.

The specific members can be either referenced by index or by name.


Reference member by index; can be class or package.

myMembers[0];

Reference class by index.

myMembers.classes[0];

Reference package by index.

myMembers.packages[0];

Reference member by index; can be class or package.

myMembers.MyClass; or myMembers.mypackage

Reference class by name; use only the name of the class, excluding the namespace.

myMembers.classes.MyClass;

Reference package by name; use only the package name, excluding the namespace.

myMembers.packages.mypackage;

null will be returned if:

  • The passed-in package p is null or undefined.
  • The getPackage method of the passed-in package returns null.

Only the passed-in package p will be searched through, no sub-packages.

In case the cache already contains a specific member class or package the
contained info it will be added to the resulting members array.

Parameters:
g:
the package info instance representing the package to search through
Returns:
the members of the package, an empty array or null

getCache

function getCache (
Void) : Cache
Returns the cache set via the setCache method or the default cache that
is returned by the org.as2lib.env.reflect.ReflectConfig.getCache method.
Returns:
the currently used cache

setCache

function setCache (
cache:Cache) : Void
Sets the cache that is used by the execute method to look whether the
member package or class is already stored and to get the root package to start the
search if not.
Parameters:
cache:
the new cache