freemarker.ext.beans
Class MethodModel

java.lang.Object
  |
  +--freemarker.ext.beans.MethodModel
All Implemented Interfaces:
TemplateMethodModel2, TemplateModel

public final class MethodModel
extends java.lang.Object
implements TemplateMethodModel2

A class that will wrap a reflected method call into a TemplateMethodModel2 interface. It can be used directly, and is heavily used by ObjectModel to wrap reflected method calls.

Version:
$Id: MethodModel.java,v 1.5 2003/10/20 13:49:02 run2000 Exp $
Author:
Attila Szegedi, attila@szegedi.org

Constructor Summary
MethodModel(java.lang.Object object, java.lang.reflect.Method method)
          Creates a model for a specific method on a specific object.
 
Method Summary
 TemplateModel exec(java.util.List arguments)
          Invokes the method, passing it the arguments from the list.
 boolean isEmpty()
          Returns true if the wrapped method's return type is void.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MethodModel

public MethodModel(java.lang.Object object,
                   java.lang.reflect.Method method)
Creates a model for a specific method on a specific object.
Parameters:
object - the object to call the method on. Can be null for static methods.
method - the method that will be invoked.
Method Detail

exec

public TemplateModel exec(java.util.List arguments)
                   throws TemplateModelException
Invokes the method, passing it the arguments from the list. Since in the current release of FM-Classic (1.8), all elements of the argument list can now be of any type, including possibly wrapped objects, go through the unwrap process before calling the method.
Specified by:
exec in interface TemplateMethodModel2
Following copied from interface: freemarker.template.TemplateMethodModel2
Parameters:
arguments - a List of TemplateModel objects containing the values of the arguments passed to the method.
Returns:
the TemplateModel produced by the method, or null.

isEmpty

public boolean isEmpty()
Returns true if the wrapped method's return type is void.
Specified by:
isEmpty in interface TemplateModel
Following copied from interface: freemarker.template.TemplateModel
Returns:
true if this object is empty, otherwise false