Clover Coverage Report - XWiki Rendering - Parent POM 4.0-SNAPSHOT (Aggregated)
Coverage timestamp: Mon Mar 12 2012 18:03:13 CET
../../../../../img/srcFileCovDistChart7.png 76% of files have more coverage
14   96   11   1.4
2   52   0.79   10
10     1.1  
1    
 
  LookaheadWikiPrinter       Line # 31 14 0% 11 10 61.5% 0.61538464
 
  (326)
 
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    /**
23    * Wiki printer that allows deferring printing text and that instead can save it in some internal buffer. This allows
24    * accumulating some content before it's flushed. This feature is used for example in the XWiki Syntax Renderer to
25    * accumulate text so that it be reviewed and escaped before printed (indeed some text has some characters that need to
26    * be escaped or they'd have a wiki meaning otherwise).
27    *
28    * @version $Id: 5fc7610cfebf498aa19631c383dfd7f2ed778489 $
29    * @since 1.7
30    */
 
31    public class LookaheadWikiPrinter extends WrappingWikiPrinter
32    {
33    private StringBuffer buffer = new StringBuffer();
34   
 
35  447 toggle public LookaheadWikiPrinter(WikiPrinter printer)
36    {
37  447 super(printer);
38    }
39   
 
40  2407 toggle protected void printInternal(String text)
41    {
42  2407 super.print(text);
43    }
44   
 
45  0 toggle protected void printlnInternal(String text)
46    {
47  0 super.println(text);
48    }
49   
 
50  1767 toggle @Override
51    public void print(String text)
52    {
53  1767 flush();
54  1767 printInternal(text);
55    }
56   
 
57  0 toggle @Override
58    public void println(String text)
59    {
60  0 flush();
61  0 printlnInternal(text);
62    }
63   
 
64  1845 toggle public void printDelayed(String text)
65    {
66  1845 getBuffer().append(text);
67    }
68   
 
69  0 toggle public void printlnDelayed(String text)
70    {
71  0 getBuffer().append(text).append(getEOL());
72    }
73   
 
74  7765 toggle public StringBuffer getBuffer()
75    {
76  7765 return this.buffer;
77    }
78   
 
79  640 toggle public void flush()
80    {
81  640 if (getBuffer().length() > 0) {
82  640 printInternal(getBuffer().toString());
83  640 getBuffer().setLength(0);
84    }
85    }
86   
87    /**
88    * This method is protected to allow classes extending this one to define what a new line is.
89    *
90    * @return a new line symbols
91    */
 
92  0 toggle protected String getEOL()
93    {
94  0 return "\n";
95    }
96    }