1 package freemarker.template; 2 3 /** 4 * Supplemental interface that can be implemented by classes that also implement 5 * any of the {@link TemplateModel} interfaces. A class implementing this 6 * interface usually serves as an adapter that provides bridging between a 7 * different object model and FreeMarker template models. It provides a 8 * capability to retrieve the underlying object. This interface is rarely 9 * implemented by applications. It is tipically implemented by adapter classes 10 * used for wrapping in various object wrapper implementation. 11 * @author Attila Szegedi 12 * @version $Id: AdapterTemplateModel.java,v 1.1 2005/06/12 19:03:07 szegedia Exp $ 13 */ 14 public interface AdapterTemplateModel extends TemplateModel { 15 /** 16 * Retrieves the underlying object, or some other object semantically 17 * equivalent to its value narrowed by the class hint. 18 * @param hint the desired class of the returned value. An implementation 19 * should make reasonable effort to retrieve an object of the requested 20 * class, but if that is impossible, it must at least return the underlying 21 * object as-is. As a minimal requirement, an implementation must always 22 * return the exact underlying object when 23 * <tt>hint.isInstance(underlyingObject) == true</tt> holds. When called 24 * with <tt>java.lang.Object.class</tt>, it should return a generic Java 25 * object (i.e. if the model is wrapping a scripting lanugage object that is 26 * further wrapping a Java object, the deepest underlying Java object should 27 * be returned). 28 * @return the underlying object, or its value accommodated for the hint 29 * class. 30 */ 31 public Object getAdaptedObject(Class hint); 32 } 33