Clover Coverage Report - XWiki Rendering - Parent POM 4.0-SNAPSHOT (Aggregated)
Coverage timestamp: Mon Mar 12 2012 18:03:13 CET
../../../../../img/srcFileCovDistChart9.png 55% of files have more coverage
8   94   8   1
0   40   1   8
8     1  
1    
 
  DefaultWikiPrinter       Line # 28 8 0% 8 2 87.5% 0.875
 
  (990)
 
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    * Printer using a {@link StringBuffer} as the underlying output target.
24    *
25    * @version $Id: e8fc57a19cdc3a8e7859cd5f9aaff8671074f154 $
26    * @since 1.6M1
27    */
 
28    public class DefaultWikiPrinter implements WikiPrinter
29    {
30    /**
31    * The buffer where to put the provided {@link String}s.
32    */
33    private StringBuffer buffer;
34   
35    /**
36    * The default constructor. It initialize a new empty {@link StringBuffer}.
37    */
 
38  1376 toggle public DefaultWikiPrinter()
39    {
40  1376 this(new StringBuffer());
41    }
42   
43    /**
44    * @param buffer the {@link StringBuffer} to where to put the provided {@link String}s.
45    */
 
46  1376 toggle public DefaultWikiPrinter(StringBuffer buffer)
47    {
48  1376 this.buffer = buffer;
49    }
50   
51    /**
52    * @return the buffer containing the printed {@link String}s.
53    */
 
54  30169 toggle public StringBuffer getBuffer()
55    {
56  30169 return this.buffer;
57    }
58   
59    /**
60    * This method is protected to allow classes extending this one to override what a new line is.
61    *
62    * @return a new line symbols
63    */
 
64  9183 toggle protected String getEOL()
65    {
66  9183 return "\n";
67    }
68   
 
69  19621 toggle @Override
70    public void print(String text)
71    {
72  19621 getBuffer().append(text);
73    }
74   
 
75  9183 toggle @Override
76    public void println(String text)
77    {
78  9183 getBuffer().append(text).append(getEOL());
79    }
80   
 
81  1365 toggle @Override
82    public String toString()
83    {
84  1365 return getBuffer().toString();
85    }
86   
87    /**
88    * Removes the buffer's content which allows the printer to be reused.
89    */
 
90  0 toggle public void clear()
91    {
92  0 getBuffer().setLength(0);
93    }
94    }