1. Project Clover database Tue Dec 20 2016 21:24:09 CET
  2. Package com.xpn.xwiki.internal

File XWikiConfigDelegate.java

 

Coverage histogram

../../../../img/srcFileCovDistChart4.png
78% of files have more coverage

Code metrics

10
14
7
1
97
57
12
0.86
2
7
1.71

Classes

Class Line # Actions
XWikiConfigDelegate 36 14 0% 12 21
0.3225806432.3%
 

Contributing tests

This file is covered by 4 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 com.xpn.xwiki.internal;
21   
22    import java.io.IOException;
23    import java.io.InputStream;
24    import java.io.Reader;
25   
26    import org.apache.commons.lang3.StringUtils;
27    import org.xwiki.configuration.ConfigurationSource;
28   
29    import com.xpn.xwiki.XWikiConfig;
30   
31    /**
32    * Delegate all {@link XWikiConfig} methods to xwiki.cfg {@link ConfigurationSource}.
33    *
34    * @version $Id: b3978aaf9c59019d69d49a0160e466c1538b75b9 $
35    */
 
36    public class XWikiConfigDelegate extends XWikiConfig
37    {
38    private ConfigurationSource source;
39   
40    /**
41    * @param source the {@link ConfigurationSource} to delegate to
42    */
 
43  17272 toggle public XWikiConfigDelegate(ConfigurationSource source)
44    {
45  17272 this.source = source;
46   
47  17271 if (this.source instanceof XWikiCfgConfigurationSource) {
48  17203 this.defaults = ((XWikiCfgConfigurationSource) this.source).getProperties();
49    }
50    }
51   
 
52  101 toggle @Override
53    public String getProperty(String key)
54    {
55  101 return StringUtils.trim(this.source.getProperty(key, String.class));
56    }
57   
 
58  17233 toggle @Override
59    public String getProperty(String key, String defaultValue)
60    {
61  17233 return StringUtils.trim(this.source.getProperty(key, defaultValue));
62    }
63   
 
64  0 toggle @Override
65    public synchronized Object put(Object key, Object value)
66    {
67  0 if (this.defaults != null) {
68  0 return this.defaults.put(key, value);
69    }
70   
71  0 return null;
72    }
73   
 
74  0 toggle @Override
75    public synchronized void load(InputStream inStream) throws IOException
76    {
77  0 if (this.defaults != null) {
78  0 this.defaults.load(inStream);
79    }
80    }
81   
 
82  0 toggle @Override
83    public synchronized void load(Reader reader) throws IOException
84    {
85  0 if (this.defaults != null) {
86  0 this.defaults.load(reader);
87    }
88    }
89   
 
90  0 toggle @Override
91    public synchronized void loadFromXML(InputStream in) throws IOException
92    {
93  0 if (this.defaults != null) {
94  0 this.defaults.loadFromXML(in);
95    }
96    }
97    }