Access keys

PackageAlgorithm

Kind of class: class
Inherits from: BasicClass
Author: Simon Wacker
Classpath: org.as2lib.env.reflect.algorithm.PackageAlgorithm
File last modified: Tuesday, 16 August 2005, 18:09:58
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);

Summary

Constructor
Instance methods
Instance methods inherited from BasicClass

Constructor

PackageAlgorithm

function PackageAlgorithm (
Void)
Constructs a new PackageAlgorithm instance.

Instance methods

execute

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 {@ling PackageInfo} 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:
o:
the package to return information about
Returns:
an object that contains information about the passed-in package

executeByName

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

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
package to find is already stored and where to start the search if not.
Parameters:
cache:
the new cache