Class | Line # | Actions | |||||
---|---|---|---|---|---|---|---|
WriterWikiPrinter | 31 | 9 | 0% | 7 | 10 |
1 | /* | |
2 | * See the NOTICE file distributed with this work for additional | |
3 | * information regarding copyright ownership. | |
4 | * | |
5 | * This is free software; you can redistribute it and/or modify it | |
6 | * under the terms of the GNU Lesser General Public License as | |
7 | * published by the Free Software Foundation; either version 2.1 of | |
8 | * the License, or (at your option) any later version. | |
9 | * | |
10 | * This software is distributed in the hope that it will be useful, | |
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
13 | * Lesser General Public License for more details. | |
14 | * | |
15 | * You should have received a copy of the GNU Lesser General Public | |
16 | * License along with this software; if not, write to the Free | |
17 | * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA | |
18 | * 02110-1301 USA, or see the FSF site: http://www.fsf.org. | |
19 | */ | |
20 | package org.xwiki.rendering.renderer.printer; | |
21 | ||
22 | import java.io.IOException; | |
23 | import java.io.Writer; | |
24 | ||
25 | /** | |
26 | * Printer using a {@link Writer} as the underlying output target. | |
27 | * | |
28 | * @version $Id: 7f5170ac8830bec6b4969db30ca1410dcec55a1b $ | |
29 | * @since 6.2M1 | |
30 | */ | |
31 | public class WriterWikiPrinter implements WikiPrinter | |
32 | { | |
33 | /** | |
34 | * The buffer where to put the provided {@link String}s. | |
35 | */ | |
36 | private Writer writer; | |
37 | ||
38 | /** | |
39 | * @param writer the writer | |
40 | */ | |
41 | 1 | ![]() |
42 | { | |
43 | 1 | this.writer = writer; |
44 | } | |
45 | ||
46 | /** | |
47 | * @return the writer | |
48 | */ | |
49 | 0 | ![]() |
50 | { | |
51 | 0 | return this.writer; |
52 | } | |
53 | ||
54 | /** | |
55 | * This method is protected to allow classes extending this one to override what a new line is. | |
56 | * | |
57 | * @return a new line symbols | |
58 | */ | |
59 | 0 | ![]() |
60 | { | |
61 | 0 | return "\n"; |
62 | } | |
63 | ||
64 | 15 | ![]() |
65 | public void print(String text) | |
66 | { | |
67 | 15 | try { |
68 | 15 | this.writer.write(text); |
69 | } catch (IOException e) { | |
70 | 0 | throw new RuntimeException("Failed to write", e); |
71 | } | |
72 | } | |
73 | ||
74 | 0 | ![]() |
75 | public void println(String text) | |
76 | { | |
77 | 0 | print(text); |
78 | 0 | print(getEOL()); |
79 | } | |
80 | ||
81 | 0 | ![]() |
82 | public String toString() | |
83 | { | |
84 | 0 | return this.writer.toString(); |
85 | } | |
86 | } |