1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 package org.millscript.millscript.render;
23
24 import org.millscript.commons.vfs.VFile;
25 import org.millscript.millscript.conf.Configuration;
26 import org.millscript.millscript.datatypes.XmlElement;
27 import org.millscript.millscript.tools.FormatPrint;
28
29 import java.io.PrintWriter;
30
31 /**
32 * This class implements MillScripts TXT renderer. It renders to a plain text
33 * file.
34 */
35 public final class TXTRenderer extends AbstractRenderer {
36
37 /**
38 * The writer we are rendering into.
39 */
40 protected final PrintWriter outputPrintWriter;
41
42 /**
43 * Constructs a new TXT renderer, to render to the specified virtual file
44 * using the given confguration.
45 *
46 * @param conf the configuration to get rendering parameters from
47 * @param file the virtual output file
48 */
49 public TXTRenderer( final Configuration conf, final VFile file ) {
50 super( conf, file );
51
52 this.outputPrintWriter = new PrintWriter( this.outputWriter );
53 }
54
55 /**
56 * @see org.millscript.millscript.render.Renderer#append(char)
57 */
58 public void append( final char ch ) {
59 this.appendNoEscape( ch );
60 }
61
62 /**
63 * @see org.millscript.millscript.render.Renderer#append(java.lang.CharSequence)
64 */
65 @Override
66 public void append( final CharSequence cs ) {
67 this.appendNoEscape( cs );
68 }
69
70 /**
71 * @see org.millscript.millscript.render.Renderer#appendEscapeFor(char)
72 */
73 public void appendEscapeFor( final char ch ) {
74 this.appendNoEscape( ch );
75 }
76
77 /**
78 * @see org.millscript.millscript.render.Renderer#appendNoEscape(char)
79 */
80 public void appendNoEscape( final char ch ) {
81 FormatPrint.print1( this.outputPrintWriter, new Character( ch ) );
82 }
83
84 /**
85 * @see org.millscript.millscript.render.Renderer#appendNoEscape(java.lang.CharSequence)
86 */
87 @Override
88 public void appendNoEscape( final CharSequence cs ) {
89 FormatPrint.print1( this.outputPrintWriter, cs );
90 }
91
92 /**
93 * @see org.millscript.millscript.render.Renderer#render(java.lang.Object)
94 */
95 @Override
96 public void render( final Object o ) {
97 FormatPrint.print1( this.outputPrintWriter, o );
98 }
99
100 /**
101 * @see org.millscript.millscript.render.Renderer#renderDocumentFooter()
102 */
103 public void renderDocumentFooter() {
104
105 }
106
107 /**
108 * @see org.millscript.millscript.render.Renderer#renderDocumentHeader()
109 */
110 public void renderDocumentHeader() {
111
112 }
113
114 /**
115 * @see org.millscript.millscript.render.Renderer#renderObject(java.lang.Object)
116 */
117 public void renderObject( final Object o ) {
118 FormatPrint.print1( this.outputPrintWriter, o );
119 }
120
121 /**
122 * @see org.millscript.millscript.render.Renderer#renderXMLElement(org.millscript.millscript.datatypes.XmlElement)
123 */
124 public void renderXMLElement( final XmlElement e ) {
125 FormatPrint.print1( this.outputPrintWriter, e );
126 }
127
128 }