01: /*
02: HttpdBase4J: An embeddable Java web server framework that supports HTTP, HTTPS,
03: templated content and serving content from inside a jar or archive.
04: Copyright (C) 2007 Donald Munro
05:
06: This library is free software; you can redistribute it and/or
07: modify it under the terms of the GNU Lesser General Public
08: License as published by the Free Software Foundation; either
09: version 2.1 of the License, or (at your option) any later version.
10:
11: This library is distributed in the hope that it will be useful,
12: but WITHOUT ANY WARRANTY; without even the implied warranty of
13: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14: Lesser General Public License for more details.
15:
16: You should have received a copy of the GNU Lesser General Public
17: License along with this library; if not,see http://www.gnu.org/licenses/lgpl.txt
18: */
19:
20: package net.homeip.donaldm.httpdbase4j;
21:
22: import java.io.File;
23: import java.io.InputStream;
24: import org.antlr.stringtemplate.StringTemplate;
25:
26: /**
27: * An interface that must be implemented by template populating class
28: * used by StringTemplateHandler.
29: * @see StringTemplateHandler
30: * @author Donald Munro
31: */
32: public interface Templatable
33: //==========================
34: {
35: /**
36: * Called by the StringTemplateHandler to populate a file based template.
37: * @param template The StringTemplate instance
38: * @param request The Request instance.
39: * @param mimeType Return the mime type of the generated content in this.
40: * parameter. NOTE: Can be null so check to avoid Exceptions
41: * @param dir Directory in which to create return file. Can be null
42: * @return A temporary file of the contents of the template output or null.
43: */
44: public File templateFile(StringTemplate template, Request request,
45: StringBuffer mimeType, File dir);
46:
47: /**
48: * Called by the StringTemplateHandler to populate a string based template.
49: * @param template The StringTemplate instance
50: * @param request The Request instance.
51: * @param mimeType Return the mime type of the generated content in this.
52: * parameter. NOTE: Can be null so check to avoid Exceptions
53: * @return A temporary file of the contents of the template output or null.
54: */
55: public String templateString(StringTemplate template,
56: Request request, StringBuffer mimeType);
57:
58: /**
59: * Called by the StringTemplateHandler to populate a stream based template.
60: * @param template The StringTemplate instance
61: * @param request The Request instance.
62: * @param mimeType Return the mime type of the generated content in this.
63: * parameter. NOTE: Can be null so check to avoid Exceptions
64: * @return A temporary file of the contents of the template output or null.
65: */
66: public InputStream templateStream(StringTemplate template,
67: Request request, StringBuffer mimeType);
68: }
|