1. Project Clover database Tue Dec 20 2016 21:24:09 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
1
87
50
7
0.5
3.5
4
1.75

Classes

Class Line # Actions
WikiModelParserUtils 37 14 0% 7 2
0.916666791.7%
 

Contributing tests

This file is covered by 131 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: 2a7cd4e19a644125f0a3543f7d5837679327479e $
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    /**
45    * @since 6.0RC1
46    * @since 5.4.5
47    */
 
48  852 toggle public void parseInline(StreamParser parser, String content, Listener listener, boolean prefix)
49    throws ParseException
50    {
51  852 if (prefix) {
52  772 WrappingListener inlineFilterListener = new InlineFilterListener()
53    {
54    private boolean foundWord = false;
55   
56    private boolean foundSpace = false;
57   
 
58  1926 toggle @Override
59    public void onWord(String word)
60    {
61  1926 if (this.foundWord) {
62  1154 super.onWord(word);
63    } else {
64  772 this.foundWord = true;
65    }
66    }
67   
 
68  1577 toggle @Override
69    public void onSpace()
70    {
71  1577 if (this.foundSpace) {
72  805 super.onSpace();
73    } else {
74  772 this.foundSpace = true;
75    }
76    }
77    };
78  772 inlineFilterListener.setWrappedListener(listener);
79   
80  772 parser.parse(new StringReader("wikimarker " + content), inlineFilterListener);
81    } else {
82  80 WrappingListener inlineFilterListener = new InlineFilterListener();
83  80 inlineFilterListener.setWrappedListener(listener);
84  80 parser.parse(new StringReader(content), inlineFilterListener);
85    }
86    }
87    }