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
128   603   102   1.29
6   462   0.8   99
99     1.03  
1    
 
  WikiScannerContext       Line # 35 128 0% 102 17 92.7% 0.9270386
 
  (967)
 
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.impl;
21   
22    import java.util.Stack;
23   
24    import org.xwiki.rendering.wikimodel.IWemListener;
25    import org.xwiki.rendering.wikimodel.WikiParameters;
26    import org.xwiki.rendering.wikimodel.WikiReference;
27    import org.xwiki.rendering.wikimodel.WikiStyle;
28    import org.xwiki.rendering.wikimodel.util.SectionBuilder;
29    import org.xwiki.rendering.wikimodel.util.SectionListener;
30   
31    /**
32    * @version $Id: acf7fab3e353365d0a3013125a978fd35c2f380c $
33    * @since 4.0M1
34    */
 
35    public class WikiScannerContext implements IWikiScannerContext
36    {
37    protected final IWemListener fListener;
38   
39    protected SectionBuilder<WikiParameters> fSectionBuilder;
40   
41    protected final Stack<IWikiScannerContext> fStack = new Stack<IWikiScannerContext>();
42   
 
43  2616 toggle public WikiScannerContext(IWemListener listener)
44    {
45  2616 fListener = listener;
46  2616 fSectionBuilder = new SectionBuilder<WikiParameters>(
47    new SectionListener<WikiParameters>()
48    {
 
49  2796 toggle @Override
50    public void beginDocument(IPos<WikiParameters> pos)
51    {
52  2796 WikiParameters params = pos.getData();
53  2796 fListener.beginDocument(params);
54  2796 beginSection(pos);
55  2796 beginSectionContent(pos);
56    }
57   
 
58  3383 toggle @Override
59    public void beginSection(IPos<WikiParameters> pos)
60    {
61  3383 WikiParameters params = pos.getData();
62  3383 int docLevel = pos.getDocumentLevel();
63  3383 int headerLevel = pos.getHeaderLevel();
64  3383 fListener.beginSection(docLevel, headerLevel, params);
65    }
66   
 
67  3383 toggle @Override
68    public void beginSectionContent(IPos<WikiParameters> pos)
69    {
70  3383 fListener.beginSectionContent(pos.getDocumentLevel(), pos
71    .getHeaderLevel(), pos.getData());
72    }
73   
 
74  380 toggle @Override
75    public void beginSectionHeader(IPos<WikiParameters> pos)
76    {
77  380 fListener.beginHeader(pos.getHeaderLevel(), pos.getData());
78    }
79   
 
80  2796 toggle @Override
81    public void endDocument(IPos<WikiParameters> pos)
82    {
83  2796 endSectionContent(pos);
84  2796 endSection(pos);
85  2796 WikiParameters params = pos.getData();
86  2796 fListener.endDocument(params);
87    }
88   
 
89  3383 toggle @Override
90    public void endSection(IPos<WikiParameters> pos)
91    {
92  3383 WikiParameters params = pos.getData();
93  3383 int docLevel = pos.getDocumentLevel();
94  3383 int headerLevel = pos.getHeaderLevel();
95  3383 fListener.endSection(docLevel, headerLevel, params);
96    }
97   
 
98  3383 toggle @Override
99    public void endSectionContent(IPos<WikiParameters> pos)
100    {
101  3383 fListener.endSectionContent(pos.getDocumentLevel(), pos
102    .getHeaderLevel(), pos.getData());
103    }
104   
 
105  380 toggle @Override
106    public void endSectionHeader(IPos<WikiParameters> pos)
107    {
108  380 fListener.endHeader(pos.getHeaderLevel(), pos.getData());
109    }
110    });
111    }
112   
 
113  30 toggle public IWemListener getfListener()
114    {
115  30 return this.fListener;
116    }
117   
 
118  2660 toggle public void beginDocument()
119    {
120  2660 InternalWikiScannerContext context = pushContext();
121  2660 context.beginDocument();
122    }
123   
 
124  136 toggle public void beginDocument(WikiParameters params)
125    {
126  136 InternalWikiScannerContext context = pushContext();
127  136 context.beginDocument(params);
128    }
129   
 
130  78 toggle public void beginFormat(WikiParameters params)
131    {
132  78 getContext().beginFormat(params);
133    }
134   
 
135  88 toggle public void beginFormat(WikiStyle wikiStyle)
136    {
137  88 getContext().beginFormat(wikiStyle);
138    }
139   
 
140  54 toggle public void beginHeader(int level)
141    {
142  54 getContext().beginHeader(level);
143    }
144   
 
145  326 toggle public void beginHeader(int level, WikiParameters params)
146    {
147  326 getContext().beginHeader(level, params);
148    }
149   
 
150  7 toggle public void beginInfo(String type, WikiParameters params)
151    {
152  7 getContext().beginInfo(type, params);
153    }
154   
 
155  63 toggle public void beginList()
156    {
157  63 getContext().beginList();
158    }
159   
 
160  265 toggle public void beginList(WikiParameters params)
161    {
162  265 getContext().beginList(params);
163    }
164   
 
165  282 toggle public void beginListItem(String item)
166    {
167  282 getContext().beginListItem(item);
168    }
169   
 
170  410 toggle public void beginListItem(String item, WikiParameters params)
171    {
172  410 getContext().beginListItem(item, params);
173    }
174   
 
175  653 toggle public void beginParagraph()
176    {
177  653 getContext().beginParagraph();
178    }
179   
 
180  1339 toggle public void beginParagraph(WikiParameters params)
181    {
182  1339 getContext().beginParagraph(params);
183    }
184   
 
185  39 toggle public void beginPropertyBlock(String property, boolean doc)
186    {
187  39 getContext().beginPropertyBlock(property, doc);
188    }
189   
 
190  4 toggle public void beginPropertyInline(String str)
191    {
192  4 getContext().beginPropertyInline(str);
193    }
194   
 
195  26 toggle public void beginQuot()
196    {
197  26 getContext().beginQuot();
198    }
199   
 
200  48 toggle public void beginQuot(WikiParameters params)
201    {
202  48 getContext().beginQuot(params);
203    }
204   
 
205  133 toggle public void beginQuotLine(int depth)
206    {
207  133 getContext().beginQuotLine(depth);
208    }
209   
 
210  22 toggle public void beginTable()
211    {
212  22 getContext().beginTable();
213    }
214   
 
215  179 toggle public void beginTable(WikiParameters params)
216    {
217  179 getContext().beginTable(params);
218    }
219   
 
220  15 toggle public void beginTableCell(boolean headCell)
221    {
222  15 getContext().beginTableCell(headCell);
223    }
224   
 
225  100 toggle public void beginTableCell(boolean headCell, WikiParameters params)
226    {
227  100 getContext().beginTableCell(headCell, params);
228    }
229   
 
230  36 toggle public void beginTableRow(boolean headCell)
231    {
232  36 getContext().beginTableRow(headCell);
233    }
234   
 
235  217 toggle public void beginTableRow(boolean head, WikiParameters rowParams,
236    WikiParameters cellParams)
237    {
238  217 getContext().beginTableRow(head, rowParams, cellParams);
239    }
240   
 
241  52 toggle public void beginTableRow(WikiParameters rowParams)
242    {
243  52 getContext().beginTableRow(rowParams);
244    }
245   
 
246  59 toggle public boolean canApplyDefintionSplitter()
247    {
248  59 return getContext().canApplyDefintionSplitter();
249    }
250   
 
251  28 toggle public boolean checkFormatStyle(WikiStyle style)
252    {
253  28 return getContext().checkFormatStyle(style);
254    }
255   
 
256  0 toggle public void closeBlock()
257    {
258  0 getContext().closeBlock();
259    }
260   
 
261  2796 toggle public void endDocument()
262    {
263  2796 getContext().endDocument();
264  2796 fStack.pop();
265    }
266   
 
267  63 toggle public void endFormat(WikiParameters params)
268    {
269  63 getContext().endFormat(params);
270    }
271   
 
272  87 toggle public void endFormat(WikiStyle wikiStyle)
273    {
274  87 getContext().endFormat(wikiStyle);
275    }
276   
 
277  380 toggle public void endHeader()
278    {
279  380 getContext().endHeader();
280    }
281   
 
282  7 toggle public void endInfo()
283    {
284  7 getContext().endInfo();
285    }
286   
 
287  302 toggle public void endList()
288    {
289  302 getContext().endList();
290    }
291   
 
292  578 toggle public void endListItem()
293    {
294  578 getContext().endListItem();
295    }
296   
 
297  2530 toggle public void endParagraph()
298    {
299  2530 getContext().endParagraph();
300    }
301   
 
302  39 toggle public void endPropertyBlock()
303    {
304  39 getContext().endPropertyBlock();
305    }
306   
 
307  4 toggle public void endPropertyInline()
308    {
309  4 getContext().endPropertyInline();
310    }
311   
 
312  74 toggle public void endQuot()
313    {
314  74 getContext().endQuot();
315    }
316   
 
317  126 toggle public void endQuotLine()
318    {
319  126 getContext().endQuotLine();
320    }
321   
 
322  201 toggle public void endTable()
323    {
324  201 getContext().endTable();
325    }
326   
 
327  100 toggle public void endTableCell()
328    {
329  100 getContext().endTableCell();
330    }
331   
 
332  0 toggle public void endTableExplicit()
333    {
334  0 getContext().endTableExplicit();
335    }
336   
 
337  305 toggle public void endTableRow()
338    {
339  305 getContext().endTableRow();
340    }
341   
 
342  29306 toggle public IWikiScannerContext getContext()
343    {
344  29306 if (!fStack.isEmpty()) {
345  26971 return fStack.peek();
346    }
347  2335 InternalWikiScannerContext context = newInternalContext();
348  2335 fStack.push(context);
349  2335 return context;
350    }
351   
 
352  28 toggle public InlineState getInlineState()
353    {
354  28 return getContext().getInlineState();
355    }
356   
 
357  4 toggle public int getTableCellCounter()
358    {
359  4 return getContext().getTableCellCounter();
360    }
361   
 
362  21 toggle public int getTableRowCounter()
363    {
364  21 return getContext().getTableRowCounter();
365    }
366   
 
367  0 toggle public boolean isInDefinitionList()
368    {
369  0 return getContext().isInDefinitionList();
370    }
371   
 
372  0 toggle public boolean isInDefinitionTerm()
373    {
374  0 return getContext().isInDefinitionTerm();
375    }
376   
 
377  60 toggle public boolean isInHeader()
378    {
379  60 return getContext().isInHeader();
380    }
381   
 
382  6 toggle public boolean isInInlineProperty()
383    {
384  6 return getContext().isInInlineProperty();
385    }
386   
 
387  0 toggle public boolean isInList()
388    {
389  0 return getContext().isInList();
390    }
391   
 
392  97 toggle public boolean isInTable()
393    {
394  97 return getContext().isInTable();
395    }
396   
 
397  0 toggle public boolean isInTableCell()
398    {
399  0 return getContext().isInTableCell();
400    }
401   
 
402  0 toggle public boolean isInTableRow()
403    {
404  0 return getContext().isInTableRow();
405    }
406   
407    /**
408    * @return
409    */
 
410  4850 toggle protected InternalWikiScannerContext newInternalContext()
411    {
412  4850 InternalWikiScannerContext context = new InternalWikiScannerContext(
413    fSectionBuilder,
414    fListener);
415  4850 return context;
416    }
417   
 
418  21 toggle public void onDefinitionListItemSplit()
419    {
420  21 getContext().onDefinitionListItemSplit();
421    }
422   
 
423  63 toggle public void onEmptyLines(int count)
424    {
425  63 getContext().onEmptyLines(count);
426    }
427   
 
428  28 toggle public void onEscape(String str)
429    {
430  28 getContext().onEscape(str);
431    }
432   
 
433  14 toggle public void onExtensionBlock(String extensionName, WikiParameters params)
434    {
435  14 getContext().onExtensionBlock(extensionName, params);
436    }
437   
 
438  6 toggle public void onExtensionInline(String extensionName, WikiParameters params)
439    {
440  6 getContext().onExtensionInline(extensionName, params);
441    }
442   
 
443  95 toggle public void onFormat(WikiParameters params)
444    {
445  95 getContext().onFormat(params);
446    }
447   
 
448  653 toggle public void onFormat(WikiStyle wikiStyle)
449    {
450  653 getContext().onFormat(wikiStyle);
451    }
452   
453    /**
454    * @see WikiScannerContext#onFormat(org.xwiki.rendering.wikimodel.WikiStyle,
455    * boolean)
456    */
 
457  22 toggle public void onFormat(WikiStyle wikiStyle, boolean forceClose)
458    {
459  22 getContext().onFormat(wikiStyle, forceClose);
460    }
461   
 
462  8 toggle public void onHorizontalLine()
463    {
464  8 getContext().onHorizontalLine();
465    }
466   
 
467  72 toggle public void onHorizontalLine(WikiParameters params)
468    {
469  72 getContext().onHorizontalLine(params);
470    }
471   
 
472  64 toggle public void onImage(String ref)
473    {
474  64 getContext().onImage(ref);
475    }
476   
 
477  68 toggle public void onImage(WikiReference ref)
478    {
479  68 getContext().onImage(ref);
480    }
481   
 
482  68 toggle public void onLineBreak()
483    {
484  68 getContext().onLineBreak();
485    }
486   
 
487  289 toggle public void onMacro(String name, WikiParameters params, String content)
488    {
489  289 getContext().onMacro(name, params, content);
490    }
491   
 
492  147 toggle public void onMacro(String macroName, WikiParameters params,
493    String content, boolean inline)
494    {
495  147 if (inline) {
496  139 onMacroInline(macroName, params, content);
497    } else {
498  8 onMacroBlock(macroName, params, content);
499    }
500    }
501   
 
502  161 toggle public void onMacroBlock(String macroName, WikiParameters params,
503    String content)
504    {
505  161 getContext().onMacroBlock(macroName, params, content);
506    }
507   
 
508  168 toggle public void onMacroInline(String macroName, WikiParameters params,
509    String content)
510    {
511  168 getContext().onMacroInline(macroName, params, content);
512    }
513   
 
514  472 toggle public void onNewLine()
515    {
516  472 getContext().onNewLine();
517    }
518   
 
519  0 toggle public void onQuotLine(int depth)
520    {
521  0 getContext().onQuotLine(depth);
522    }
523   
 
524  77 toggle public void onReference(String ref)
525    {
526  77 getContext().onReference(ref);
527    }
528   
 
529  340 toggle public void onReference(WikiReference ref)
530    {
531  340 getContext().onReference(ref);
532    }
533   
 
534  4161 toggle public void onSpace(String str)
535    {
536  4161 getContext().onSpace(str);
537    }
538   
 
539  1677 toggle public void onSpecialSymbol(String str)
540    {
541  1677 getContext().onSpecialSymbol(str);
542    }
543   
 
544  1 toggle public void onTableCaption(String str)
545    {
546  1 getContext().onTableCaption(str);
547    }
548   
 
549  52 toggle public void onTableCell(boolean headCell)
550    {
551  52 getContext().onTableCell(headCell);
552    }
553   
 
554  193 toggle public void onTableCell(boolean head, WikiParameters cellParams)
555    {
556  193 getContext().onTableCell(head, cellParams);
557    }
558   
559    /**
560    * @see WikiScannerContext#onTableRow(org.xwiki.rendering.wikimodel.WikiParameters)
561    */
 
562  8 toggle public void onTableRow(WikiParameters params)
563    {
564  8 getContext().onTableRow(params);
565    }
566   
567    /**
568    * @see WikiScannerContext#onVerbatim(java.lang.String,
569    * boolean)
570    */
 
571  80 toggle public void onVerbatim(String str, boolean inline)
572    {
573  80 getContext().onVerbatim(str, inline);
574    }
575   
 
576  48 toggle public void onVerbatim(String str, boolean inline, WikiParameters params)
577    {
578  48 getContext().onVerbatim(str, inline, params);
579    }
580   
 
581  81 toggle public void onVerbatim(String str, WikiParameters params)
582    {
583  81 getContext().onVerbatim(str, params);
584    }
585   
 
586  7455 toggle public void onWord(String str)
587    {
588  7455 getContext().onWord(str);
589    }
590   
 
591  2796 toggle private InternalWikiScannerContext pushContext()
592    {
593  2796 InternalWikiScannerContext context = (InternalWikiScannerContext) getContext();
594  2796 if (context != null) {
595  2796 context.checkBlockContainer();
596  2796 context.closeFormat();
597    }
598  2796 context = newInternalContext();
599  2796 fStack.push(context);
600   
601  2796 return context;
602    }
603    }