public Object exec(List arguments) throws TemplateModelException { return simpleMethodModel.exec(arguments); }
/** * Wraps a Java method so that it can be called from templates, without wrapping its parent ("this") object. The * result is almost the same as that you would get by wrapping the parent object then getting the method from the * resulting {@link TemplateHashModel} by name. Except, if the wrapped method is overloaded, with this method you * explicitly select an overload, while otherwise you would get a {@link TemplateMethodModelEx} that selects an * overload each time it's called based on the argument values. * * @param object The object whose method will be called, or {@code null} if {@code method} is a static method. * This object will be used "as is", like without unwrapping it if it's a {@link TemplateModelAdapter}. * @param method The method to call, which must be an (inherited) member of the class of {@code object}, as * described by {@link Method#invoke(Object, Object...)} * * @since 2.3.22 */ public TemplateMethodModelEx wrap(Object object, Method method) { return new SimpleMethodModel(object, method, method.getParameterTypes(), this); }
/** * Invokes the method, passing it the arguments from the list. */ public Object exec(List arguments) throws TemplateModelException { try { return wrapper.invokeMethod(object, (Method) getMember(), unwrapArguments(arguments, wrapper)); } catch (TemplateModelException e) { throw e; } catch (Exception e) { throw _MethodUtil.newInvocationTemplateModelException(object, getMember(), e); } }
@Override public String toString() { return getMember().toString(); }
public Object[] explainTypeError(Class[] expectedClasses) { return simpleMethodModel.explainTypeError(expectedClasses); }
public int size() throws TemplateModelException { return simpleMethodModel.size(); }
public TemplateModel get(int index) throws TemplateModelException { return simpleMethodModel.get(index); }
final Member member = getMember(); if (!(member instanceof Method)) { return null; // This shouldn't occur
public Object[] explainTypeError(Class[] expectedClasses) { return simpleMethodModel.explainTypeError(expectedClasses); }
public int size() throws TemplateModelException { return simpleMethodModel.size(); }
public TemplateModel get(int index) throws TemplateModelException { return simpleMethodModel.get(index); }
public Object exec(List arguments) throws TemplateModelException { return simpleMethodModel.exec(arguments); }
/** * Invokes the method, passing it the arguments from the list. */ public Object exec(List arguments) throws TemplateModelException { try { return wrapper.invokeMethod(object, (Method) getMember(), unwrapArguments(arguments, wrapper)); } catch (TemplateModelException e) { throw e; } catch (Exception e) { throw _MethodUtil.newInvocationTemplateModelException(object, getMember(), e); } }
if (value instanceof Method) { Method method = (Method) value; entry.setValue(new SimpleMethodModel(null, method, method.getParameterTypes(), wrapper)); } else if (value instanceof OverloadedMethods) {
public int size() throws TemplateModelException { throw new _TemplateModelException( new _ErrorDescriptionBuilder( "Getting the number of items or listing the items is not supported on this ", new _DelayedFTLTypeDescription(this), " value, because this value wraps the following Java method, " + "not a real listable value: ", new _DelayedToString(getMember())) .tips( "Maybe you should to call this method first and then do something with its return value.", "obj.someMethod(i) and obj.someMethod[i] does the same for this method, hence it's a " + "\"+sequence\".")); }
public Object[] explainTypeError(Class[] expectedClasses) { return simpleMethodModel.explainTypeError(expectedClasses); }
public int size() throws TemplateModelException { return simpleMethodModel.size(); }
public TemplateModel get(int index) throws TemplateModelException { return simpleMethodModel.get(index); }
public TemplateModel get(int index) throws TemplateModelException { return (TemplateModel) exec(Collections.singletonList( new SimpleNumber(Integer.valueOf(index)))); }
/** * Invokes the method, passing it the arguments from the list. */ public Object exec(List arguments) throws TemplateModelException { try { return wrapper.invokeMethod(object, (Method) getMember(), unwrapArguments(arguments, wrapper)); } catch (TemplateModelException e) { throw e; } catch (Exception e) { throw _MethodUtil.newInvocationTemplateModelException(object, getMember(), e); } }