Class org.as2lib.env.reflect.algorithm.PackageMemberAlgorithm

org.as2lib.core.BasicClass
   +--org.as2lib.env.reflect.algorithm.PackageMemberAlgorithm

Description

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 PackageInfo.getMembers, PackageInfo.getMemberClasses and 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.

Method Index

new PackageMemberAlgorithm()

execute(), getCache(), setCache()

Inherited from BasicClass

toString()

Constructor Detail

PackageMemberAlgorithm

public function PackageMemberAlgorithm(Void)

Constructs a new PackageMemberAlgorithm instance.

Method Detail

setCache

public 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

cachethe new cache

getCache

public function getCache(Void):Cache

Returns the cache set via the setCache method or the default cache that is returned by the ReflectConfig.getCache method.

Return

the currently used cache

execute

public 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 PackageMemberInfo, that is either of type ClassInfo or 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

Return

the members of the package, an empty array or null