Clover Coverage Report - XWiki Rendering - Parent POM 4.0-SNAPSHOT (Aggregated)
Coverage timestamp: Mon Mar 12 2012 18:03:13 CET
../../../../../../img/srcFileCovDistChart10.png 0% of files have more coverage
13   98   9   1.44
0   62   0.69   4.5
9     1  
2    
 
  PreserveTagHandler       Line # 30 7 0% 3 0 100% 1.0
  PreserverListener       Line # 59 6 0% 6 0 100% 1.0
 
  (219)
 
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.wikimodel.xhtml.handler;
21   
22    import org.xwiki.rendering.wikimodel.EmptyWemListener;
23    import org.xwiki.rendering.wikimodel.impl.WikiScannerContext;
24    import org.xwiki.rendering.wikimodel.xhtml.impl.XhtmlHandler.TagStack.TagContext;
25   
26    /**
27    * @version $Id: 8d9dbb4a117f07e583c5fd159b20663dcb336887 $
28    * @since 4.0M1
29    */
 
30    public class PreserveTagHandler extends TagHandler
31    {
 
32  309 toggle public PreserveTagHandler()
33    {
34  309 super(false, true, true);
35    }
36   
 
37  13 toggle @Override
38    protected void begin(TagContext context)
39    {
40    // filter content of the <pre> element
41  13 context.getTagStack().pushScannerContext(
42    new WikiScannerContext(new PreserverListener()));
43  13 context.getScannerContext().beginDocument();
44    }
45   
 
46  13 toggle @Override
47    protected void end(TagContext context)
48    {
49  13 context.getScannerContext().endDocument();
50  13 PreserverListener preserverListener = (PreserverListener) context
51    .getTagStack().popScannerContext().getfListener();
52  13 sendEmptyLines(context);
53   
54  13 context.getScannerContext().onVerbatim(preserverListener.toString(),
55    false, context.getParams());
56    }
57    }
58   
 
59    class PreserverListener extends EmptyWemListener
60    {
61    StringBuffer buffer = new StringBuffer();
62   
 
63  23 toggle @Override
64    public String toString()
65    {
66  23 return this.buffer.toString();
67    }
68   
 
69  29 toggle @Override
70    public void onWord(String str)
71    {
72  29 this.buffer.append(str);
73    }
74   
 
75  34 toggle @Override
76    public void onSpecialSymbol(String str)
77    {
78  34 this.buffer.append(str);
79    }
80   
 
81  17 toggle @Override
82    public void onSpace(String str)
83    {
84  17 this.buffer.append(str);
85    }
86   
 
87  13 toggle @Override
88    public void onLineBreak()
89    {
90  13 this.buffer.append("\n");
91    }
92   
 
93  4 toggle @Override
94    public void onNewLine()
95    {
96  4 this.buffer.append("\n");
97    }
98    }