[jboss-cvs] jboss-portal/portlet/src/main/org/jboss/portal/portlet/state ...

Julien Viet julien at jboss.com
Tue Aug 22 10:08:53 EDT 2006


  User: julien  
  Date: 06/08/22 10:08:53

  Modified:    portlet/src/main/org/jboss/portal/portlet/state    
                        AbstractPropertyContext.java
  Added:       portlet/src/main/org/jboss/portal/portlet/state    
                        AbstractPropertyMap.java PropertyMap.java
                        SimplePropertyMap.java
  Log:
  - refactored the ValueMap to PropertyMap and moved it in org.jboss.portal.portlet.state package
  - introduced TypedMap that is super type of ParameterMap and is reused for the PropertyMap
  
  Revision  Changes    Path
  1.4       +10 -11    jboss-portal/portlet/src/main/org/jboss/portal/portlet/state/AbstractPropertyContext.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: AbstractPropertyContext.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-portal/portlet/src/main/org/jboss/portal/portlet/state/AbstractPropertyContext.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -b -r1.3 -r1.4
  --- AbstractPropertyContext.java	30 Jul 2006 12:36:23 -0000	1.3
  +++ AbstractPropertyContext.java	22 Aug 2006 14:08:53 -0000	1.4
  @@ -23,16 +23,15 @@
   
   import org.jboss.portal.portlet.info.PreferencesInfo;
   import org.jboss.portal.portlet.info.PreferenceInfo;
  -import org.jboss.portal.common.value.ValueMap;
  +import org.jboss.portal.portlet.state.PropertyMap;
   import org.jboss.portal.common.value.Value;
  -import org.jboss.portal.common.value.SimpleValueMap;
   
   import java.util.Set;
   import java.util.Collections;
   
   /**
    * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
  - * @version $Revision: 1.3 $
  + * @version $Revision: 1.4 $
    */
   public class AbstractPropertyContext implements PropertyContext
   {
  @@ -47,7 +46,7 @@
      public static final int UPDATE_SUCCEDED = 2;
   
      /** The user prefs. */
  -   private ValueMap prefs;
  +   private PropertyMap prefs;
   
      /** The runtime preferences info for the system. */
      private PreferencesInfo portletPrefs;
  @@ -66,7 +65,7 @@
       * @param portletPrefs the portlet prefs
       * @throws IllegalArgumentException if the portletPrefs are null
       */
  -   public AbstractPropertyContext(AccessMode access, ValueMap userPrefs, PreferencesInfo portletPrefs) throws IllegalArgumentException
  +   public AbstractPropertyContext(AccessMode access, PropertyMap userPrefs, PreferencesInfo portletPrefs) throws IllegalArgumentException
      {
         if (access == null)
         {
  @@ -95,11 +94,11 @@
            {
               if (prefs == null)
               {
  -               prefs = new SimpleValueMap();
  +               prefs = new SimplePropertyMap();
               }
               else
               {
  -               prefs = new SimpleValueMap(prefs);
  +               prefs = new SimplePropertyMap(prefs);
               }
            }
   
  @@ -107,7 +106,7 @@
            for (int i = 0; i < changes.length; i++)
            {
               PropertyChange change = changes[i];
  -            prefs.setValue(change.getKey(), change.getValue());
  +            prefs.setProperty(change.getKey(), change.getValue());
            }
            status = UPDATE_SUCCEDED;
         }
  @@ -119,7 +118,7 @@
         {
            return Collections.EMPTY_SET;
         }
  -      return prefs.getKeys();
  +      return prefs.keySet();
      }
   
      public Value getValue(String key) throws IllegalArgumentException
  @@ -128,7 +127,7 @@
         {
            return null;
         }
  -      return prefs.getValue(key);
  +      return prefs.getProperty(key);
      }
   
      public Set getPortletKeys() throws IllegalArgumentException
  @@ -161,7 +160,7 @@
         return access == AccessMode.READ_ONLY;
      }
   
  -   public ValueMap getPrefs()
  +   public PropertyMap getPrefs()
      {
         return prefs;
      }
  
  
  
  1.1      date: 2006/08/22 14:08:53;  author: julien;  state: Exp;jboss-portal/portlet/src/main/org/jboss/portal/portlet/state/AbstractPropertyMap.java
  
  Index: AbstractPropertyMap.java
  ===================================================================
  /*
  * JBoss, Home of Professional Open Source
  * Copyright 2005, JBoss Inc., and individual contributors as indicated
  * by the @authors tag. See the copyright.txt in the distribution for a
  * full listing of individual contributors.
  *
  * This is free software; you can redistribute it and/or modify it
  * under the terms of the GNU Lesser General Public License as
  * published by the Free Software Foundation; either version 2.1 of
  * the License, or (at your option) any later version.
  *
  * This software is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  * Lesser General Public License for more details.
  *
  * You should have received a copy of the GNU Lesser General Public
  * License along with this software; if not, write to the Free
  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
  */
  package org.jboss.portal.portlet.state;
  
  import org.jboss.portal.common.util.TypedMap;
  import org.jboss.portal.common.value.Value;
  
  /**
   * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
   * @version $Revision: 1.1 $
   */
  public abstract class AbstractPropertyMap extends TypedMap implements PropertyMap
  {
  
     /** The serialVersionUID */
     private static final long serialVersionUID = -5889928820592375820L;
  
     protected void assertKeyValidity(Object value)
     {
        if (!(value instanceof String))
        {
           throw new IllegalArgumentException("Key should be a String");
        }
     }
  
     protected Object getInternalValue(Object value)
     {
        if (!(value instanceof Value))
        {
           throw new IllegalArgumentException("Value should be a Value");
        }
        return value;
     }
  
     protected Object getExternalValue(Object value)
     {
        return value;
     }
  
     public Value getProperty(String key) throws IllegalArgumentException
     {
        if (key == null)
        {
           throw new IllegalArgumentException("No null key accepted");
        }
        return (Value)get(key);
     }
  
     public void setProperty(String key, Value value) throws IllegalArgumentException, UnsupportedOperationException
     {
        if (key == null)
        {
           throw new IllegalArgumentException("No null key accepted");
        }
        if (value != null)
        {
           put(key, value);
        }
        else
        {
           remove(key);
        }
     }
  }
  
  
  
  1.1      date: 2006/08/22 14:08:53;  author: julien;  state: Exp;jboss-portal/portlet/src/main/org/jboss/portal/portlet/state/PropertyMap.java
  
  Index: PropertyMap.java
  ===================================================================
  /*
  * JBoss, Home of Professional Open Source
  * Copyright 2005, JBoss Inc., and individual contributors as indicated
  * by the @authors tag. See the copyright.txt in the distribution for a
  * full listing of individual contributors.
  *
  * This is free software; you can redistribute it and/or modify it
  * under the terms of the GNU Lesser General Public License as
  * published by the Free Software Foundation; either version 2.1 of
  * the License, or (at your option) any later version.
  *
  * This software is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  * Lesser General Public License for more details.
  *
  * You should have received a copy of the GNU Lesser General Public
  * License along with this software; if not, write to the Free
  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
  */
  package org.jboss.portal.portlet.state;
  
  import org.jboss.portal.common.value.Value;
  
  import java.util.Set;
  import java.util.Map;
  
  /**
   * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
   * @version $Revision: 1.1 $
   */
  public interface PropertyMap extends Map
  {
     /**
      * Return the value for the given key or null if it does not exist.
      *
      * @param key the requested key
      * @return the requested value or null if it does not exist
      * @throws IllegalArgumentException if the key is null
      */
     Value getProperty(String key) throws IllegalArgumentException;
  
     /**
      * Update the value of the given key. If the value object is null
      * it means that the entry must be removed. Implementation can throw
      * an unsupported operation exception when it is abnormal to perform an update.
      *
      * @param key the key to update
      * @param value the new value
      * @throws UnsupportedOperationException if the operation is not supported
      * @throws IllegalArgumentException if the key is null
      */
     void setProperty(String key, Value value) throws IllegalArgumentException, UnsupportedOperationException;
  }
  
  
  
  1.1      date: 2006/08/22 14:08:53;  author: julien;  state: Exp;jboss-portal/portlet/src/main/org/jboss/portal/portlet/state/SimplePropertyMap.java
  
  Index: SimplePropertyMap.java
  ===================================================================
  /*
  * JBoss, Home of Professional Open Source
  * Copyright 2005, JBoss Inc., and individual contributors as indicated
  * by the @authors tag. See the copyright.txt in the distribution for a
  * full listing of individual contributors.
  *
  * This is free software; you can redistribute it and/or modify it
  * under the terms of the GNU Lesser General Public License as
  * published by the Free Software Foundation; either version 2.1 of
  * the License, or (at your option) any later version.
  *
  * This software is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  * Lesser General Public License for more details.
  *
  * You should have received a copy of the GNU Lesser General Public
  * License along with this software; if not, write to the Free
  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
  */
  package org.jboss.portal.portlet.state;
  
  import java.util.Map;
  import java.util.HashMap;
  
  /**
   * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
   * @version $Revision: 1.1 $
   */
  public class SimplePropertyMap extends AbstractPropertyMap
  {
  
     /** The serialVersionUID */
     private static final long serialVersionUID = -5889928820592375820L;
  
     protected Map getDelegate()
     {
        return values;
     }
  
     /** . */
     protected final Map values;
  
     public SimplePropertyMap()
     {
        this(new HashMap());
     }
  
     public SimplePropertyMap(PropertyMap that)
     {
        this();
        if (that == null)
        {
           throw new IllegalArgumentException();
        }
        putAll(that);
     }
  
     public SimplePropertyMap(Map map)
     {
        if (map == null)
        {
           throw new IllegalArgumentException();
        }
        this.values = map;
     }
  }
  
  
  



More information about the jboss-cvs-commits mailing list