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

File ConsecutiveNewLineStateChainingListener.java

 

Coverage histogram

../../../../../img/srcFileCovDistChart10.png
0% of files have more coverage

Code metrics

0
61
32
1
289
200
32
0.52
1.91
32
1

Classes

Class Line # Actions
ConsecutiveNewLineStateChainingListener 37 61 0% 32 0
1.0100%
 

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.listener.chaining;
21   
22    import java.util.Map;
23   
24    import org.xwiki.rendering.listener.Format;
25    import org.xwiki.rendering.listener.HeaderLevel;
26    import org.xwiki.rendering.listener.ListType;
27    import org.xwiki.rendering.listener.MetaData;
28    import org.xwiki.rendering.listener.reference.ResourceReference;
29    import org.xwiki.rendering.syntax.Syntax;
30   
31    /**
32    * Counts consecutive new lines.
33    *
34    * @version $Id; $
35    * @since 1.8RC1
36    */
 
37    public class ConsecutiveNewLineStateChainingListener extends AbstractChainingListener implements
38    StackableChainingListener
39    {
40    /**
41    * Number of found new lines.
42    */
43    private int newLineCount;
44   
45    /**
46    * @param listenerChain see {@link #getListenerChain()}
47    */
 
48  363 toggle public ConsecutiveNewLineStateChainingListener(ListenerChain listenerChain)
49    {
50  363 setListenerChain(listenerChain);
51    }
52   
 
53  29 toggle @Override
54    public StackableChainingListener createChainingListenerInstance()
55    {
56  29 return new ConsecutiveNewLineStateChainingListener(getListenerChain());
57    }
58   
59    /**
60    * @return the number of found new lines.
61    */
 
62  99 toggle public int getNewLineCount()
63    {
64  99 return this.newLineCount;
65    }
66   
 
67  21 toggle @Override
68    public void endDefinitionDescription()
69    {
70  21 this.newLineCount = 0;
71  21 super.endDefinitionDescription();
72    }
73   
74    /**
75    * {@inheritDoc}
76    *
77    * @since 2.0RC1
78    */
 
79  22 toggle @Override
80    public void endDefinitionList(Map<String, String> parameters)
81    {
82  22 this.newLineCount = 0;
83  22 super.endDefinitionList(parameters);
84    }
85   
 
86  17 toggle @Override
87    public void endDefinitionTerm()
88    {
89  17 this.newLineCount = 0;
90  17 super.endDefinitionTerm();
91    }
92   
93    /**
94    * {@inheritDoc}
95    *
96    * @since 3.0M2
97    */
 
98  511 toggle @Override
99    public void endDocument(MetaData metadata)
100    {
101  511 this.newLineCount = 0;
102  511 super.endDocument(metadata);
103    }
104   
 
105  29 toggle @Override
106    public void endGroup(Map<String, String> parameters)
107    {
108  29 this.newLineCount = 0;
109  29 super.endGroup(parameters);
110    }
111   
 
112  112 toggle @Override
113    public void endFormat(Format format, Map<String, String> parameters)
114    {
115  112 this.newLineCount = 0;
116  112 super.endFormat(format, parameters);
117    }
118   
119    /**
120    * {@inheritDoc}
121    *
122    * @since 2.5RC1
123    */
 
124  91 toggle @Override
125    public void endLink(ResourceReference reference, boolean freestanding, Map<String, String> parameters)
126    {
127  91 this.newLineCount = 0;
128  91 super.endLink(reference, freestanding, parameters);
129    }
130   
 
131  64 toggle @Override
132    public void endList(ListType type, Map<String, String> parameters)
133    {
134  64 this.newLineCount = 0;
135  64 super.endList(type, parameters);
136    }
137   
 
138  94 toggle @Override
139    public void endListItem()
140    {
141  94 this.newLineCount = 0;
142  94 super.endListItem();
143    }
144   
 
145  25 toggle @Override
146    public void endMacroMarker(String name, Map<String, String> parameters, String content, boolean isInline)
147    {
148  25 this.newLineCount = 0;
149  25 super.endMacroMarker(name, parameters, content, isInline);
150    }
151   
 
152  282 toggle @Override
153    public void endParagraph(Map<String, String> parameters)
154    {
155  282 this.newLineCount = 0;
156  282 super.endParagraph(parameters);
157    }
158   
 
159  11 toggle @Override
160    public void endQuotation(Map<String, String> parameters)
161    {
162  11 this.newLineCount = 0;
163  11 super.endQuotation(parameters);
164    }
165   
 
166  17 toggle @Override
167    public void endQuotationLine()
168    {
169  17 this.newLineCount = 0;
170  17 super.endQuotationLine();
171    }
172   
 
173  60 toggle @Override
174    public void endHeader(HeaderLevel level, String id, Map<String, String> parameters)
175    {
176  60 this.newLineCount = 0;
177  60 super.endHeader(level, id, parameters);
178    }
179   
 
180  19 toggle @Override
181    public void endTable(Map<String, String> parameters)
182    {
183  19 this.newLineCount = 0;
184  19 super.endTable(parameters);
185    }
186   
 
187  44 toggle @Override
188    public void endTableCell(Map<String, String> parameters)
189    {
190  44 this.newLineCount = 0;
191  44 super.endTableCell(parameters);
192    }
193   
 
194  25 toggle @Override
195    public void endTableHeadCell(Map<String, String> parameters)
196    {
197  25 this.newLineCount = 0;
198  25 super.endTableHeadCell(parameters);
199    }
200   
 
201  34 toggle @Override
202    public void endTableRow(Map<String, String> parameters)
203    {
204  34 this.newLineCount = 0;
205  34 super.endTableRow(parameters);
206    }
207   
 
208  4 toggle @Override
209    public void onRawText(String text, Syntax syntax)
210    {
211  4 this.newLineCount = 0;
212  4 super.onRawText(text, syntax);
213    }
214   
 
215  10 toggle @Override
216    public void onEmptyLines(int count)
217    {
218  10 this.newLineCount = 0;
219  10 super.onEmptyLines(count);
220    }
221   
 
222  10 toggle @Override
223    public void onHorizontalLine(Map<String, String> parameters)
224    {
225  10 this.newLineCount = 0;
226  10 super.onHorizontalLine(parameters);
227    }
228   
 
229  6 toggle @Override
230    public void onId(String name)
231    {
232  6 this.newLineCount = 0;
233  6 super.onId(name);
234    }
235   
236    /**
237    * {@inheritDoc}
238    *
239    * @since 2.5RC1
240    */
 
241  37 toggle @Override
242    public void onImage(ResourceReference reference, boolean freestanding, Map<String, String> parameters)
243    {
244  37 this.newLineCount = 0;
245  37 super.onImage(reference, freestanding, parameters);
246    }
247   
 
248  101 toggle @Override
249    public void onNewLine()
250    {
251  101 this.newLineCount++;
252  101 super.onNewLine();
253    }
254   
 
255  603 toggle @Override
256    public void onSpace()
257    {
258  603 this.newLineCount = 0;
259  603 super.onSpace();
260    }
261   
 
262  276 toggle @Override
263    public void onSpecialSymbol(char symbol)
264    {
265  276 this.newLineCount = 0;
266  276 super.onSpecialSymbol(symbol);
267    }
268   
 
269  22 toggle @Override
270    public void onMacro(String id, Map<String, String> parameters, String content, boolean inline)
271    {
272  22 this.newLineCount = 0;
273  22 super.onMacro(id, parameters, content, inline);
274    }
275   
 
276  20 toggle @Override
277    public void onVerbatim(String content, boolean inline, Map<String, String> parameters)
278    {
279  20 this.newLineCount = 0;
280  20 super.onVerbatim(content, inline, parameters);
281    }
282   
 
283  1067 toggle @Override
284    public void onWord(String word)
285    {
286  1067 this.newLineCount = 0;
287  1067 super.onWord(word);
288    }
289    }