You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by so...@apache.org on 2007/11/21 01:19:56 UTC

svn commit: r596889 [2/2] - in /myfaces/portlet-bridge/trunk: api/src/main/java/javax/portlet/faces/ impl/src/main/java/org/apache/myfaces/portlet/faces/application/ impl/src/main/java/org/apache/myfaces/portlet/faces/bridge/ impl/src/main/java/org/apa...

Copied: myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/util/map/EnumerationIterator.java (from r596788, myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/util/map/LocalesIterator.java)
URL: http://svn.apache.org/viewvc/myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/util/map/EnumerationIterator.java?p2=myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/util/map/EnumerationIterator.java&p1=myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/util/map/LocalesIterator.java&r1=596788&r2=596889&rev=596889&view=diff
==============================================================================
--- myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/util/map/LocalesIterator.java (original)
+++ myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/util/map/EnumerationIterator.java Tue Nov 20 16:19:55 2007
@@ -22,27 +22,35 @@
 import java.util.Enumeration;
 import java.util.Iterator;
 
-public class LocalesIterator implements Iterator
+public class EnumerationIterator<T extends Object> implements Iterator<T>, Iterable<T>
 {
-  private Enumeration mLocales;
+  private Enumeration<T> mEnumeration;
 
-  public LocalesIterator(Enumeration locales)
+  public EnumerationIterator(Enumeration<T> enumeration)
   {
-    mLocales = locales;
+    mEnumeration = enumeration;
   }
 
   public boolean hasNext()
   {
-    return mLocales.hasMoreElements();
+    return mEnumeration.hasMoreElements();
   }
 
-  public Object next()
+  public T next()
   {
-    return mLocales.nextElement();
+    return mEnumeration.nextElement();
   }
 
   public void remove()
   {
     throw new UnsupportedOperationException();
   }
+
+  /**
+   * This makes java5 style for-looping much easier.
+   */
+	public Iterator<T> iterator()
+	{
+		return this;
+	}
 }

Modified: myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/util/map/PortletAbstractMap.java
URL: http://svn.apache.org/viewvc/myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/util/map/PortletAbstractMap.java?rev=596889&r1=596888&r2=596889&view=diff
==============================================================================
--- myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/util/map/PortletAbstractMap.java (original)
+++ myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/util/map/PortletAbstractMap.java Tue Nov 20 16:19:55 2007
@@ -14,7 +14,6 @@
  * KIND, either express or implied.  See the License for the
  * specific language governing permissions and limitations
  * under the License.
- *
  */
 
 package org.apache.myfaces.portlet.faces.util.map;
@@ -32,25 +31,25 @@
 /**
  * Helper class for different portlet external context maps
  */
-public abstract class PortletAbstractMap implements Map
+public abstract class PortletAbstractMap<V> implements Map<String, V>
 {
   static final String ILLEGAL_ARGUMENT = "Only supported in a portlet environment";
 
-  private Set         mKeySet;
-  private Collection  mValues;
-  private Set         mEntrySet;
+  private Set<String> mKeySet;
+  private Collection<V> mValues;
+  private Set<Entry<String, V>> mEntrySet;
 
   public void clear()
   {
-    List names = new ArrayList();
-    for (Enumeration e = getAttributeNames(); e.hasMoreElements();)
+    List<String> names = new ArrayList<String>();
+    for (Enumeration<String> e = getAttributeNames(); e.hasMoreElements();)
     {
       names.add(e.nextElement());
     }
 
-    for (Iterator it = names.iterator(); it.hasNext();)
+    for (String name : names)
     {
-      removeAttribute((String) it.next());
+      removeAttribute(name);
     }
   }
 
@@ -66,9 +65,9 @@
       return false;
     }
 
-    for (Enumeration e = getAttributeNames(); e.hasMoreElements();)
+    for (Enumeration<String> e = getAttributeNames(); e.hasMoreElements();)
     {
-      Object value = getAttribute((String) e.nextElement());
+      Object value = getAttribute(e.nextElement());
       if (findValue.equals(value))
       {
         return true;
@@ -78,12 +77,12 @@
     return false;
   }
 
-  public Set entrySet()
+  public Set<Entry<String, V>> entrySet()
   {
     return mEntrySet != null ? mEntrySet : (mEntrySet = new EntrySet());
   }
 
-  public Object get(Object key)
+  public V get(Object key)
   {
     return getAttribute(key.toString());
   }
@@ -93,32 +92,31 @@
     return !getAttributeNames().hasMoreElements();
   }
 
-  public Set keySet()
+  public Set<String> keySet()
   {
     return mKeySet != null ? mKeySet : (mKeySet = new KeySet());
   }
 
-  public Object put(Object key, Object value)
+  public V put(String key, V value)
   {
     String localKey = key.toString();
-    Object retval = getAttribute(localKey);
+    V retval = getAttribute(localKey);
     setAttribute(localKey, value);
     return retval;
   }
-
-  public void putAll(Map t)
+  
+  public void putAll(Map<? extends String, ? extends V> t)
   {
-    for (Iterator it = t.entrySet().iterator(); it.hasNext();)
+    for (Entry<? extends String, ? extends V> entry : t.entrySet())
     {
-      Entry entry = (Entry) it.next();
-      setAttribute(entry.getKey().toString(), entry.getValue());
+      setAttribute(entry.getKey(), entry.getValue());
     }
   }
 
-  public Object remove(Object key)
+  public V remove(Object key)
   {
     String localKey = key.toString();
-    Object retval = getAttribute(localKey);
+    V retval = getAttribute(localKey);
     removeAttribute(localKey);
     return retval;
   }
@@ -126,47 +124,45 @@
   public int size()
   {
     int size = 0;
-    for (Enumeration e = getAttributeNames(); e.hasMoreElements();)
+    for (Enumeration<String> e = getAttributeNames(); e.hasMoreElements();)
     {
       size++;
       e.nextElement();
     }
+    
     return size;
   }
 
-  public Collection values()
+  public Collection<V> values()
   {
     return mValues != null ? mValues : (mValues = new Values());
   }
 
-  protected abstract Object getAttribute(String key);
+  protected abstract V getAttribute(String key);
 
-  protected abstract void setAttribute(String key, Object value);
+  protected abstract void setAttribute(String key, V value);
 
   protected abstract void removeAttribute(String key);
 
-  protected abstract Enumeration getAttributeNames();
-
-  private class KeySet extends AbstractSet
+  protected abstract Enumeration<String> getAttributeNames();
+  
+  private abstract class BaseMapContentSet<T> extends AbstractSet<T>
   {
     @Override
-    public Iterator iterator()
-    {
-      return new KeyIterator();
-    }
-
-    @Override
-    public boolean isEmpty()
+    public void clear()
     {
-      return PortletAbstractMap.this.isEmpty();
+      PortletAbstractMap.this.clear();
     }
-
+    
     @Override
     public int size()
     {
       return PortletAbstractMap.this.size();
     }
+  }
 
+  private class KeySet extends BaseMapContentSet<String>
+  {
     @Override
     public boolean contains(Object o)
     {
@@ -174,22 +170,22 @@
     }
 
     @Override
-    public boolean remove(Object o)
+    public Iterator<String> iterator()
     {
-      return PortletAbstractMap.this.remove(o) != null;
+      return new KeyIterator();
     }
 
     @Override
-    public void clear()
+    public boolean remove(Object o)
     {
-      PortletAbstractMap.this.clear();
+      return PortletAbstractMap.this.remove(o) != null;
     }
   }
 
-  private class KeyIterator implements Iterator
+  private class KeyIterator implements Iterator<String>
   {
-    protected final Enumeration mEnum = getAttributeNames();
-    protected Object            mKey;
+    protected final Enumeration<String> mEnum = getAttributeNames();
+    protected String mKey;
 
     public void remove()
     {
@@ -197,6 +193,7 @@
       {
         throw new NoSuchElementException();
       }
+      
       PortletAbstractMap.this.remove(mKey);
     }
 
@@ -205,20 +202,40 @@
       return mEnum.hasMoreElements();
     }
 
-    public Object next()
+    public String next()
     {
       return mKey = mEnum.nextElement();
     }
   }
-
-  private class Values extends KeySet
+  
+  private abstract class KeyIteratorWrapper<T> implements Iterator<T>
   {
-    @Override
-    public Iterator iterator()
+    private KeyIterator wrapped;
+    
+    protected KeyIteratorWrapper()
     {
-      return new ValuesIterator();
+      wrapped = new KeyIterator();
+    }
+    
+    public boolean hasNext()
+    {
+      return wrapped.hasNext();
     }
 
+    protected String nextKey()
+    {
+      return wrapped.next();
+    }
+
+    public void remove()
+    {
+      wrapped.remove();
+    }
+    
+  }
+
+  private class Values extends BaseMapContentSet<V>
+  {
     @Override
     public boolean contains(Object o)
     {
@@ -226,6 +243,12 @@
     }
 
     @Override
+    public Iterator<V> iterator()
+    {
+      return new ValuesIterator();
+    }
+
+    @Override
     public boolean remove(Object o)
     {
       if (o == null)
@@ -233,7 +256,7 @@
         return false;
       }
 
-      for (Iterator it = iterator(); it.hasNext();)
+      for (Iterator<V> it = iterator(); it.hasNext();)
       {
         if (o.equals(it.next()))
         {
@@ -246,24 +269,23 @@
     }
   }
 
-  private class ValuesIterator extends KeyIterator
+  private class ValuesIterator extends KeyIteratorWrapper<V>
   {
-    @Override
-    public Object next()
+    public V next()
     {
-      super.next();
-      return get(mKey);
+      return get(nextKey());
     }
   }
 
-  private class EntrySet extends KeySet
+  private class EntrySet extends BaseMapContentSet<Entry<String, V>>
   {
     @Override
-    public Iterator iterator()
+    public Iterator<Entry<String, V>> iterator()
     {
       return new EntryIterator();
     }
 
+    @SuppressWarnings("unchecked")
     @Override
     public boolean contains(Object o)
     {
@@ -272,7 +294,7 @@
         return false;
       }
 
-      Entry entry = (Entry) o;
+      Entry<String, V> entry = (Entry<String, V>)o;
       Object key = entry.getKey();
       Object value = entry.getValue();
       if (key == null || value == null)
@@ -283,6 +305,7 @@
       return value.equals(get(key));
     }
 
+    @SuppressWarnings("unchecked")
     @Override
     public boolean remove(Object o)
     {
@@ -291,7 +314,7 @@
         return false;
       }
 
-      Entry entry = (Entry) o;
+      Entry<String, V> entry = (Entry<String, V>) o;
       Object key = entry.getKey();
       Object value = entry.getValue();
       if (key == null || value == null || !value.equals(get(key)))
@@ -299,40 +322,38 @@
         return false;
       }
 
-      return PortletAbstractMap.this.remove(((Entry) o).getKey()) != null;
+      return PortletAbstractMap.this.remove(key) != null;
     }
   }
 
-  private class EntryIterator extends KeyIterator
+  private class EntryIterator extends KeyIteratorWrapper<Entry<String, V>>
   {
-    @Override
-    public Object next()
+    public Entry<String, V> next()
     {
-      super.next();
-      return new EntrySetEntry(mKey);
+      return new EntrySetEntry(nextKey());
     }
   }
 
-  private class EntrySetEntry implements Entry
+  private class EntrySetEntry implements Entry<String, V>
   {
-    private final Object mKey;
+    private final String mKey;
 
-    public EntrySetEntry(Object currentKey)
+    public EntrySetEntry(String currentKey)
     {
       mKey = currentKey;
     }
 
-    public Object getKey()
+    public String getKey()
     {
       return mKey;
     }
 
-    public Object getValue()
+    public V getValue()
     {
       return get(mKey);
     }
 
-    public Object setValue(Object value)
+    public V setValue(V value)
     {
       return put(mKey, value);
     }

Modified: myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/util/map/PortletApplicationMap.java
URL: http://svn.apache.org/viewvc/myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/util/map/PortletApplicationMap.java?rev=596889&r1=596888&r2=596889&view=diff
==============================================================================
--- myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/util/map/PortletApplicationMap.java (original)
+++ myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/util/map/PortletApplicationMap.java Tue Nov 20 16:19:55 2007
@@ -26,7 +26,7 @@
 /**
  * Map of portlet context attributes
  */
-public class PortletApplicationMap extends PortletAbstractMap
+public class PortletApplicationMap extends PortletAbstractMap<Object>
 {
   private final PortletContext mPortletContext;
 
@@ -73,8 +73,9 @@
     }
   }
 
+  @SuppressWarnings("unchecked")
   @Override
-  public Enumeration getAttributeNames()
+  public Enumeration<String> getAttributeNames()
   {
     if (mPortletContext != null)
     {

Modified: myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/util/map/PortletInitParameterMap.java
URL: http://svn.apache.org/viewvc/myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/util/map/PortletInitParameterMap.java?rev=596889&r1=596888&r2=596889&view=diff
==============================================================================
--- myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/util/map/PortletInitParameterMap.java (original)
+++ myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/util/map/PortletInitParameterMap.java Tue Nov 20 16:19:55 2007
@@ -26,7 +26,7 @@
 /**
  * Map of portlet context init params
  */
-public class PortletInitParameterMap extends PortletAbstractMap
+public class PortletInitParameterMap extends PortletAbstractMap<String>
 {
   private final PortletContext mPortletContext;
 
@@ -43,7 +43,7 @@
   }
 
   @Override
-  public Object getAttribute(String key)
+  public String getAttribute(String key)
   {
     if (mPortletContext != null)
     {
@@ -56,7 +56,7 @@
   }
 
   @Override
-  public void setAttribute(String key, Object value)
+  public void setAttribute(String key, String value)
   {
     throw new UnsupportedOperationException();
   }
@@ -67,8 +67,9 @@
     throw new UnsupportedOperationException();
   }
 
+  @SuppressWarnings("unchecked")
   @Override
-  public Enumeration getAttributeNames()
+  public Enumeration<String> getAttributeNames()
   {
     if (mPortletContext != null)
     {

Modified: myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/util/map/PortletRequestHeaderMap.java
URL: http://svn.apache.org/viewvc/myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/util/map/PortletRequestHeaderMap.java?rev=596889&r1=596888&r2=596889&view=diff
==============================================================================
--- myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/util/map/PortletRequestHeaderMap.java (original)
+++ myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/util/map/PortletRequestHeaderMap.java Tue Nov 20 16:19:55 2007
@@ -14,7 +14,6 @@
  * KIND, either express or implied.  See the License for the
  * specific language governing permissions and limitations
  * under the License.
- *
  */
 
 package org.apache.myfaces.portlet.faces.util.map;
@@ -24,7 +23,7 @@
 /**
  * Map of portlet request headers
  */
-public class PortletRequestHeaderMap extends PortletAbstractMap
+public class PortletRequestHeaderMap extends PortletAbstractMap<String>
 {
   private final PortletRequestHeaders mPortletRequestHeaders;
 
@@ -34,13 +33,13 @@
   }
 
   @Override
-  protected Object getAttribute(String key)
+  protected String getAttribute(String key)
   {
     return mPortletRequestHeaders.getHeader(key);
   }
 
   @Override
-  protected void setAttribute(String key, Object value)
+  protected void setAttribute(String key, String value)
   {
     throw new UnsupportedOperationException();
   }
@@ -51,8 +50,9 @@
     throw new UnsupportedOperationException();
   }
 
+  @SuppressWarnings("unchecked")
   @Override
-  protected Enumeration getAttributeNames()
+  protected Enumeration<String> getAttributeNames()
   {
     return mPortletRequestHeaders.getHeaderNames();
   }

Modified: myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/util/map/PortletRequestHeaderValuesMap.java
URL: http://svn.apache.org/viewvc/myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/util/map/PortletRequestHeaderValuesMap.java?rev=596889&r1=596888&r2=596889&view=diff
==============================================================================
--- myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/util/map/PortletRequestHeaderValuesMap.java (original)
+++ myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/util/map/PortletRequestHeaderValuesMap.java Tue Nov 20 16:19:55 2007
@@ -14,7 +14,6 @@
  * KIND, either express or implied.  See the License for the
  * specific language governing permissions and limitations
  * under the License.
- *
  */
 
 package org.apache.myfaces.portlet.faces.util.map;
@@ -28,10 +27,10 @@
 /**
  * Map of portlet request header values
  */
-public class PortletRequestHeaderValuesMap extends PortletAbstractMap
+public class PortletRequestHeaderValuesMap extends PortletAbstractMap<String[]>
 {
   private final PortletRequestHeaders mPortletRequestHeaders;
-  private final Map                   mValueCache = new HashMap();
+  private final Map<String, String[]> mValueCache = new HashMap<String, String[]>();
 
   public PortletRequestHeaderValuesMap(PortletRequestHeaders portletRequestHeaders)
   {
@@ -39,9 +38,9 @@
   }
 
   @Override
-  protected Object getAttribute(String key)
+  protected String[] getAttribute(String key)
   {
-    Object ret = mValueCache.get(key);
+    String[] ret = mValueCache.get(key);
     if (ret == null)
     {
       mValueCache.put(key, ret = toArray(mPortletRequestHeaders.getHeaders(key)));
@@ -50,7 +49,7 @@
   }
 
   @Override
-  protected void setAttribute(String key, Object value)
+  protected void setAttribute(String key, String[] value)
   {
     throw new UnsupportedOperationException();
   }
@@ -60,22 +59,22 @@
   {
     throw new UnsupportedOperationException("");
   }
-
+  
   @Override
-  protected Enumeration getAttributeNames()
+  protected Enumeration<String> getAttributeNames()
   {
     return mPortletRequestHeaders.getHeaderNames();
   }
 
-  private String[] toArray(Enumeration e)
+  private String[] toArray(Enumeration<String> e)
   {
-    List ret = new ArrayList();
+    List<String> ret = new ArrayList<String>();
 
     while (e.hasMoreElements())
     {
       ret.add(e.nextElement());
     }
 
-    return (String[]) ret.toArray(new String[ret.size()]);
+    return ret.toArray(new String[ret.size()]);
   }
 }

Modified: myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/util/map/PortletRequestHeaders.java
URL: http://svn.apache.org/viewvc/myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/util/map/PortletRequestHeaders.java?rev=596889&r1=596888&r2=596889&view=diff
==============================================================================
--- myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/util/map/PortletRequestHeaders.java (original)
+++ myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/util/map/PortletRequestHeaders.java Tue Nov 20 16:19:55 2007
@@ -14,55 +14,59 @@
  * KIND, either express or implied.  See the License for the
  * specific language governing permissions and limitations
  * under the License.
- *
  */
 
 package org.apache.myfaces.portlet.faces.util.map;
 
-import javax.portlet.PortletRequest;
-
 import java.util.ArrayList;
+import java.util.Collections;
 import java.util.Enumeration;
 import java.util.HashMap;
-import java.util.Map;
 import java.util.List;
-import java.util.Collections;
-import java.util.Iterator;
 import java.util.Locale;
+import java.util.Map;
 
 import javax.portlet.ActionRequest;
+import javax.portlet.PortletRequest;
 import javax.portlet.faces.Bridge;
 
 public class PortletRequestHeaders
 {
   private PortletRequest mPortletRequest = null;
-  private List           mHeaderNames    = null;
-  private Map            mHeaders        = null;
+  private List<String> mHeaderNames = null;
+  private Map<String, List<String>> mHeaders = null;
 
   public PortletRequestHeaders(PortletRequest request)
   {
     mPortletRequest = request;
   }
 
-  public java.lang.String getHeader(java.lang.String name)
+  @SuppressWarnings("unchecked")
+  public String getHeader(String name)
   {
     // initialize the header map if it hasn't been already
     initHeaderMap();
 
-    List headerVals = (List) mHeaders.get(name.toUpperCase());
+    List<String> headerVals = mHeaders.get(name.toUpperCase());
     return headerVals == null ? null : (String) headerVals.get(0);
   }
 
-  public java.util.Enumeration getHeaders(java.lang.String name)
+  public Enumeration<String> getHeaders(String name)
   {
     // initialize the header map if it hasn't been already
     initHeaderMap();
 
-    List headerVals = (List) mHeaders.get(name.toUpperCase());
-    return Collections.enumeration(headerVals == null ? Collections.EMPTY_LIST : headerVals);
+    List<String> headerVals = mHeaders.get(name.toUpperCase());
+    
+    if (headerVals == null)
+    {
+      headerVals = Collections.emptyList();
+    }
+    
+    return Collections.enumeration(headerVals);
   }
 
-  public java.util.Enumeration getHeaderNames()
+  public Enumeration<String> getHeaderNames()
   {
     // initialize the header map if it hasn't been already
     initHeaderMap();
@@ -73,6 +77,7 @@
   /**
    * Does 'lazy' initialization of Map of 'properties', i.e. mime headers.
    */
+  @SuppressWarnings("unchecked")
   protected boolean initHeaderMap()
   {
     if (mHeaders != null)
@@ -80,41 +85,34 @@
       return false;
     }
 
-    mHeaders = Collections.EMPTY_MAP;
-    mHeaderNames = Collections.EMPTY_LIST;
-
-    Enumeration props = mPortletRequest.getPropertyNames();
-    Enumeration values = null;
-    StringBuffer property = null;
+    mHeaders = Collections.emptyMap();
+    mHeaderNames = Collections.emptyList();
 
-    while (props != null && props.hasMoreElements())
+    Enumeration<String> props = mPortletRequest.getPropertyNames();
+    while (props.hasMoreElements())
     {
-      String name = (String) props.nextElement();
-      values = mPortletRequest.getProperties(name);
+      String name = props.nextElement();
+      Enumeration<String> values = mPortletRequest.getProperties(name);
       while (values != null && values.hasMoreElements())
       {
-        addProperty(name, (String) values.nextElement());
+        addProperty(name, values.nextElement());
       }
     }
+    
+    StringBuilder property = null;
 
     // if they don't already exist, now add in the the required (HTTP)
     // headers to ensure compatibility with servlets
     if (!containsHeader(mHeaderNames, "ACCEPT"))
     {
-      values = mPortletRequest.getResponseContentTypes();
-      if (property == null)
-      {
-        property = new StringBuffer(64);
-      }
-      else
-      {
-        property.setLength(0);
-      }
+      Enumeration<String> contentTypes = mPortletRequest.getResponseContentTypes();
+      property = new StringBuilder(64);
+      
       boolean addComma = false;
-      while (values != null && values.hasMoreElements())
+      while (contentTypes.hasMoreElements())
       {
-        String s = (String) values.nextElement();
-        if (s != null)
+        String type = contentTypes.nextElement();
+        if (type != null)
         {
           if (addComma)
           {
@@ -124,7 +122,8 @@
           {
             addComma = true;
           }
-          property = property.append(s);
+          
+          property = property.append(type);
         }
       }
 
@@ -136,19 +135,20 @@
 
     if (!containsHeader(mHeaderNames, "ACCEPT-LANGUAGE"))
     {
-      values = mPortletRequest.getLocales();
+      Enumeration<Locale> locales = mPortletRequest.getLocales();
       if (property == null)
       {
-        property = new StringBuffer(64);
+        property = new StringBuilder(64);
       }
       else
       {
         property.setLength(0);
       }
+      
       boolean addComma = false;
-      while (values != null && values.hasMoreElements())
+      while (locales.hasMoreElements())
       {
-        Locale l = (Locale) values.nextElement();
+        Locale l = locales.nextElement();
         if (l != null)
         {
           if (addComma)
@@ -159,6 +159,7 @@
           {
             addComma = true;
           }
+          
           String s = l.getLanguage();
           // only add if language not empty
           if (s.length() > 0)
@@ -192,7 +193,7 @@
         {
           if (property == null)
           {
-            property = new StringBuffer(64);
+            property = new StringBuilder(64);
           }
           else
           {
@@ -224,17 +225,16 @@
     return true;
   }
 
-  private boolean containsHeader(List headerNames, String key)
+  private boolean containsHeader(List<String> headerNames, String key)
   {
-    Iterator i = headerNames.iterator();
-    while (i.hasNext())
+    for (String name : headerNames)
     {
-      String name = (String) i.next();
       if (key.toUpperCase().equals(name.toUpperCase()))
       {
         return true;
       }
     }
+    
     return false;
   }
 
@@ -242,15 +242,15 @@
   {
     if (mHeaders == Collections.EMPTY_MAP)
     {
-      mHeaders = new HashMap(40);
-      mHeaderNames = new ArrayList(30);
+      mHeaders = new HashMap<String, List<String>>(40);
+      mHeaderNames = new ArrayList<String>(30);
     }
     // Store against UPPER CASE key to make case-insensitive
     String upperName = name.toUpperCase();
-    List propertyList = (List) mHeaders.get(upperName);
+    List<String> propertyList = mHeaders.get(upperName);
     if (propertyList == null)
     {
-      propertyList = new ArrayList(4);
+      propertyList = new ArrayList<String>(4);
       mHeaders.put(upperName, propertyList);
       mHeaderNames.add(name);
     }

Modified: myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/util/map/PortletRequestMap.java
URL: http://svn.apache.org/viewvc/myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/util/map/PortletRequestMap.java?rev=596889&r1=596888&r2=596889&view=diff
==============================================================================
--- myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/util/map/PortletRequestMap.java (original)
+++ myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/util/map/PortletRequestMap.java Tue Nov 20 16:19:55 2007
@@ -14,7 +14,6 @@
  * KIND, either express or implied.  See the License for the
  * specific language governing permissions and limitations
  * under the License.
- *
  */
 
 package org.apache.myfaces.portlet.faces.util.map;
@@ -26,7 +25,7 @@
 /**
  * Map of portlet request attributes
  */
-public class PortletRequestMap extends PortletAbstractMap
+public class PortletRequestMap extends PortletAbstractMap<Object>
 {
   private final PortletRequest mPortletRequest;
 
@@ -60,9 +59,7 @@
   {
     if (mPortletRequest != null)
     {
-
       mPortletRequest.setAttribute(key, value);
-
     }
   }
 
@@ -75,8 +72,9 @@
     }
   }
 
+  @SuppressWarnings("unchecked")
   @Override
-  public Enumeration getAttributeNames()
+  public Enumeration<String> getAttributeNames()
   {
     if (mPortletRequest != null)
     {

Modified: myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/util/map/PortletRequestParameterMap.java
URL: http://svn.apache.org/viewvc/myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/util/map/PortletRequestParameterMap.java?rev=596889&r1=596888&r2=596889&view=diff
==============================================================================
--- myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/util/map/PortletRequestParameterMap.java (original)
+++ myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/util/map/PortletRequestParameterMap.java Tue Nov 20 16:19:55 2007
@@ -14,7 +14,6 @@
  * KIND, either express or implied.  See the License for the
  * specific language governing permissions and limitations
  * under the License.
- *
  */
 
 package org.apache.myfaces.portlet.faces.util.map;
@@ -22,7 +21,6 @@
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.Enumeration;
-import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 
@@ -31,19 +29,19 @@
 /**
  * Map of portlet request params
  */
-public class PortletRequestParameterMap extends PortletAbstractMap
+public class PortletRequestParameterMap extends PortletAbstractMap<String>
 {
   private final PortletRequest mPortletRequest;
-  private final Map            mInternalAttributes;
+  private final Map<String, String> mInternalAttributes;
 
-  public PortletRequestParameterMap(Object request, Map internal)
+  public PortletRequestParameterMap(Object request, Map<String, String> internal)
   {
     if (request instanceof PortletRequest)
     {
       mPortletRequest = (PortletRequest) request;
       if (internal == null)
       {
-        mInternalAttributes = Collections.EMPTY_MAP;
+        mInternalAttributes = Collections.emptyMap();
       }
       else
       {
@@ -57,11 +55,11 @@
   }
 
   @Override
-  public Object getAttribute(String key)
+  public String getAttribute(String key)
   {
     if (mPortletRequest != null)
     {
-      Object value = mInternalAttributes.get(key);
+      String value = mInternalAttributes.get(key);
       if (value != null)
       {
         return value;
@@ -76,7 +74,7 @@
   }
 
   @Override
-  public void setAttribute(String key, Object value)
+  public void setAttribute(String key, String value)
   {
     throw new UnsupportedOperationException();
   }
@@ -87,25 +85,22 @@
     throw new UnsupportedOperationException();
   }
 
+  @SuppressWarnings("unchecked")
   @Override
-  public Enumeration getAttributeNames()
+  public Enumeration<String> getAttributeNames()
   {
     if (mPortletRequest != null)
     {
       // merged list of internal parameters & request parameters
-      List attrNames = new ArrayList(5);
+      List<String> attrNames = new ArrayList<String>(5);
 
-      Enumeration requestAttrNames = mPortletRequest.getParameterNames();
+      Enumeration<String> requestAttrNames = mPortletRequest.getParameterNames();
       while (requestAttrNames.hasMoreElements())
       {
         attrNames.add(requestAttrNames.nextElement());
       }
-
-      for (Iterator i = mInternalAttributes.entrySet().iterator(); i.hasNext();)
-      {
-        Entry entry = (Entry) i.next();
-        attrNames.add(entry.getKey());
-      }
+      
+      attrNames.addAll(mInternalAttributes.keySet());
 
       return Collections.enumeration(attrNames);
     }

Modified: myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/util/map/PortletRequestParameterValuesMap.java
URL: http://svn.apache.org/viewvc/myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/util/map/PortletRequestParameterValuesMap.java?rev=596889&r1=596888&r2=596889&view=diff
==============================================================================
--- myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/util/map/PortletRequestParameterValuesMap.java (original)
+++ myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/util/map/PortletRequestParameterValuesMap.java Tue Nov 20 16:19:55 2007
@@ -14,7 +14,6 @@
  * KIND, either express or implied.  See the License for the
  * specific language governing permissions and limitations
  * under the License.
- *
  */
 
 package org.apache.myfaces.portlet.faces.util.map;
@@ -22,7 +21,6 @@
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.Enumeration;
-import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 
@@ -31,19 +29,19 @@
 /**
  * Map of portlet request param values
  */
-public class PortletRequestParameterValuesMap extends PortletAbstractMap
+public class PortletRequestParameterValuesMap extends PortletAbstractMap<String[]>
 {
   private final PortletRequest mPortletRequest;
-  private final Map            mInternalAttributes;
+  private final Map<String, String[]> mInternalAttributes;
 
-  public PortletRequestParameterValuesMap(Object request, Map internal)
+  public PortletRequestParameterValuesMap(Object request, Map<String, String[]> internal)
   {
     if (request instanceof PortletRequest)
     {
       mPortletRequest = (PortletRequest) request;
       if (internal == null)
       {
-        mInternalAttributes = Collections.EMPTY_MAP;
+        mInternalAttributes = Collections.emptyMap();
       }
       else
       {
@@ -57,11 +55,11 @@
   }
 
   @Override
-  public Object getAttribute(String key)
+  public String[] getAttribute(String key)
   {
     if (mPortletRequest != null)
     {
-      Object value = mInternalAttributes.get(key);
+      String[] value = mInternalAttributes.get(key);
       if (value != null)
       {
         return value;
@@ -76,7 +74,7 @@
   }
 
   @Override
-  public void setAttribute(String key, Object value)
+  public void setAttribute(String key, String[] value)
   {
     throw new UnsupportedOperationException();
   }
@@ -87,25 +85,22 @@
     throw new UnsupportedOperationException();
   }
 
+  @SuppressWarnings("unchecked")
   @Override
-  public Enumeration getAttributeNames()
+  public Enumeration<String> getAttributeNames()
   {
     if (mPortletRequest != null)
     {
       // merged list of internal parameters & request parameters
-      List attrNames = new ArrayList(5);
+      List<String> attrNames = new ArrayList<String>(5);
 
-      Enumeration requestAttrNames = mPortletRequest.getParameterNames();
+      Enumeration<String> requestAttrNames = mPortletRequest.getParameterNames();
       while (requestAttrNames.hasMoreElements())
       {
         attrNames.add(requestAttrNames.nextElement());
       }
 
-      for (Iterator i = mInternalAttributes.entrySet().iterator(); i.hasNext();)
-      {
-        Entry entry = (Entry) i.next();
-        attrNames.add(entry.getKey());
-      }
+      attrNames.addAll(mInternalAttributes.keySet());
 
       return Collections.enumeration(attrNames);
     }

Modified: myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/util/map/PortletSessionMap.java
URL: http://svn.apache.org/viewvc/myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/util/map/PortletSessionMap.java?rev=596889&r1=596888&r2=596889&view=diff
==============================================================================
--- myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/util/map/PortletSessionMap.java (original)
+++ myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/util/map/PortletSessionMap.java Tue Nov 20 16:19:55 2007
@@ -14,13 +14,13 @@
  * KIND, either express or implied.  See the License for the
  * specific language governing permissions and limitations
  * under the License.
- *
  */
 
 package org.apache.myfaces.portlet.faces.util.map;
 
 import java.util.Collections;
 import java.util.Enumeration;
+import java.util.List;
 import java.util.Map;
 
 import javax.portlet.PortletRequest;
@@ -30,7 +30,7 @@
 /**
  * Map of portlet session attributes
  */
-public class PortletSessionMap extends PortletAbstractMap
+public class PortletSessionMap extends PortletAbstractMap<Object>
 {
 
   private final PortletRequest mPortletRequest;
@@ -100,15 +100,23 @@
     }
   }
 
+  @SuppressWarnings("unchecked")
   @Override
-  protected Enumeration getAttributeNames()
+  protected Enumeration<String> getAttributeNames()
   {
     if (mPortletRequest != null)
     {
       PortletSession portletSession = mPortletRequest.getPortletSession(false);
-      ;
-      return portletSession == null ? Collections.enumeration(Collections.EMPTY_LIST)
-                                   : portletSession.getAttributeNames(mScope);
+      
+      if (portletSession == null)
+      {
+        List<String> dummy = Collections.emptyList();
+        return Collections.enumeration(dummy);
+      }
+      else
+      {
+        return portletSession.getAttributeNames(mScope);
+      }
     }
     else
     {
@@ -116,20 +124,23 @@
     }
   }
 
-  private Map getAppScopeMap(PortletSession portletSession)
+  @SuppressWarnings("unchecked")
+  private Map<String, Object> getAppScopeMap(PortletSession portletSession)
   {
     if (mScope != PortletSession.PORTLET_SCOPE)
     {
       return null;
     }
 
-    Map m = (Map) portletSession.getAttribute(Bridge.APPLICATION_SCOPE_MAP);
+    Map<String, Object> m = 
+      (Map<String, Object>)portletSession.getAttribute(Bridge.APPLICATION_SCOPE_MAP);
 
     if (m == null)
     {
       m = new PortletSessionMap(mPortletRequest, PortletSession.APPLICATION_SCOPE);
       portletSession.setAttribute(Bridge.APPLICATION_SCOPE_MAP, m);
     }
+    
     return m;
   }