[jboss-cvs] jboss-portal/common/src/main/org/jboss/portal/common/util ...

Julien Viet julien at jboss.com
Sun Jul 30 20:05:39 EDT 2006


  User: julien  
  Date: 06/07/30 20:05:39

  Modified:    common/src/main/org/jboss/portal/common/util 
                        ParameterMap.java
  Log:
  - Make Parameters extend ParameterMap
  
  Revision  Changes    Path
  1.3       +22 -33    jboss-portal/common/src/main/org/jboss/portal/common/util/ParameterMap.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: ParameterMap.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-portal/common/src/main/org/jboss/portal/common/util/ParameterMap.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -b -r1.2 -r1.3
  --- ParameterMap.java	30 Jul 2006 21:54:57 -0000	1.2
  +++ ParameterMap.java	31 Jul 2006 00:05:39 -0000	1.3
  @@ -30,29 +30,14 @@
    * A decorator that enforce the map content to be <String,String[]>
    *
    * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
  - * @version $Revision: 1.2 $
  + * @version $Revision: 1.3 $
    */
  -public class ParameterMap implements Map
  +public abstract class ParameterMap implements Map
   {
   
  -   private Map delegate;
  +   protected abstract Map getDelegate();
   
  -   public ParameterMap(Map delegate)
  -   {
  -      if (delegate == null)
  -      {
  -         throw new IllegalArgumentException();
  -      }
  -      for (Iterator i = delegate.entrySet().iterator(); i.hasNext();)
  -      {
  -         Entry entry = (Entry)i.next();
  -         assertKey(entry.getKey());
  -         assertValue(entry.getValue());
  -      }
  -      this.delegate = delegate;
  -   }
  -
  -   private void assertKey(Object value)
  +   protected void assertKey(Object value)
      {
         if (!(value instanceof String))
         {
  @@ -60,14 +45,18 @@
         }
      }
   
  -   private void assertValue(Object value)
  +   protected void assertValue(Object value)
      {
         if (!(value instanceof String[]))
         {
            throw new IllegalArgumentException("Value should be a String[]");
         }
         String[] strings = (String[])value;
  -      for (int i = 0; i < strings.length; i++)
  +      if (strings.length == 0)
  +      {
  +         throw new IllegalArgumentException("Array must not be zero length");
  +      }
  +      for (int i = strings.length - 1;i >= 0;i--)
         {
            if (strings[i] == null)
            {
  @@ -78,32 +67,32 @@
   
      public int size()
      {
  -      return delegate.size();
  +      return getDelegate().size();
      }
   
      public void clear()
      {
  -      delegate.clear();
  +      getDelegate().clear();
      }
   
      public boolean isEmpty()
      {
  -      return delegate.isEmpty();
  +      return getDelegate().isEmpty();
      }
   
      public boolean containsKey(Object key)
      {
  -      return delegate.containsKey(key);
  +      return getDelegate().containsKey(key);
      }
   
      public boolean containsValue(Object value)
      {
  -      return delegate.containsValue(value);
  +      return getDelegate().containsValue(value);
      }
   
      public Collection values()
      {
  -      return delegate.values();
  +      return getDelegate().values();
      }
   
      public void putAll(Map t)
  @@ -114,34 +103,34 @@
            assertKey(entry.getKey());
            assertValue(entry.getValue());
         }
  -      delegate.putAll(t);
  +      getDelegate().putAll(t);
      }
   
      public Set entrySet()
      {
  -      return new ParameterEntrySet(delegate.entrySet());
  +      return new ParameterEntrySet(getDelegate().entrySet());
      }
   
      public Set keySet()
      {
  -      return delegate.keySet();
  +      return getDelegate().keySet();
      }
   
      public Object get(Object key)
      {
  -      return delegate.get(key);
  +      return getDelegate().get(key);
      }
   
      public Object remove(Object key)
      {
  -      return delegate.remove(key);
  +      return getDelegate().remove(key);
      }
   
      public Object put(Object key, Object value)
      {
         assertKey(key);
         assertValue(value);
  -      return delegate.put(key, value);
  +      return getDelegate().put(key, value);
      }
   
      public class ParameterEntrySet implements Set
  
  
  



More information about the jboss-cvs-commits mailing list