| %line | %branch | |||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| org.apache.commons.configuration.web.BaseWebConfiguration |
|
|
| 1 | /* |
|
| 2 | * Copyright 2004-2005 The Apache Software Foundation. |
|
| 3 | * |
|
| 4 | * Licensed under the Apache License, Version 2.0 (the "License") |
|
| 5 | * you may not use this file except in compliance with the License. |
|
| 6 | * You may obtain a copy of the License at |
|
| 7 | * |
|
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
|
| 9 | * |
|
| 10 | * Unless required by applicable law or agreed to in writing, software |
|
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
|
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
| 13 | * See the License for the specific language governing permissions and |
|
| 14 | * limitations under the License. |
|
| 15 | */ |
|
| 16 | package org.apache.commons.configuration.web; |
|
| 17 | ||
| 18 | import org.apache.commons.configuration.AbstractConfiguration; |
|
| 19 | ||
| 20 | /** |
|
| 21 | * <p> |
|
| 22 | * An abstract base class for all web configurations. |
|
| 23 | * </p> |
|
| 24 | * <p> |
|
| 25 | * This class implements common functionality used by all web based |
|
| 26 | * configurations. E.g. some methods are not supported by configurations of this |
|
| 27 | * type, so they throw a <code>UnsupportedOperationException</code> exception. |
|
| 28 | * </p> |
|
| 29 | * |
|
| 30 | * @author Oliver Heger |
|
| 31 | * @version $Id: BaseWebConfiguration.java 314999 2005-10-12 19:01:43Z oheger $ |
|
| 32 | * @since 1.2 |
|
| 33 | */ |
|
| 34 | 120 | abstract class BaseWebConfiguration extends AbstractConfiguration |
| 35 | { |
|
| 36 | /** |
|
| 37 | * Checks if this configuration is empty. This implementation makes use of |
|
| 38 | * the <code>getKeys()</code> method (which must be defined by concrete |
|
| 39 | * sub classes) to find out whether properties exist. |
|
| 40 | * |
|
| 41 | * @return a flag whether this configuration is empty |
|
| 42 | */ |
|
| 43 | public boolean isEmpty() |
|
| 44 | { |
|
| 45 | 30 | return !getKeys().hasNext(); |
| 46 | } |
|
| 47 | ||
| 48 | /** |
|
| 49 | * Checks whether the specified key is stored in this configuration. |
|
| 50 | * |
|
| 51 | * @param key the key |
|
| 52 | * @return a flag whether this key exists in this configuration |
|
| 53 | */ |
|
| 54 | public boolean containsKey(String key) |
|
| 55 | { |
|
| 56 | 30 | return getProperty(key) != null; |
| 57 | } |
|
| 58 | ||
| 59 | /** |
|
| 60 | * Removes the property with the given key. <strong>This operation is not |
|
| 61 | * supported and will throw an UnsupportedOperationException.</strong> |
|
| 62 | * |
|
| 63 | * @param key the key of the property to be removed |
|
| 64 | * @throws UnsupportedOperationException because this operation is not |
|
| 65 | * allowed |
|
| 66 | */ |
|
| 67 | public void clearProperty(String key) |
|
| 68 | { |
|
| 69 | 15 | throw new UnsupportedOperationException("Read only configuration"); |
| 70 | } |
|
| 71 | ||
| 72 | /** |
|
| 73 | * Adds a property to this configuration. <strong>This operation is not |
|
| 74 | * supported and will throw an UnsupportedOperationException.</strong> |
|
| 75 | * |
|
| 76 | * @param key the key of the property |
|
| 77 | * @param obj the value to be added |
|
| 78 | * @throws UnsupportedOperationException because this operation is not |
|
| 79 | * allowed |
|
| 80 | */ |
|
| 81 | protected void addPropertyDirect(String key, Object obj) |
|
| 82 | { |
|
| 83 | 15 | throw new UnsupportedOperationException("Read only configuration"); |
| 84 | } |
|
| 85 | } |
| This report is generated by jcoverage, Maven and Maven JCoverage Plugin. |