1. Project Clover database Sat Feb 2 2019 06:45:20 CET
  2. Package org.xwiki.rendering.internal.parser.wikimodel

File WikiModelParserUtils.java

 

Coverage histogram

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

Code metrics

6
14
4
2
90
51
7
0.5
3.5
2
1.75

Classes

Class Line # Actions
WikiModelParserUtils 37 8 0% 3 2
0.833333383.3%
WikiModelParserUtils.PrefixIgnoredInlineFilterListener 44 6 0% 4 0
1.0100%
 

Contributing tests

This file is covered by 124 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.internal.parser.wikimodel;
21   
22    import java.io.StringReader;
23   
24    import org.xwiki.rendering.listener.InlineFilterListener;
25    import org.xwiki.rendering.listener.Listener;
26    import org.xwiki.rendering.listener.WrappingListener;
27    import org.xwiki.rendering.parser.ParseException;
28    import org.xwiki.rendering.parser.StreamParser;
29    import org.xwiki.rendering.util.ParserUtils;
30   
31    /**
32    * Methods for helping in parsing.
33    *
34    * @version $Id: 0e77f4a8382979247d228e8aa032ea380853d1f2 $
35    * @since 1.8M1
36    */
 
37    public class WikiModelParserUtils extends ParserUtils
38    {
 
39  0 toggle public void parseInline(StreamParser parser, String content, Listener listener) throws ParseException
40    {
41  0 parseInline(parser, content, listener, false);
42    }
43   
 
44    private class PrefixIgnoredInlineFilterListener extends InlineFilterListener
45    {
46    private boolean foundWord;
47   
48    private boolean foundSpace;
49   
 
50  74042 toggle @Override
51    public void onWord(String word)
52    {
53  74042 if (this.foundWord) {
54  50076 super.onWord(word);
55    } else {
56  23965 this.foundWord = true;
57    }
58    }
59   
 
60  51367 toggle @Override
61    public void onSpace()
62    {
63  51365 if (this.foundSpace) {
64  27400 super.onSpace();
65    } else {
66  23968 this.foundSpace = true;
67    }
68    }
69    }
70   
71    /**
72    * @since 6.0RC1
73    * @since 5.4.5
74    */
 
75  24022 toggle public void parseInline(StreamParser parser, String content, Listener listener, boolean prefix)
76    throws ParseException
77    {
78  24028 if (prefix) {
79  23969 WrappingListener inlineFilterListener = new PrefixIgnoredInlineFilterListener();
80  23966 inlineFilterListener.setWrappedListener(listener);
81   
82  23965 parser.parse(new StringReader("wikimarker " + content), inlineFilterListener);
83    } else {
84  61 WrappingListener inlineFilterListener = new InlineFilterListener();
85  61 inlineFilterListener.setWrappedListener(listener);
86   
87  61 parser.parse(new StringReader(content), inlineFilterListener);
88    }
89    }
90    }