KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > openharmonise > rm > publishing > renderers > impl > TextRenderer


1 /*
2  * The contents of this file are subject to the
3  * Mozilla Public License Version 1.1 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at http://www.mozilla.org/MPL/
6  *
7  * Software distributed under the License is distributed on an "AS IS"
8  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.
9  * See the License for the specific language governing rights and
10  * limitations under the License.
11  *
12  * The Initial Developer of the Original Code is Simulacra Media Ltd.
13  * Portions created by Simulacra Media Ltd are Copyright (C) Simulacra Media Ltd, 2004.
14  *
15  * All Rights Reserved.
16  *
17  * Contributor(s):
18  */

19 package org.openharmonise.rm.publishing.renderers.impl;
20
21 import java.io.*;
22
23 import javax.xml.transform.*;
24
25 import org.openharmonise.commons.xml.*;
26 import org.openharmonise.commons.xml.namespace.*;
27 import org.openharmonise.rm.publishing.renderers.*;
28
29
30 /**
31  *
32  * FIXME - Michael Bell DIDN'T GIVE ME A DESCRIPTION!!
33  * @author Michael Bell
34  * @version $Revision: 1.2 $
35  *
36  */

37 public class TextRenderer implements PageRenderer {
38
39     private static XMLPrettyPrint m_xprinter = new XMLPrettyPrint();
40
41     /**
42      * Basic constructor
43      */

44     public TextRenderer() {
45         super();
46     }
47
48     /* (non-Javadoc)
49      * @see org.openharmonise.rm.publishing.renderers.PageRenderer#render(org.openharmonise.commons.xml.XMLDocument, javax.xml.transform.Templates, java.io.OutputStream)
50      */

51     public void render(XMLDocument xdoc, Templates templates, OutputStream out)
52         throws RenderException {
53
54         try {
55             PrintStream pstream = new PrintStream(out, true, "UTF-8");
56
57             pstream.print(m_xprinter.printNode(xdoc.getDocumentElement()));
58             pstream.flush();
59         } catch (NamespaceClashException e) {
60             throw new RenderException("There was a namespace clash?!", e);
61         } catch (UnsupportedEncodingException e) {
62             throw new RenderException("Unsupported char encoding", e);
63         }
64
65     }
66
67     /**
68      * Renders state to <code>OutputStream</code>
69      *
70      * @param out
71      * @throws RenderException
72      */

73     static public void render(XMLDocument xdoc, OutputStream out)
74         throws RenderException {
75         try {
76             PrintStream pstream = new PrintStream(out, true, "UTF-8");
77
78             pstream.print(m_xprinter.printNode(xdoc.getDocumentElement()));
79             pstream.flush();
80         } catch (NamespaceClashException e) {
81             throw new RenderException("There was a namespace clash?!", e);
82         } catch (UnsupportedEncodingException e) {
83             throw new RenderException("Unsupported char encoding", e);
84         }
85
86     }
87
88 }
89
Popular Tags