commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ohe...@apache.org
Subject svn commit: r314999 - /jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/web/
Date Wed, 12 Oct 2005 19:02:00 GMT
Author: oheger
Date: Wed Oct 12 12:01:43 2005
New Revision: 314999

URL: http://svn.apache.org/viewcvs?rev=314999&view=rev
Log:
Refactored common code of web configurations into a new base class; Javadoc and Checkstyle

Added:
    jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/web/BaseWebConfiguration.java
  (with props)
Modified:
    jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/web/AppletConfiguration.java
    jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/web/ServletConfiguration.java
    jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/web/ServletContextConfiguration.java
    jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/web/ServletFilterConfiguration.java
    jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/web/ServletRequestConfiguration.java

Modified: jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/web/AppletConfiguration.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/web/AppletConfiguration.java?rev=314999&r1=314998&r2=314999&view=diff
==============================================================================
--- jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/web/AppletConfiguration.java
(original)
+++ jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/web/AppletConfiguration.java
Wed Oct 12 12:01:43 2005
@@ -1,5 +1,5 @@
 /*
- * Copyright 2004 The Apache Software Foundation.
+ * Copyright 2004-2005 The Apache Software Foundation.
  *
  * Licensed under the Apache License, Version 2.0 (the "License")
  * you may not use this file except in compliance with the License.
@@ -21,7 +21,6 @@
 import java.util.List;
 
 import org.apache.commons.collections.iterators.ArrayIterator;
-import org.apache.commons.configuration.AbstractConfiguration;
 import org.apache.commons.configuration.PropertyConverter;
 
 /**
@@ -33,15 +32,16 @@
  * @version $Revision$, $Date$
  * @since 1.1
  */
-public class AppletConfiguration extends AbstractConfiguration
+public class AppletConfiguration extends BaseWebConfiguration
 {
+    /** Stores the wrapped applet.*/
     protected Applet applet;
 
     /**
      * Create an AppletConfiguration using the initialization parameters of
      * the specified Applet.
      *
-     * @param applet
+     * @param applet the applet
      */
     public AppletConfiguration(Applet applet)
     {
@@ -54,38 +54,6 @@
         List list = PropertyConverter.split((String) value, getDelimiter());
 
         return list.size() > 1 ? list : value;
-    }
-
-    /**
-     * <p><strong>This operation is not supported and will throw an
-     * UnsupportedOperationException.</strong></p>
-     *
-     * @throws UnsupportedOperationException
-     */
-    protected void addPropertyDirect(String key, Object obj)
-    {
-        throw new UnsupportedOperationException("Read only configuration");
-    }
-
-    public boolean isEmpty()
-    {
-        return !getKeys().hasNext();
-    }
-
-    public boolean containsKey(String key)
-    {
-        return getProperty(key) != null;
-    }
-
-    /**
-     * <p><strong>This operation is not supported and will throw an
-     * UnsupportedOperationException.</strong></p>
-     *
-     * @throws UnsupportedOperationException
-     */
-    public void clearProperty(String key)
-    {
-        throw new UnsupportedOperationException("Read only configuration");
     }
 
     public Iterator getKeys()

Added: jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/web/BaseWebConfiguration.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/web/BaseWebConfiguration.java?rev=314999&view=auto
==============================================================================
--- jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/web/BaseWebConfiguration.java
(added)
+++ jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/web/BaseWebConfiguration.java
Wed Oct 12 12:01:43 2005
@@ -0,0 +1,85 @@
+/*
+ * Copyright 2004-2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License")
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.configuration.web;
+
+import org.apache.commons.configuration.AbstractConfiguration;
+
+/**
+ * <p>
+ * An abstract base class for all web configurations.
+ * </p>
+ * <p>
+ * This class implements common functionality used by all web based
+ * configurations. E.g. some methods are not supported by configurations of this
+ * type, so they throw a <code>UnsupportedOperationException</code> exception.
+ * </p>
+ *
+ * @author Oliver Heger
+ * @version $Id$
+ * @since 1.2
+ */
+abstract class BaseWebConfiguration extends AbstractConfiguration
+{
+    /**
+     * Checks if this configuration is empty. This implementation makes use of
+     * the <code>getKeys()</code> method (which must be defined by concrete
+     * sub classes) to find out whether properties exist.
+     *
+     * @return a flag whether this configuration is empty
+     */
+    public boolean isEmpty()
+    {
+        return !getKeys().hasNext();
+    }
+
+    /**
+     * Checks whether the specified key is stored in this configuration.
+     *
+     * @param key the key
+     * @return a flag whether this key exists in this configuration
+     */
+    public boolean containsKey(String key)
+    {
+        return getProperty(key) != null;
+    }
+
+    /**
+     * Removes the property with the given key. <strong>This operation is not
+     * supported and will throw an UnsupportedOperationException.</strong>
+     *
+     * @param key the key of the property to be removed
+     * @throws UnsupportedOperationException because this operation is not
+     * allowed
+     */
+    public void clearProperty(String key)
+    {
+        throw new UnsupportedOperationException("Read only configuration");
+    }
+
+    /**
+     * Adds a property to this configuration. <strong>This operation is not
+     * supported and will throw an UnsupportedOperationException.</strong>
+     *
+     * @param key the key of the property
+     * @param obj the value to be added
+     * @throws UnsupportedOperationException because this operation is not
+     * allowed
+     */
+    protected void addPropertyDirect(String key, Object obj)
+    {
+        throw new UnsupportedOperationException("Read only configuration");
+    }
+}

Propchange: jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/web/BaseWebConfiguration.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/web/BaseWebConfiguration.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/web/BaseWebConfiguration.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/web/ServletConfiguration.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/web/ServletConfiguration.java?rev=314999&r1=314998&r2=314999&view=diff
==============================================================================
--- jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/web/ServletConfiguration.java
(original)
+++ jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/web/ServletConfiguration.java
Wed Oct 12 12:01:43 2005
@@ -1,5 +1,5 @@
 /*
- * Copyright 2004 The Apache Software Foundation.
+ * Copyright 2004-2005 The Apache Software Foundation.
  *
  * Licensed under the Apache License, Version 2.0 (the "License")
  * you may not use this file except in compliance with the License.
@@ -22,7 +22,6 @@
 import javax.servlet.ServletConfig;
 
 import org.apache.commons.collections.iterators.EnumerationIterator;
-import org.apache.commons.configuration.AbstractConfiguration;
 import org.apache.commons.configuration.PropertyConverter;
 
 /**
@@ -34,8 +33,9 @@
  * @version $Revision$, $Date$
  * @since 1.1
  */
-public class ServletConfiguration extends AbstractConfiguration
+public class ServletConfiguration extends BaseWebConfiguration
 {
+    /** Stores a reference to the wrapped <code>ServletConfig</code>.*/
     protected ServletConfig config;
 
     /**
@@ -67,41 +67,8 @@
         return list.size() > 1 ? list : value;
     }
 
-    /**
-     * <p><strong>This operation is not supported and will throw an
-     * UnsupportedOperationException.</strong></p>
-     *
-     * @throws UnsupportedOperationException
-     */
-    protected void addPropertyDirect(String key, Object obj)
-    {
-        throw new UnsupportedOperationException("Read only configuration");
-    }
-
-    public boolean isEmpty()
-    {
-        return !getKeys().hasNext();
-    }
-
-    public boolean containsKey(String key)
-    {
-        return getProperty(key) != null;
-    }
-
-    /**
-     * <p><strong>This operation is not supported and will throw an
-     * UnsupportedOperationException.</strong></p>
-     *
-     * @throws UnsupportedOperationException
-     */
-    public void clearProperty(String key)
-    {
-        throw new UnsupportedOperationException("Read only configuration");
-    }
-
     public Iterator getKeys()
     {
         return new EnumerationIterator(config.getInitParameterNames());
     }
-
 }

Modified: jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/web/ServletContextConfiguration.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/web/ServletContextConfiguration.java?rev=314999&r1=314998&r2=314999&view=diff
==============================================================================
--- jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/web/ServletContextConfiguration.java
(original)
+++ jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/web/ServletContextConfiguration.java
Wed Oct 12 12:01:43 2005
@@ -1,5 +1,5 @@
 /*
- * Copyright 2004 The Apache Software Foundation.
+ * Copyright 2004-2005 The Apache Software Foundation.
  *
  * Licensed under the Apache License, Version 2.0 (the "License")
  * you may not use this file except in compliance with the License.
@@ -22,7 +22,6 @@
 import javax.servlet.ServletContext;
 
 import org.apache.commons.collections.iterators.EnumerationIterator;
-import org.apache.commons.configuration.AbstractConfiguration;
 import org.apache.commons.configuration.PropertyConverter;
 
 /**
@@ -34,8 +33,9 @@
  * @version $Revision$, $Date$
  * @since 1.1
  */
-public class ServletContextConfiguration extends AbstractConfiguration
+public class ServletContextConfiguration extends BaseWebConfiguration
 {
+    /** Stores the wrapped servlet context.*/
     protected ServletContext context;
 
     /**
@@ -66,38 +66,6 @@
         List list = PropertyConverter.split((String) value, getDelimiter());
 
         return list.size() > 1 ? list : value;
-    }
-
-    /**
-     * <p><strong>This operation is not supported and will throw an
-     * UnsupportedOperationException.</strong></p>
-     *
-     * @throws UnsupportedOperationException
-     */
-    protected void addPropertyDirect(String key, Object obj)
-    {
-        throw new UnsupportedOperationException("Read only configuration");
-    }
-
-    public boolean isEmpty()
-    {
-        return !getKeys().hasNext();
-    }
-
-    public boolean containsKey(String key)
-    {
-        return getProperty(key) != null;
-    }
-
-    /**
-     * <p><strong>This operation is not supported and will throw an
-     * UnsupportedOperationException.</strong></p>
-     *
-     * @throws UnsupportedOperationException
-     */
-    public void clearProperty(String key)
-    {
-        throw new UnsupportedOperationException("Read only configuration");
     }
 
     public Iterator getKeys()

Modified: jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/web/ServletFilterConfiguration.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/web/ServletFilterConfiguration.java?rev=314999&r1=314998&r2=314999&view=diff
==============================================================================
--- jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/web/ServletFilterConfiguration.java
(original)
+++ jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/web/ServletFilterConfiguration.java
Wed Oct 12 12:01:43 2005
@@ -1,5 +1,5 @@
 /*
- * Copyright 2004 The Apache Software Foundation.
+ * Copyright 2004-2005 The Apache Software Foundation.
  *
  * Licensed under the Apache License, Version 2.0 (the "License")
  * you may not use this file except in compliance with the License.
@@ -21,7 +21,6 @@
 import javax.servlet.FilterConfig;
 
 import org.apache.commons.collections.iterators.EnumerationIterator;
-import org.apache.commons.configuration.AbstractConfiguration;
 import org.apache.commons.configuration.PropertyConverter;
 
 /**
@@ -33,12 +32,15 @@
  * @version $Revision$, $Date$
  * @since 1.1
  */
-public class ServletFilterConfiguration extends AbstractConfiguration
+public class ServletFilterConfiguration extends BaseWebConfiguration
 {
+    /** Stores the wrapped filter config.*/
     protected FilterConfig config;
 
     /**
      * Create a ServletFilterConfiguration using the filter initialization parameters.
+     *
+     * @param config the filter configuration
      */
     public ServletFilterConfiguration(FilterConfig config)
     {
@@ -51,38 +53,6 @@
         List list = PropertyConverter.split((String) value, getDelimiter());
 
         return list.size() > 1 ? list : value;
-    }
-
-    /**
-     * <p><strong>This operation is not supported and will throw an
-     * UnsupportedOperationException.</strong></p>
-     *
-     * @throws UnsupportedOperationException
-     */
-    protected void addPropertyDirect(String key, Object obj)
-    {
-        throw new UnsupportedOperationException("Read only configuration");
-    }
-
-    public boolean isEmpty()
-    {
-        return !getKeys().hasNext();
-    }
-
-    public boolean containsKey(String key)
-    {
-        return getProperty(key) != null;
-    }
-
-    /**
-     * <p><strong>This operation is not supported and will throw an
-     * UnsupportedOperationException.</strong></p>
-     *
-     * @throws UnsupportedOperationException
-     */
-    public void clearProperty(String key)
-    {
-        throw new UnsupportedOperationException("Read only configuration");
     }
 
     public Iterator getKeys()

Modified: jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/web/ServletRequestConfiguration.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/web/ServletRequestConfiguration.java?rev=314999&r1=314998&r2=314999&view=diff
==============================================================================
--- jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/web/ServletRequestConfiguration.java
(original)
+++ jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/web/ServletRequestConfiguration.java
Wed Oct 12 12:01:43 2005
@@ -1,5 +1,5 @@
 /*
- * Copyright 2004 The Apache Software Foundation.
+ * Copyright 2004-2005 The Apache Software Foundation.
  *
  * Licensed under the Apache License, Version 2.0 (the "License")
  * you may not use this file except in compliance with the License.
@@ -21,7 +21,6 @@
 import javax.servlet.ServletRequest;
 
 import org.apache.commons.collections.iterators.EnumerationIterator;
-import org.apache.commons.configuration.AbstractConfiguration;
 
 /**
  * A configuration wrapper to read the parameters of a servlet request. This
@@ -32,8 +31,9 @@
  * @version $Revision$, $Date$
  * @since 1.1
  */
-public class ServletRequestConfiguration extends AbstractConfiguration
+public class ServletRequestConfiguration extends BaseWebConfiguration
 {
+    /** Stores the wrapped request.*/
     protected ServletRequest request;
 
     /**
@@ -48,7 +48,7 @@
 
     public Object getProperty(String key)
     {
-        String values[] = request.getParameterValues(key);
+        String[] values = request.getParameterValues(key);
 
         if (values == null || values.length == 0)
         {
@@ -62,38 +62,6 @@
         {
             return Arrays.asList(values);
         }
-    }
-
-    /**
-     * <p><strong>This operation is not supported and will throw an
-     * UnsupportedOperationException.</strong></p>
-     *
-     * @throws UnsupportedOperationException
-     */
-    protected void addPropertyDirect(String key, Object obj)
-    {
-        throw new UnsupportedOperationException("Read only configuration");
-    }
-
-    public boolean isEmpty()
-    {
-        return !getKeys().hasNext();
-    }
-
-    public boolean containsKey(String key)
-    {
-        return getProperty(key) != null;
-    }
-
-    /**
-     * <p><strong>This operation is not supported and will throw an
-     * UnsupportedOperationException.</strong></p>
-     *
-     * @throws UnsupportedOperationException
-     */
-    public void clearProperty(String key)
-    {
-        throw new UnsupportedOperationException("Read only configuration");
     }
 
     public Iterator getKeys()



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message