1. Project Clover database Tue Dec 20 2016 21:24:09 CET
  2. Package org.xwiki.component.wiki.internal.bridge

File DefaultContentParser.java

 

Coverage histogram

../../../../../../img/srcFileCovDistChart5.png
74% of files have more coverage

Code metrics

0
5
2
1
66
33
4
0.8
2.5
2
2

Classes

Class Line # Actions
DefaultContentParser 41 5 0% 4 4
0.4285714342.9%
 

Contributing tests

No tests hitting this source file were found.

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.component.wiki.internal.bridge;
21   
22    import javax.inject.Inject;
23    import javax.inject.Singleton;
24   
25    import org.xwiki.component.annotation.Component;
26    import org.xwiki.component.wiki.WikiComponentException;
27    import org.xwiki.model.reference.EntityReference;
28    import org.xwiki.rendering.block.XDOM;
29    import org.xwiki.rendering.parser.MissingParserException;
30    import org.xwiki.rendering.parser.ParseException;
31    import org.xwiki.rendering.syntax.Syntax;
32   
33    /**
34    * A bridge between Wiki Components and rendering.
35    *
36    * @version $Id: 22307cde98baf63913546caabfa3ebd0a6faefc8 $
37    * @since 4.3M2
38    */
39    @Component
40    @Singleton
 
41    public class DefaultContentParser implements ContentParser
42    {
43    /**
44    * Used to retrieve parsers dynamically depending on documents syntax.
45    */
46    @Inject
47    private org.xwiki.rendering.parser.ContentParser contentParser;
48   
 
49  0 toggle @Override
50    public XDOM parse(String content, Syntax syntax) throws WikiComponentException
51    {
52  0 return parse(content, syntax, null);
53    }
54   
 
55  310 toggle @Override
56    public XDOM parse(String content, Syntax syntax, EntityReference source) throws WikiComponentException
57    {
58  310 try {
59  310 return contentParser.parse(content, syntax, source);
60    } catch (ParseException e) {
61  0 throw new WikiComponentException(String.format("Failed to parse content [%s]", content), e);
62    } catch (MissingParserException e) {
63  0 throw new WikiComponentException(String.format("Failed to find a parser to parse syntax [%s]", syntax), e);
64    }
65    }
66    }