Access keys

MethodInfo

Kind of class: class
Inherits from: BasicClass
Implements:
Known subclasses:
Author: Simon Wacker
Classpath: org.as2lib.env.reflect.MethodInfo
File last modified: Friday, 09 September 2005, 14:24:52
MethodInfo represents a method.

MethodInfo instances for specific methods can be obtained using the
ClassInfo.getMethods or ClassInfo.getMethod methods. That means
you first have to get a class info for the class that declares or inherits the
method. You can therefor use the ClassInfo.forObject, ClassInfo.forClass,
ClassInfo.forInstance and ClassInfo.forName methods.

When you have obtained the method info you can use it to get information about
the method.

trace("Method name: " + methodInfo.getName());
trace("Declaring type: " + methodInfo.getDeclaringType().getFullName());
trace("Is Static?: " + methodInfo.isStatic());

Summary

Constructor

Constructor

MethodInfo

function MethodInfo (
name:String, declaringType:TypeInfo, staticFlag:Boolean, method:Function)
Constructs a new MethodInfo instance.

All arguments are allowed to be null. But keep in mind that not all
methods will function properly if one is.

If method is not specified, it will be resolved at run-time everytime
it is needed. This means that the concrete method will always be up-to-date even
if you have overwritten it.

Parameters:
name :
the name of the method
declaringType:
the declaring type of the method
staticFlag :
determines whether the method is static
method :
(optional) the concrete method

Class methods

getStringifier

static function getStringifier (
Void) : Stringifier
Returns the stringifier used to stringify method infos.

If no custom stringifier has been set via the setStringifier method,
a instance of the default MethodInfoStringifier class is returned.

Returns:
the stringifier that stringifies method infos

setStringifier

static function setStringifier (
methodInfoStringifier:MethodInfoStringifier) : Void
Sets the stringifier used to stringify method infos.

If methodInfoStringifier is null or undefined
getStringifier will return the default stringifier.

Parameters:
methodInfoStringifier:
the stringifier that stringifies method infos

Instance methods

getDeclaringType

function getDeclaringType (
Void) : TypeInfo
Returns the type that declares this method.
Returns:
the type that declares this method

getFullName

function getFullName (
Void) : String
Returns the full name of this method.

The full name is the fully qualified name of the declaring type plus the name
of this method.

Returns:
the full name of this method

getMethod

function getMethod (
Void) : Function
Returns the concrete method this instance represents.

If the concrete method was not specified on construction it will be resolved
on run-time by this method everytime asked for. The returned method is thus
always the current method on the declaring type.

Returns:
the concrete method

getName

function getName (
Void) : String
Returns the name of this method.
Returns:
the name of this method
Specified by:

invoke

function invoke (
scope, args:Array)
Invokes this method on the passed-in scope passing the given args.

The object referenced by this in this method is the object this method
is invoked on, its / the passed-in scope.

Parameters:
scope:
the this-scope for the method invocation
args :
the arguments to pass-to the method on invocation
Returns:
the return value of the method invocation

isStatic

function isStatic (
Void) : Boolean
Returns whether this method is static or not.

Static methods are methods per type.

Non-Static methods are methods per instance.

Returns:
true if this method is static else false

snapshot

function snapshot (
Void) : MethodInfo
Returns a method info that reflects the current state of this method info.
Returns:
a snapshot of this method info

toString

function toString (
) : String
Returns the string representation of this method.

The string representation is obtained via the stringifier returned by the
static getStringifier method.

Returns:
the string representation of this method