~ubuntu-branches/ubuntu/saucy/commons-configuration/saucy

« back to all changes in this revision

Viewing changes to src/main/java/org/apache/commons/configuration/web/BaseWebConfiguration.java

  • Committer: Package Import Robot
  • Author(s): Emmanuel Bourg
  • Date: 2013-07-01 16:29:44 UTC
  • mfrom: (1.1.4)
  • Revision ID: package-import@ubuntu.com-20130701162944-98waq5gogha5gpn1
Tags: 1.9-1
* New upstream release
* debian/control:
  - Updated Standards-Version to 3.9.4 (no changes)
  - Use canonical URLs for the Vcs-* fields
  - Added new build dependencies (libjavacc-maven-plugin-java, junit4)
  - Upgraded the dependency on the Servlet API (2.5 -> 3.0)
  - Removed the dependency on the Activation Framework (glassfish-activation)
  - Replaced the dependency on glassfish-mail with libgnumail-java
  - Removed the unused dependencies:
    liblog4j1.2-java-doc, libmaven-assembly-plugin-java
  - Replaced the dependency on libcommons-jexl-java by libcommons-jexl2-java
* debian/watch: Changed to point the official Apache distribution server
* Removed the obsolete file debian/ant.properties
* Installed the upstream changelog in the binary packages
* Added the report plugins to maven.ignoreRules
* Added the classpath attribute to the jar manifest

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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.commons.configuration.web;
 
18
 
 
19
import java.util.List;
 
20
 
 
21
import org.apache.commons.configuration.AbstractConfiguration;
 
22
import org.apache.commons.configuration.PropertyConverter;
 
23
 
 
24
/**
 
25
 * <p>
 
26
 * An abstract base class for all web configurations.
 
27
 * </p>
 
28
 * <p>
 
29
 * This class implements common functionality used by all web based
 
30
 * configurations. E.g. some methods are not supported by configurations of this
 
31
 * type, so they throw a {@code UnsupportedOperationException} exception.
 
32
 * </p>
 
33
 *
 
34
 * @author <a
 
35
 * href="http://commons.apache.org/configuration/team-list.html">Commons
 
36
 * Configuration team</a>
 
37
 * @version $Id: BaseWebConfiguration.java 1211122 2011-12-06 20:55:45Z oheger $
 
38
 * @since 1.2
 
39
 */
 
40
abstract class BaseWebConfiguration extends AbstractConfiguration
 
41
{
 
42
    /**
 
43
     * Checks if this configuration is empty. This implementation makes use of
 
44
     * the {@code getKeys()} method (which must be defined by concrete
 
45
     * sub classes) to find out whether properties exist.
 
46
     *
 
47
     * @return a flag whether this configuration is empty
 
48
     */
 
49
    public boolean isEmpty()
 
50
    {
 
51
        return !getKeys().hasNext();
 
52
    }
 
53
 
 
54
    /**
 
55
     * Checks whether the specified key is stored in this configuration.
 
56
     *
 
57
     * @param key the key
 
58
     * @return a flag whether this key exists in this configuration
 
59
     */
 
60
    public boolean containsKey(String key)
 
61
    {
 
62
        return getProperty(key) != null;
 
63
    }
 
64
 
 
65
    /**
 
66
     * Removes the property with the given key. <strong>This operation is not
 
67
     * supported and will throw an UnsupportedOperationException.</strong>
 
68
     *
 
69
     * @param key the key of the property to be removed
 
70
     * @throws UnsupportedOperationException because this operation is not
 
71
     * allowed
 
72
     */
 
73
    @Override
 
74
    public void clearProperty(String key)
 
75
    {
 
76
        throw new UnsupportedOperationException("Read only configuration");
 
77
    }
 
78
 
 
79
    /**
 
80
     * Adds a property to this configuration. <strong>This operation is not
 
81
     * supported and will throw an UnsupportedOperationException.</strong>
 
82
     *
 
83
     * @param key the key of the property
 
84
     * @param obj the value to be added
 
85
     * @throws UnsupportedOperationException because this operation is not
 
86
     * allowed
 
87
     */
 
88
    @Override
 
89
    protected void addPropertyDirect(String key, Object obj)
 
90
    {
 
91
        throw new UnsupportedOperationException("Read only configuration");
 
92
    }
 
93
 
 
94
    /**
 
95
     * Takes care of list delimiters in property values. This method checks if
 
96
     * delimiter parsing is enabled and the passed in value contains a delimiter
 
97
     * character. If this is the case, a split operation is performed.
 
98
     *
 
99
     * @param value the property value to be examined
 
100
     * @return the processed value
 
101
     */
 
102
    protected Object handleDelimiters(Object value)
 
103
    {
 
104
        if (!isDelimiterParsingDisabled() && value instanceof String)
 
105
        {
 
106
            List<String> list = PropertyConverter.split((String) value,
 
107
                    getListDelimiter());
 
108
            value = list.size() > 1 ? list : list.get(0);
 
109
        }
 
110
 
 
111
        return value;
 
112
    }
 
113
}