1. Project Clover database Sat Feb 2 2019 06:45:20 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
67
35
1
310
218
35
0.52
1.91
35
1

Classes

Class Line # Actions
ConsecutiveNewLineStateChainingListener 37 67 0% 35 9
0.911764791.2%
 

Contributing tests

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