Package freemarker.ext.beans
Class SimpleMethodModel
- java.lang.Object
-
- freemarker.ext.beans.SimpleMethodModel
-
- All Implemented Interfaces:
freemarker.core._UnexpectedTypeErrorExplainerTemplateModel,TemplateMethodModel,TemplateMethodModelEx,TemplateModel,TemplateSequenceModel
public final class SimpleMethodModel extends java.lang.Object implements TemplateMethodModelEx, TemplateSequenceModel, freemarker.core._UnexpectedTypeErrorExplainerTemplateModel
A class that will wrap a reflected method call into aTemplateMethodModelinterface. It is used byBeanModelto wrap reflected method calls for non-overloaded methods.
-
-
Field Summary
-
Fields inherited from interface freemarker.template.TemplateModel
NOTHING
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Objectexec(java.util.List arguments)Invokes the method, passing it the arguments from the list.java.lang.Object[]explainTypeError(java.lang.Class[] expectedClasses)Implementation of experimental interface; don't use it, no backward compatibility guarantee!TemplateModelget(int index)Retrieves the i-th template model in this sequence.protected java.lang.reflect.MembergetMember()intsize()java.lang.StringtoString()
-
-
-
Method Detail
-
exec
public java.lang.Object exec(java.util.List arguments) throws TemplateModelExceptionInvokes the method, passing it the arguments from the list.- Specified by:
execin interfaceTemplateMethodModel- Specified by:
execin interfaceTemplateMethodModelEx- Parameters:
arguments- aListofTemplateModel-s, containing the arguments passed to the method. If the implementation absolutely wants to operate on POJOs, it can use the static utility methods in theDeepUnwrapclass to easily obtain them. However, unwrapping is not always possible (or not perfectly), and isn't always efficient, so it's recommended to use the originalTemplateModelvalue as much as possible.- Returns:
- the return value of the method, or
null. If the returned value does not implementTemplateModel, it will be automatically wrapped using theenvironment's object wrapper. - Throws:
TemplateModelException
-
get
public TemplateModel get(int index) throws TemplateModelException
Description copied from interface:TemplateSequenceModelRetrieves the i-th template model in this sequence.- Specified by:
getin interfaceTemplateSequenceModel- Returns:
- the item at the specified index, or
nullif the index is out of bounds. Note that anullvalue 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, unless the default value for that case was also specified in the template. - Throws:
TemplateModelException
-
size
public int size() throws TemplateModelException- Specified by:
sizein interfaceTemplateSequenceModel- Returns:
- the number of items in the list.
- Throws:
TemplateModelException
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
explainTypeError
public java.lang.Object[] explainTypeError(java.lang.Class[] expectedClasses)
Implementation of experimental interface; don't use it, no backward compatibility guarantee!- Specified by:
explainTypeErrorin interfacefreemarker.core._UnexpectedTypeErrorExplainerTemplateModel
-
getMember
protected java.lang.reflect.Member getMember()
-
-