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

File ConfluenceImageWikiReferenceParser.java

 

Coverage histogram

../../../../../img/srcFileCovDistChart9.png
38% of files have more coverage

Code metrics

6
24
1
1
69
40
4
0.17
24
1
4

Classes

Class Line # Actions
ConfluenceImageWikiReferenceParser 35 24 0% 4 3
0.903225890.3%
 

Contributing tests

This file is covered by 1 test. .

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.wikimodel.confluence;
21   
22    import java.util.ArrayList;
23   
24    import org.xwiki.rendering.wikimodel.IWikiReferenceParser;
25    import org.xwiki.rendering.wikimodel.WikiParameter;
26    import org.xwiki.rendering.wikimodel.WikiParameters;
27    import org.xwiki.rendering.wikimodel.WikiReference;
28    import org.xwiki.rendering.wikimodel.impl.WikiScannerUtil;
29   
30    /**
31    * @version $Id: c4fc5ca58e9ff03c78880aae1eaa21a852979d34 $
32    * @since 4.0M1
33    * @see org.xwiki.rendering.wikimodel.WikiReference
34    */
 
35    public class ConfluenceImageWikiReferenceParser implements IWikiReferenceParser
36    {
 
37  5 toggle public WikiReference parse(String str)
38    {
39  5 str = str.trim();
40  5 String[] array = str.split("[|]");
41  5 String link;
42  5 String label;
43  5 String tip;
44  5 WikiParameters params;
45  5 if (array.length == 1) {
46  3 link = str;
47  3 label = null;
48  3 tip = null;
49  3 params = WikiParameters.EMPTY;
50    } else {
51   
52  2 String s = array[1].trim();
53  2 ArrayList<WikiParameter> kps = new ArrayList<WikiParameter>();
54  2 WikiScannerUtil.splitToPairs(s, kps, ",");
55  2 params = WikiParameters.newWikiParameters("");
56  2 for (WikiParameter param : kps) {
57  3 params = params.addParameter(param.getKey(), param.getValue());
58    }
59  2 label = array[0].trim();
60  2 link = array[0].trim();
61  2 tip = (array.length > 2) ? array[2].trim() : null;
62    }
63  5 if (tip != null) {
64  0 params = params.addParameter("title", tip);
65    }
66  5 WikiReference ref = new WikiReference(link, label, params);
67  5 return ref;
68    }
69    }