001: /*
002: * Copyright 2004-2007 the original author or authors.
003: *
004: * Licensed under the Apache License, Version 2.0 (the "License");
005: * you may not use this file except in compliance with the License.
006: * You may obtain a copy of the License at
007: *
008: * http://www.apache.org/licenses/LICENSE-2.0
009: *
010: * Unless required by applicable law or agreed to in writing, software
011: * distributed under the License is distributed on an "AS IS" BASIS,
012: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013: * See the License for the specific language governing permissions and
014: * limitations under the License.
015: *
016: */
017:
018: package org.jpublish.view.raw;
019:
020: import java.io.Reader;
021: import java.io.Writer;
022: import java.io.IOException;
023: import java.io.InputStream;
024: import java.io.OutputStream;
025:
026: import com.anthonyeden.lib.config.Configuration;
027: import com.anthonyeden.lib.config.ConfigurationException;
028:
029: import org.jpublish.SiteContext;
030: import org.jpublish.JPublishContext;
031: import org.jpublish.view.ViewRenderer;
032: import org.jpublish.view.ViewRenderException;
033:
034: /** ViewRenderer which renders the data directly to the output stream with
035: no template engine.
036:
037: @author Anthony Eden
038: @since 2.0
039: */
040:
041: public class RawViewRenderer implements ViewRenderer {
042:
043: private SiteContext siteContext;
044:
045: /** Set the SiteContext.
046:
047: @param siteContext The SiteContext
048: */
049:
050: public void setSiteContext(SiteContext siteContext) {
051: this .siteContext = siteContext;
052: }
053:
054: /** Initialize the ViewRenderer.
055:
056: @throws Exception Any Exception
057: */
058:
059: public void init() throws Exception {
060:
061: }
062:
063: /** Render the view.
064:
065: @param context The JPublishContext
066: @param path The path to the template
067: @param in The Reader to read view template from
068: @param out The Writer to write the rendered view
069: @throws IOException
070: @throws ViewRenderException
071: */
072:
073: public void render(JPublishContext context, String path, Reader in,
074: Writer out) throws IOException, ViewRenderException {
075: int c = -1;
076: while ((c = in.read()) != -1) {
077: out.write((char) c);
078: }
079: }
080:
081: /** Render the view.
082:
083: @param context The JPublishContext
084: @param path The path to the template
085: @param in The InputStream to read view template from
086: @param out The OutputStream to write the rendered view
087: @throws IOException
088: @throws ViewRenderException
089: */
090:
091: public void render(JPublishContext context, String path,
092: InputStream in, OutputStream out) throws IOException,
093: ViewRenderException {
094: int c = -1;
095: while ((c = in.read()) != -1) {
096: out.write((char) c);
097: }
098: }
099:
100: /** Load the configuration for the view.
101:
102: @param configuration The configuration object
103: */
104:
105: public void loadConfiguration(Configuration configuration)
106: throws ConfigurationException {
107:
108: }
109:
110: }
|