View Javadoc

1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one or more
3    * contributor license agreements.  See the NOTICE file distributed with
4    * this work for additional information regarding copyright ownership.
5    * The ASF licenses this file to You under the Apache License, Version 2.0
6    * (the "License"); you may not use this file except in compliance with
7    * the License.  You may obtain a copy of the License at
8    * 
9    *      http://www.apache.org/licenses/LICENSE-2.0
10   * 
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS,
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   * See the License for the specific language governing permissions and
15   * limitations under the License.
16   */
17  package org.apache.jetspeed.administration;
18  
19  import java.util.Iterator;
20  import java.util.List;
21  
22  import org.apache.commons.configuration.Configuration;
23  
24  
25  /***
26   * Portal Configuration
27   * 
28   * Retrieve basic data types from the jetspeed.properties configuration
29   * This is a subset of Commons Configuration functionality
30   * Not the best solution wrappering commons configuration, but it does continue 
31   * with the requirements of interface-driven development and zero dependencies in API
32   *
33   * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
34   * @version $Id: $
35   */
36  public class PortalConfigurationImpl implements PortalConfiguration
37  {
38      Configuration configuration;
39      
40      public PortalConfigurationImpl(Configuration configuration)
41      {
42          this.configuration = configuration;
43      }
44      
45      public boolean getBoolean(String key, boolean defaultValue)
46      {
47          return configuration.getBoolean(key, defaultValue);
48      }
49  
50      public boolean getBoolean(String key)
51      {
52          return configuration.getBoolean(key);
53      }
54  
55      public double getDouble(String key, double defaultValue)
56      {
57          return configuration.getDouble(key, defaultValue);
58      }
59  
60      public double getDouble(String key)
61      {
62          return configuration.getDouble(key);
63      }
64  
65      public float getFloat(String key, float defaultValue)
66      {
67          return configuration.getFloat(key, defaultValue);
68      }
69  
70      public float getFloat(String key)
71      {
72          return configuration.getFloat(key);
73      }
74  
75      public int getInt(String key, int defaultValue)
76      {
77          return configuration.getInt(key, defaultValue);        
78      }
79  
80      public int getInt(String key)
81      {
82          return configuration.getInt(key);        
83      }
84  
85      public List getList(String key)
86      {
87          return configuration.getList(key);
88      }
89  
90      public long getLong(String key, long defaultValue)
91      {
92          return configuration.getLong(key, defaultValue);        
93      }
94  
95      public long getLong(String key)
96      {
97          return configuration.getLong(key);        
98      }
99  
100     public String getString(String key, String defaultValue)
101     {
102         return configuration.getString(key, defaultValue);        
103     }
104 
105     public String getString(String key)
106     {
107         return configuration.getString(key);        
108     }
109 
110     public String[] getStringArray(String key)
111     {
112         return configuration.getStringArray(key);                
113     }
114     
115     public Iterator getKeys()
116     {
117         return configuration.getKeys();
118     }
119     
120     public void setString(String key, String value)
121     {
122         configuration.setProperty(key, value);
123     }
124 }