Interface org.as2lib.env.overload.OverloadHandler

org.as2lib.core.BasicInterface
   +--org.as2lib.env.overload.OverloadHandler

Description

OverloadHandler declares methods needed by overload handlers.

Overload handlers are used by the Overload class to identify the corresponding method for a specific list of arguments. Whereby the overload handler holds the method and the expected arguments' types of this method.

It also offers functionalities to match real arguments against the expected arguments' types, matches, and to determine which overload handler or rather which arguments' types of two handlers are more explicit, isMoreExplicit.

It also offers the ability to invoke/execute the target method on a target scope passing-in a list of arguments.

Method Index

execute(), getArgumentsTypes(), getMethod(), isMoreExplicit(), matches()

Inherited from BasicInterface

toString()

Method Detail

matches

public function matches(realArguments:Array):Boolean

Checks whether the passed-in realArguments match the expected arguments' types of this overload handler.

Parameters

realArgumentsthe real arguments to match against the arguments' types

Return

true if the realArguments match the arguments' types else false

execute

public function execute(target, args:Array)

Executes the method of this handler on the given target passing-in the given args.

The this scope of the method refers to the passed-in target on execution.

Parameters

targetthe target object to invoke the method on
argsthe arguments to pass-in on method invocation

Return

the result of the method invocation

isMoreExplicit

public function isMoreExplicit(handler:OverloadHandler):Boolean

Checks if this overload handler is more explicit than the passed-in handler.

What means more explicit? The type String is for example more explicit than Object. The type org.as2lib.core.BasicClass is also more explicit than Object. And the type org.as2lib.env.overload.SimpleOverloadHandler is more explicit than org.as2lib.core.BasicClass. I hope you get the image. As you can see, the explicitness depends on the inheritance hierarchy.

Note that classes are supposed to be more explicit than interfaces.

Parameters

handlerthe handler to compare this handler with regarding explicitness

Return

true if this handler is more explicit else false or null if the two handlers have the same explicitness

getArgumentsTypes

public function getArgumentsTypes(Void):Array

Returns the arguments' types used to match against the real arguments.

The arguments' types determine for which types of arguments the method was declared for. That means which arguments' types the method expects.

Return

the arguments' types the method expects

getMethod

public function getMethod(Void):Function

Returns the method this overload handler was assigned to.

This is the method to invoke passing the appropriate arguments when this handler matches the arguments and is the most explicit one.

Return

the method to invoke when the real arguments match the ones of this handler and this handler is the most explicit one