Class org.as2lib.env.reflect.algorithm.PackageAlgorithm

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

Description

PackageAlgorithm searches for the specified package and returns the package info representing the found package.

To obtain the package info corresponding to package you use this class as follows. var packageAlgorithm:PackageAlgorithm = new PackageAlgorithm(); var packageInfoByPackage:PackageInfo = packageAlgorithm.execute(org.as2lib.core);

It is also possible to retrieve a package info by name. packageInfoByName:PackageInfo = packageAlgorithm.executeByName("org.as2lib.core");

Already retrieved package infos are stored in a cache. There thus exists only one PackageInfo instance per package. The following traces true. trace(packageInfoByPackage == packageInfoByName);

Method Index

new PackageAlgorithm()

execute(), executeByName(), getCache(), setCache()

Inherited from BasicClass

toString()

Constructor Detail

PackageAlgorithm

public function PackageAlgorithm(Void)

Constructs a new PackageAlgorithm instance.

Method Detail

setCache

public function setCache(cache:Cache):Void

Sets the cache that is used by the execute method to look whether the package to find is already stored and where 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(o)

Executes the search for the passed-in package o and returns information about this package.

The returned object has the following properties:

package
The package as Object that has been searched for, this is the passed-in package o.
name
The name as String of the searched for package.
parent
The parent represented by a instance the searched for package is a member of.

null will be returned if:

  • The passed-in package o is null or undefined.
  • The searched for package o could not be found.

The search starts on the package returned by the cache's getRoot method, this is by default _global.

Parameters

othe package to return information about

Return

an object that contains information about the passed-in package

executeByName

public function executeByName(n:String):PackageInfo

Returns the package info representing the package corresponding to the passed-in package name n.

The name must be fully qualified, that means it must consist of the package's path as well as its name. For example 'org.as2lib.core'.

The search starts on the package returned by the Cache.getRoot method of the set cache. If this method returns a package info whose getFullName method returns null, undefined or an empty string "_global" is used instead

Parameters

nthe fully qualified name of the package

Return

the package info representing the package corresponding to the passed-in name

Throws

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