public TemplateCollectionModel values() throws TemplateModelException { return (TemplateCollectionModel) wrapper.getOuterIdentity().wrap(map.values()); }
public TemplateCollectionModel keys() throws TemplateModelException { return (TemplateCollectionModel) wrapper.getOuterIdentity().wrap(map.keySet()); }
protected TemplateModel wrap(Object obj) throws TemplateModelException { return wrapper.getOuterIdentity().wrap(obj); }
/** * Invokes the specified method, wrapping the return value. The specialty * of this method is that if the return value is null, and the return type * of the invoked method is void, {@link TemplateModel#NOTHING} is returned. * @param object the object to invoke the method on * @param method the method to invoke * @param args the arguments to the method * @return the wrapped return value of the method. * @throws InvocationTargetException if the invoked method threw an exception * @throws IllegalAccessException if the method can't be invoked due to an * access restriction. * @throws TemplateModelException if the return value couldn't be wrapped * (this can happen if the wrapper has an outer identity or is subclassed, * and the outer identity or the subclass throws an exception. Plain * BeansWrapper never throws TemplateModelException). */ TemplateModel invokeMethod(Object object, Method method, Object[] args) throws InvocationTargetException, IllegalAccessException, TemplateModelException { // [2.4]: Java's Method.invoke truncates numbers if the target type has not enough bits to hold the value. // There should at least be an option to check this. Object retval = method.invoke(object, args); return method.getReturnType() == void.class ? TemplateModel.NOTHING : getOuterIdentity().wrap(retval); }
/** * Returns the field or method named by the <tt>key</tt> * parameter. */ public TemplateModel get(String key) throws TemplateModelException { Object model = map.get(key); // Simple method, overloaded method or final field -- these have cached // template models if (model instanceof TemplateModel) return (TemplateModel) model; // Non-final field; this must be evaluated on each call. if (model instanceof Field) { try { return wrapper.getOuterIdentity().wrap(((Field) model).get(null)); } catch (IllegalAccessException e) { throw new TemplateModelException( "Illegal access for field " + key + " of class " + clazz.getName()); } } throw new TemplateModelException( "No such key: " + key + " in class " + clazz.getName()); }
map.put(field.getName(), wrapper.getOuterIdentity().wrap(field.get(null))); } catch (IllegalAccessException e) {
public TemplateCollectionModel values() throws TemplateModelException { return (TemplateCollectionModel)wrapper.getOuterIdentity().wrap(map.values()); }
protected TemplateModel wrap(Object obj) throws TemplateModelException { return wrapper.getOuterIdentity().wrap(obj); }
public TemplateCollectionModel keys() throws TemplateModelException { return (TemplateCollectionModel)wrapper.getOuterIdentity().wrap(map.keySet()); }
protected TemplateModel wrap(Object obj) throws TemplateModelException { return wrapper.getOuterIdentity().wrap(obj); }
protected TemplateModel wrap(Object obj) throws TemplateModelException { return wrapper.getOuterIdentity().wrap(obj); }
public TemplateCollectionModel keys() throws TemplateModelException { return (TemplateCollectionModel) wrapper.getOuterIdentity().wrap(map.keySet()); }
public TemplateCollectionModel keys() throws TemplateModelException { return (TemplateCollectionModel) wrapper.getOuterIdentity().wrap(map.keySet()); }
public TemplateCollectionModel values() throws TemplateModelException { return (TemplateCollectionModel) wrapper.getOuterIdentity().wrap(map.values()); }
public TemplateCollectionModel values() throws TemplateModelException { return (TemplateCollectionModel) wrapper.getOuterIdentity().wrap(map.values()); }
/** * Invokes the specified method, wrapping the return value. The specialty * of this method is that if the return value is null, and the return type * of the invoked method is void, {@link TemplateModel#NOTHING} is returned. * @param object the object to invoke the method on * @param method the method to invoke * @param args the arguments to the method * @return the wrapped return value of the method. * @throws InvocationTargetException if the invoked method threw an exception * @throws IllegalAccessException if the method can't be invoked due to an * access restriction. * @throws TemplateModelException if the return value couldn't be wrapped * (this can happen if the wrapper has an outer identity or is subclassed, * and the outer identity or the subclass throws an exception. Plain * BeansWrapper never throws TemplateModelException). */ TemplateModel invokeMethod(Object object, Method method, Object[] args) throws InvocationTargetException, IllegalAccessException, TemplateModelException { // [2.4]: Java's Method.invoke truncates numbers if the target type has not enough bits to hold the value. // There should at least be an option to check this. Object retval = method.invoke(object, args); return method.getReturnType() == void.class ? TemplateModel.NOTHING : getOuterIdentity().wrap(retval); }
/** * Invokes the specified method, wrapping the return value. The specialty * of this method is that if the return value is null, and the return type * of the invoked method is void, {@link TemplateModel#NOTHING} is returned. * @param object the object to invoke the method on * @param method the method to invoke * @param args the arguments to the method * @return the wrapped return value of the method. * @throws InvocationTargetException if the invoked method threw an exception * @throws IllegalAccessException if the method can't be invoked due to an * access restriction. * @throws TemplateModelException if the return value couldn't be wrapped * (this can happen if the wrapper has an outer identity or is subclassed, * and the outer identity or the subclass throws an exception. Plain * BeansWrapper never throws TemplateModelException). */ TemplateModel invokeMethod(Object object, Method method, Object[] args) throws InvocationTargetException, IllegalAccessException, TemplateModelException { // [2.4]: Java's Method.invoke truncates numbers if the target type has not enough bits to hold the value. // There should at least be an option to check this. Object retval = method.invoke(object, args); return method.getReturnType() == void.class ? TemplateModel.NOTHING : getOuterIdentity().wrap(retval); }
/** * Returns the field or method named by the <tt>key</tt> * parameter. */ public TemplateModel get(String key) throws TemplateModelException { Object model = map.get(key); // Simple method, overloaded method or final field -- these have cached // template models if (model instanceof TemplateModel) return (TemplateModel) model; // Non-final field; this must be evaluated on each call. if (model instanceof Field) { try { return wrapper.getOuterIdentity().wrap(((Field) model).get(null)); } catch (IllegalAccessException e) { throw new TemplateModelException( "Illegal access for field " + key + " of class " + clazz.getName()); } } throw new TemplateModelException( "No such key: " + key + " in class " + clazz.getName()); }
/** * Returns the field or method named by the <tt>key</tt> * parameter. */ public TemplateModel get(String key) throws TemplateModelException { Object model = map.get(key); // Simple method, overloaded method or final field -- these have cached // template models if (model instanceof TemplateModel) return (TemplateModel) model; // Non-final field; this must be evaluated on each call. if (model instanceof Field) { try { return wrapper.getOuterIdentity().wrap(((Field) model).get(null)); } catch (IllegalAccessException e) { throw new TemplateModelException( "Illegal access for field " + key + " of class " + clazz.getName()); } } throw new TemplateModelException( "No such key: " + key + " in class " + clazz.getName()); }
/** * Returns the field or method named by the <tt>key</tt> * parameter. */ public TemplateModel get(String key) throws TemplateModelException { Object model = map.get(key); // Simple method, overloaded method or final field -- these have cached // template models if (model instanceof TemplateModel) return (TemplateModel) model; // Non-final field; this must be evaluated on each call. if (model instanceof Field) { try { return wrapper.getOuterIdentity().wrap(((Field) model).get(null)); } catch (IllegalAccessException e) { throw new TemplateModelException( "Illegal access for field " + key + " of class " + clazz.getName()); } } throw new TemplateModelException( "No such key: " + key + " in class " + clazz.getName()); }