1 /* 2 * $Id: TemplateSource.java,v 1.3 2004/12/01 07:54:28 hengels Exp $ 3 * Copyright 2000,2005 wingS development team. 4 * 5 * This file is part of wingS (http://www.j-wings.org). 6 * 7 * wingS is free software; you can redistribute it and/or modify 8 * it under the terms of the GNU Lesser General Public License 9 * as published by the Free Software Foundation; either version 2.1 10 * of the License, or (at your option) any later version. 11 * 12 * Please see COPYING for the complete licence. 13 */ 14 package org.wings.template; 15 16 import java.io.IOException; 17 import java.io.InputStream; 18 19 /** 20 * A TemplateSource for a Template. This encapsulates what is the notion 21 * of a template from the parsers point of view: some named entity, that 22 * might change over time and thus has a modification time; an input stream 23 * to access the contents. 24 * <p/> 25 * So <CODE>TemplateSource</CODE> is a general source where templates can come 26 * from. You can think of Files, URLs, Database-BLOBS .. 27 * 28 * @author <A HREF="mailto:H.Zeller@acm.org">Henner Zeller</A> 29 * @version $Revision: 1.3 $ $Date: 2004/12/01 07:54:28 $ 30 */ 31 public interface TemplateSource { 32 /** 33 * Returns a canonical name of this TemplateSource. 34 * <p/> 35 * The name returned here is used to look up the parsing 36 * result of the internal caching, so it should differ 37 * for all different Sources :-) 38 * May return <code>null</code> if this Source is supposed 39 * to be parsed each time. The canonical name would be something 40 * like a filename or an URL. 41 * 42 * @return the canonical name of the source. like 'file:/web/template.html' 43 */ 44 String getCanonicalName(); 45 46 /** 47 * Returns the time the content of this TemplateSource 48 * was last modified. 49 * <p/> 50 * The return value is used to decide whether to reparse a 51 * Source or not. Reparsing is done if the value returned 52 * here <em>differs</em> from the value returned at the last processing 53 * time. This may not return a 'real' time, it needs just 54 * to be comparable to itself; so some sort of version counter instead 55 * of time would be perfect as well. 56 * 57 * @return long a modification time 58 */ 59 long lastModified(); 60 61 /** 62 * Gets an InputStream of this TemplateSource. 63 * <p/> 64 * <em>Note</em> 65 * that this method may be called twice if the page has to 66 * be parsed first. So you probably have to implement a 67 * buffer if your underlying source is transient .. 68 * 69 * @return an InputStream the content of the template is read from. 70 */ 71 InputStream getInputStream() throws IOException; 72 } 73 74 75 76 77