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

File DefaultRenderingConfiguration.java

 

Coverage histogram

../../../../../img/srcFileCovDistChart8.png
54% of files have more coverage

Code metrics

0
9
7
1
134
63
7
0.78
1.29
7
1

Classes

Class Line # Actions
DefaultRenderingConfiguration 47 9 0% 7 4
0.7575%
 

Contributing tests

This file is covered by 438 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.configuration;
21   
22    import java.lang.reflect.Type;
23    import java.util.ArrayList;
24    import java.util.List;
25    import java.util.Properties;
26   
27    import javax.inject.Inject;
28    import javax.inject.Singleton;
29   
30    import org.slf4j.Logger;
31    import org.xwiki.component.annotation.Component;
32    import org.xwiki.component.descriptor.ComponentDescriptor;
33    import org.xwiki.component.manager.ComponentManager;
34    import org.xwiki.component.phase.Initializable;
35    import org.xwiki.component.phase.InitializationException;
36    import org.xwiki.rendering.configuration.RenderingConfiguration;
37    import org.xwiki.rendering.transformation.Transformation;
38   
39    /**
40    * Basic default implementation to be used when using the XWiki Rendering system standalone.
41    *
42    * @version $Id: f39e899e1a5b4a4469a2447121ecc57d9a4b6bb7 $
43    * @since 2.0M1
44    */
45    @Component
46    @Singleton
 
47    public class DefaultRenderingConfiguration implements RenderingConfiguration, Initializable
48    {
49    /**
50    * The logger to log.
51    */
52    @Inject
53    private Logger logger;
54   
55    /**
56    * Used to look up Transformations at runtime.
57    */
58    @Inject
59    private ComponentManager componentManager;
60   
61    /**
62    * Holds the names of transformations to apply (in any order, the Transformation Manager will execute them in the
63    * proper order).
64    */
65    private List<String> transformationNames = new ArrayList<String>();
66   
67    /**
68    * @see #getLinkLabelFormat()
69    */
70    private String linkLabelFormat = "%p";
71   
72    /**
73    * @see #getInterWikiDefinitions()
74    */
75    private Properties interWikiDefinitions = new Properties();
76   
 
77  634 toggle @Override
78    public void initialize() throws InitializationException
79    {
80    // Find the names of all registered Transformations.
81  634 List<ComponentDescriptor<Transformation>> descriptors =
82    this.componentManager.getComponentDescriptorList((Type) Transformation.class);
83  634 for (ComponentDescriptor<Transformation> descriptor : descriptors) {
84  633 this.transformationNames.add(descriptor.getRoleHint());
85    }
86    }
87   
 
88  2 toggle @Override
89    public String getLinkLabelFormat()
90    {
91  2 return this.linkLabelFormat;
92    }
93   
94    /**
95    * @param linkLabelFormat the format used to decide how to display links that have no label
96    */
 
97  0 toggle public void setLinkLabelFormat(String linkLabelFormat)
98    {
99    // This method is useful for those using the XWiki Rendering in standalone mode since it allows the rendering
100    // to work even without a configuration store.
101  0 this.linkLabelFormat = linkLabelFormat;
102    }
103   
 
104  4 toggle @Override
105    public Properties getInterWikiDefinitions()
106    {
107  4 return this.interWikiDefinitions;
108    }
109   
110    /**
111    * @param interWikiAlias see {@link org.xwiki.rendering.listener.reference.InterWikiResourceReference}
112    * @param interWikiURL see {@link org.xwiki.rendering.listener.reference.InterWikiResourceReference}
113    */
 
114  198 toggle public void addInterWikiDefinition(String interWikiAlias, String interWikiURL)
115    {
116    // This method is useful for those using the XWiki Rendering in standalone mode since it allows the rendering
117    // to work even without a configuration store.
118  198 this.interWikiDefinitions.setProperty(interWikiAlias, interWikiURL);
119    }
120   
121    /**
122    * @param transformationNames the explicit list of transformation names to execute (overrides the default list)
123    */
 
124  0 toggle public void setTransformationNames(List<String> transformationNames)
125    {
126  0 this.transformationNames = transformationNames;
127    }
128   
 
129  473 toggle @Override
130    public List<String> getTransformationNames()
131    {
132  473 return this.transformationNames;
133    }
134    }