freemarker.ext.beans
Class SimpleMethodModel
java.lang.Object
freemarker.ext.beans.SimpleMethodModel
- All Implemented Interfaces:
- TemplateMethodModel, TemplateMethodModelEx, TemplateModel, TemplateSequenceModel
public final class SimpleMethodModel
- extends java.lang.Object
- implements TemplateMethodModelEx, TemplateSequenceModel
A class that will wrap a reflected method call into a
TemplateMethodModel
interface.
It is used by BeanModel
to wrap reflected method calls
for non-overloaded methods.
- Version:
- $Id: SimpleMethodModel.java,v 1.27 2005/06/11 12:12:04 szegedia Exp $
- Author:
- Attila Szegedi, szegedia at users dot sourceforge dot net
Method Summary |
java.lang.Object |
exec(java.util.List arguments)
Invokes the method, passing it the arguments from the list. |
TemplateModel |
get(int index)
Retrieves the i-th template model in this sequence. |
protected java.lang.reflect.Member |
getMember()
|
int |
size()
|
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
exec
public java.lang.Object exec(java.util.List arguments)
throws TemplateModelException
- Invokes the method, passing it the arguments from the list.
- Specified by:
exec
in interface TemplateMethodModel
- Specified by:
exec
in interface TemplateMethodModelEx
- Parameters:
arguments
- a List of TemplateModel
objects
containing the values of the arguments passed to the method. If the
implementation wishes to operate on POJOs that might be underlying the
models, it can use the static utility methods in the DeepUnwrap
class to easily obtain them.
- Returns:
- the return value of the method, or null. If the returned value
does not implement
TemplateModel
, it will be automatically
wrapped using the environment
object wrapper
.
- Throws:
TemplateModelException
get
public TemplateModel get(int index)
throws TemplateModelException
- Description copied from interface:
TemplateSequenceModel
- Retrieves the i-th template model in this sequence.
- Specified by:
get
in interface TemplateSequenceModel
- Returns:
- the item at the specified index, or
null
if
the index is out of bounds. Note that a null
value is
interpreted by FreeMarker as "variable does not exist", and accessing
a missing variables is usually considered as an error in the FreeMarker
Template Language, so the usage of a bad index will not remain hidden.
- Throws:
TemplateModelException
size
public int size()
throws TemplateModelException
- Specified by:
size
in interface TemplateSequenceModel
- Returns:
- the number of items in the list.
- Throws:
TemplateModelException
toString
public java.lang.String toString()
- Overrides:
toString
in class java.lang.Object
getMember
protected java.lang.reflect.Member getMember()