1. Project Clover database Tue Dec 20 2016 21:24:09 CET
  2. Package org.xwiki.rendering.renderer.printer

File DefaultWikiPrinter.java

 

Coverage histogram

../../../../../img/srcFileCovDistChart9.png
38% of files have more coverage

Code metrics

0
8
8
1
94
40
8
1
1
8
1

Classes

Class Line # Actions
DefaultWikiPrinter 28 8 0% 8 2
0.87587.5%
 

Contributing tests

This file is covered by 278 tests. .

Source view

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: 4f0769c6cf8b069a824c7bf4ff363de8196e8225 $
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  108264 toggle public DefaultWikiPrinter()
39    {
40  108261 this(new StringBuffer());
41    }
42   
43    /**
44    * @param buffer the {@link StringBuffer} to where to put the provided {@link String}s.
45    */
 
46  108265 toggle public DefaultWikiPrinter(StringBuffer buffer)
47    {
48  108262 this.buffer = buffer;
49    }
50   
51    /**
52    * @return the buffer containing the printed {@link String}s.
53    */
 
54  1676878 toggle public StringBuffer getBuffer()
55    {
56  1676857 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  8938 toggle protected String getEOL()
65    {
66  8938 return "\n";
67    }
68   
 
69  1559740 toggle @Override
70    public void print(String text)
71    {
72  1559736 getBuffer().append(text);
73    }
74   
 
75  8938 toggle @Override
76    public void println(String text)
77    {
78  8938 getBuffer().append(text).append(getEOL());
79    }
80   
 
81  108201 toggle @Override
82    public String toString()
83    {
84  108203 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    }