01: /*
02: * Copyright 2004-2007 the original author or authors.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: *
16: */
17:
18: package org.jpublish.view;
19:
20: import java.io.Reader;
21: import java.io.Writer;
22: import java.io.IOException;
23: import java.io.InputStream;
24: import java.io.OutputStream;
25:
26: import com.anthonyeden.lib.config.Configuration;
27: import com.anthonyeden.lib.config.ConfigurationException;
28:
29: import org.jpublish.SiteContext;
30: import org.jpublish.JPublishContext;
31:
32: /** Standard interface for rendering views.
33:
34: @author Anthony Eden
35: @since 2.0
36: */
37:
38: public interface ViewRenderer {
39:
40: /** Set the SiteContext.
41:
42: @param siteContext The SiteContext
43: */
44:
45: public void setSiteContext(SiteContext siteContext);
46:
47: /** Initialize the ViewRenderer.
48:
49: @throws Exception Any Exception
50: */
51:
52: public void init() throws Exception;
53:
54: /** Render the view.
55:
56: @param context The JPublishContext
57: @param path The path to the template
58: @param in The Reader to read view template from
59: @param out The Writer to write the rendered view
60: @throws IOException
61: @throws ViewRenderException
62: */
63:
64: public void render(JPublishContext context, String path, Reader in,
65: Writer out) throws IOException, ViewRenderException;
66:
67: /** Render the view.
68:
69: @param context The JPublishContext
70: @param path The path to the template
71: @param in The InputStream to read view template from
72: @param out The OutputStream to write the rendered view
73: @throws IOException
74: @throws ViewRenderException
75: */
76:
77: public void render(JPublishContext context, String path,
78: InputStream in, OutputStream out) throws IOException,
79: ViewRenderException;
80:
81: /** Load the configuration for the view.
82:
83: @param configuration The configuration object
84: */
85:
86: public void loadConfiguration(Configuration configuration)
87: throws ConfigurationException;
88:
89: }
|