You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by gr...@apache.org on 2006/05/09 19:55:32 UTC
svn commit: r405486 [1/2] - in /struts/sandbox/trunk/tiles/tiles-core: ./
src/main/java/org/apache/tiles/context/
src/main/java/org/apache/tiles/context/portlet/
src/main/java/org/apache/tiles/context/servlet/
src/main/java/org/apache/tiles/filter/ src...
Author: greddin
Date: Tue May 9 10:55:29 2006
New Revision: 405486
URL: http://svn.apache.org/viewcvs?rev=405486&view=rev
Log:
SB-13
Completed API for TilesContext. Added servlet and portlet implementations. Ported implementation helpers from Commons-Chain.
Added:
struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/context/MapEntry.java (with props)
struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/context/portlet/
struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/context/portlet/PortletApplicationScopeMap.java (with props)
struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/context/portlet/PortletInitParamMap.java (with props)
struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/context/portlet/PortletParamMap.java (with props)
struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/context/portlet/PortletParamValuesMap.java (with props)
struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/context/portlet/PortletRequestScopeMap.java (with props)
struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/context/portlet/PortletSessionScopeMap.java (with props)
struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/context/portlet/PortletTilesContext.java (with props)
struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/context/servlet/
struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/context/servlet/ServletApplicationScopeMap.java (with props)
struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/context/servlet/ServletHeaderMap.java (with props)
struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/context/servlet/ServletHeaderValuesMap.java (with props)
struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/context/servlet/ServletInitParamMap.java (with props)
struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/context/servlet/ServletParamMap.java (with props)
struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/context/servlet/ServletParamValuesMap.java (with props)
struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/context/servlet/ServletRequestScopeMap.java (with props)
struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/context/servlet/ServletSessionScopeMap.java (with props)
struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/context/servlet/ServletTilesContext.java
- copied, changed from r399725, struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/context/ServletTilesContext.java
Removed:
struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/context/ServletTilesContext.java
Modified:
struts/sandbox/trunk/tiles/tiles-core/pom.xml
struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/context/TilesContextFactory.java
struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/filter/TilesFilter.java
struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/InitDefinitionsTag.java
struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/InsertTag.java
struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/util/TagUtils.java
Modified: struts/sandbox/trunk/tiles/tiles-core/pom.xml
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/tiles/tiles-core/pom.xml?rev=405486&r1=405485&r2=405486&view=diff
==============================================================================
--- struts/sandbox/trunk/tiles/tiles-core/pom.xml (original)
+++ struts/sandbox/trunk/tiles/tiles-core/pom.xml Tue May 9 10:55:29 2006
@@ -91,6 +91,13 @@
</dependency>
<dependency>
+ <groupId>javax.portlet</groupId>
+ <artifactId>portlet-api</artifactId>
+ <version>1.0</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
Added: struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/context/MapEntry.java
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/context/MapEntry.java?rev=405486&view=auto
==============================================================================
--- struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/context/MapEntry.java (added)
+++ struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/context/MapEntry.java Tue May 9 10:55:29 2006
@@ -0,0 +1,129 @@
+/*
+ * $Id$
+ *
+ * Copyright 1999-2004 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.tiles.context;
+
+
+import java.util.Map;
+
+
+/**
+ * <p>Map.Entry implementation that can be constructed to either be read-only
+ * or not.</p>
+ *
+ * @version $Revision$ $Date$
+ */
+
+public class MapEntry implements Map.Entry {
+
+
+ /**
+ * <p>The entry key.</p>
+ */
+ private Object key;
+
+ /**
+ * <p>The entry value.</p>
+ */
+ private Object value;
+
+ /**
+ * <p>Whether the entry can be modified.</p>
+ */
+ private boolean modifiable = false;
+
+
+ /**
+ * <p>Creates a map entry that can either allow modifications or not.</p>
+ *
+ * @param key The entry key
+ * @param value The entry value
+ * @param modifiable Whether the entry should allow modification or not
+ */
+ public MapEntry(Object key, Object value, boolean modifiable) {
+ this.key = key;
+ this.value = value;
+ this.modifiable = modifiable;
+ }
+
+
+ /**
+ * <p>Gets the entry key.</p>
+ *
+ * @return The entry key
+ */
+ public Object getKey() {
+ return key;
+ }
+
+
+ /**
+ * <p>Gets the entry value.</p>
+ *
+ * @return The entry key
+ */
+ public Object getValue() {
+ return value;
+ }
+
+
+ /**
+ * <p>Sets the entry value if the entry can be modified.</p>
+ *
+ * @param val The new value
+ * @return The old entry value
+ * @throws UnsupportedOperationException If the entry cannot be modified
+ */
+ public Object setValue(Object val) {
+ if (modifiable) {
+ Object oldVal = this.value;
+ this.value = val;
+ return oldVal;
+ } else {
+ throw new UnsupportedOperationException();
+ }
+ }
+
+
+ /**
+ * <p>Determines if this entry is equal to the passed object.</p>
+ *
+ * @param o The object to test
+ * @return True if equal, else false
+ */
+ public boolean equals(Object o) {
+ if (o != null && o instanceof Map.Entry) {
+ Map.Entry entry = (Map.Entry)o;
+ return (this.getKey() == null ?
+ entry.getKey() == null : this.getKey().equals(entry.getKey())) &&
+ (this.getValue() == null ?
+ entry.getValue() == null : this.getValue().equals(entry.getValue()));
+ }
+ return false;
+ }
+
+
+ /**
+ * <p>Returns the hashcode for this entry.</p>
+ *
+ * @return The and'ed hashcode of the key and value
+ */
+ public int hashCode() {
+ return (this.getKey() == null ? 0 : this.getKey().hashCode()) ^
+ (this.getValue() == null ? 0 : this.getValue().hashCode());
+ }
+}
Propchange: struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/context/MapEntry.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/context/MapEntry.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Modified: struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/context/TilesContextFactory.java
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/context/TilesContextFactory.java?rev=405486&r1=405485&r2=405486&view=diff
==============================================================================
--- struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/context/TilesContextFactory.java (original)
+++ struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/context/TilesContextFactory.java Tue May 9 10:55:29 2006
@@ -20,8 +20,17 @@
import javax.servlet.ServletContext;
import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
import javax.servlet.jsp.PageContext;
+import javax.portlet.PortletContext;
+import javax.portlet.PortletRequest;
+import javax.portlet.PortletResponse;
+
import org.apache.tiles.TilesContext;
+import org.apache.tiles.context.portlet.PortletTilesContext;
+import org.apache.tiles.context.servlet.ServletTilesContext;
/**
* Creates an instance of the appropriate TilesContext implementation.
@@ -33,17 +42,48 @@
/**
* Creates a TilesContext from parameters found in the Servlet environment.
*/
- public static TilesContext getInstance(ServletRequest request,
- ServletContext servletContext) {
- return new ServletTilesContext(servletContext, request);
+ public static TilesContext getInstance(Object context,
+ Object request) {
+
+ if (context instanceof ServletContext) {
+ return new ServletTilesContext((ServletContext) context,
+ (HttpServletRequest) request);
+ } else if (context instanceof PortletContext) {
+ return new PortletTilesContext((PortletContext) context,
+ (PortletRequest) request);
+ } else {
+ throw new IllegalArgumentException("Invalid context specified. "
+ + context.getClass().getName());
+ }
}
- public static TilesContext getInstance(ServletContext servletContext) {
- return new ServletTilesContext(servletContext);
+ public static TilesContext getInstance(Object context, Object request,
+ Object response) {
+
+ if (context instanceof ServletContext) {
+ return new ServletTilesContext((ServletContext) context,
+ (HttpServletRequest) request,
+ (HttpServletResponse) response);
+ } else if (context instanceof PortletContext) {
+ return new PortletTilesContext((PortletContext) context,
+ (PortletRequest) request,
+ (PortletResponse) response);
+ } else {
+ throw new IllegalArgumentException("Invalid context specified. "
+ + context.getClass().getName());
+ }
}
- public static TilesContext getInstance(PageContext pageContext) {
- return new ServletTilesContext(pageContext.getServletContext(),
- pageContext.getRequest(), pageContext.getResponse());
+ public static TilesContext getInstance(Object context) {
+
+ if (context instanceof ServletContext) {
+ return new ServletTilesContext((ServletContext)context);
+ } else if (context instanceof PortletContext) {
+ return new PortletTilesContext((PortletContext)context);
+ } else {
+ throw new IllegalArgumentException("Invalid context specified. "
+ + context.getClass().getName());
+ }
}
+
}
Added: struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/context/portlet/PortletApplicationScopeMap.java
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/context/portlet/PortletApplicationScopeMap.java?rev=405486&view=auto
==============================================================================
--- struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/context/portlet/PortletApplicationScopeMap.java (added)
+++ struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/context/portlet/PortletApplicationScopeMap.java Tue May 9 10:55:29 2006
@@ -0,0 +1,178 @@
+/*
+ * $Id$
+ *
+ * Copyright 1999-2006 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.tiles.context.portlet;
+
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Enumeration;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import javax.portlet.PortletContext;
+
+
+/**
+ * <p>Private implementation of <code>Map</code> for portlet context
+ * attributes.</p>
+ *
+ * @version $Rev$ $Date$
+ */
+
+final class PortletApplicationScopeMap implements Map {
+
+
+ public PortletApplicationScopeMap(PortletContext context) {
+ this.context = context;
+ }
+
+
+ private PortletContext context = null;
+
+
+ public void clear() {
+ Iterator keys = keySet().iterator();
+ while (keys.hasNext()) {
+ context.removeAttribute((String) keys.next());
+ }
+ }
+
+
+ public boolean containsKey(Object key) {
+ return (context.getAttribute(key(key)) != null);
+ }
+
+
+ public boolean containsValue(Object value) {
+ if (value == null) {
+ return (false);
+ }
+ Enumeration keys = context.getAttributeNames();
+ while (keys.hasMoreElements()) {
+ Object next = context.getAttribute((String) keys.nextElement());
+ if (next == value) {
+ return (true);
+ }
+ }
+ return (false);
+ }
+
+
+ public Set entrySet() {
+ Set set = new HashSet();
+ Enumeration keys = context.getAttributeNames();
+ while (keys.hasMoreElements()) {
+ set.add(context.getAttribute((String) keys.nextElement()));
+ }
+ return (set);
+ }
+
+
+ public boolean equals(Object o) {
+ return (context.equals(o));
+ }
+
+
+ public Object get(Object key) {
+ return (context.getAttribute(key(key)));
+ }
+
+
+ public int hashCode() {
+ return (context.hashCode());
+ }
+
+
+ public boolean isEmpty() {
+ return (size() < 1);
+ }
+
+
+ public Set keySet() {
+ Set set = new HashSet();
+ Enumeration keys = context.getAttributeNames();
+ while (keys.hasMoreElements()) {
+ set.add(keys.nextElement());
+ }
+ return (set);
+ }
+
+
+ public Object put(Object key, Object value) {
+ if (value == null) {
+ return (remove(key));
+ }
+ String skey = key(key);
+ Object previous = context.getAttribute(skey);
+ context.setAttribute(skey, value);
+ return (previous);
+ }
+
+
+ public void putAll(Map map) {
+ Iterator keys = map.keySet().iterator();
+ while (keys.hasNext()) {
+ String key = (String) keys.next();
+ context.setAttribute(key, map.get(key));
+ }
+ }
+
+
+ public Object remove(Object key) {
+ String skey = key(key);
+ Object previous = context.getAttribute(skey);
+ context.removeAttribute(skey);
+ return (previous);
+ }
+
+
+ public int size() {
+ int n = 0;
+ Enumeration keys = context.getAttributeNames();
+ while (keys.hasMoreElements()) {
+ keys.nextElement();
+ n++;
+ }
+ return (n);
+ }
+
+
+ public Collection values() {
+ List list = new ArrayList();
+ Enumeration keys = context.getAttributeNames();
+ while (keys.hasMoreElements()) {
+ list.add(context.getAttribute((String) keys.nextElement()));
+ }
+ return (list);
+ }
+
+
+ private String key(Object key) {
+ if (key == null) {
+ throw new IllegalArgumentException();
+ } else if (key instanceof String) {
+ return ((String) key);
+ } else {
+ return (key.toString());
+ }
+ }
+
+
+}
Propchange: struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/context/portlet/PortletApplicationScopeMap.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/context/portlet/PortletApplicationScopeMap.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Added: struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/context/portlet/PortletInitParamMap.java
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/context/portlet/PortletInitParamMap.java?rev=405486&view=auto
==============================================================================
--- struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/context/portlet/PortletInitParamMap.java (added)
+++ struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/context/portlet/PortletInitParamMap.java Tue May 9 10:55:29 2006
@@ -0,0 +1,158 @@
+/*
+ * $Id$
+ *
+ * Copyright 1999-2006 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.tiles.context.portlet;
+
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Enumeration;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import javax.portlet.PortletContext;
+
+
+/**
+ * <p>Private implementation of <code>Map</code> for portlet context
+ * init parameters.</p>
+ *
+ * @version $Rev$ $Date$
+ */
+
+final class PortletInitParamMap implements Map {
+
+
+ public PortletInitParamMap(PortletContext context) {
+ this.context = context;
+ }
+
+
+ private PortletContext context = null;
+
+
+ public void clear() {
+ throw new UnsupportedOperationException();
+ }
+
+
+ public boolean containsKey(Object key) {
+ return (context.getInitParameter(key(key)) != null);
+ }
+
+
+ public boolean containsValue(Object value) {
+ Iterator values = values().iterator();
+ while (values.hasNext()) {
+ if (value.equals(values.next())) {
+ return (true);
+ }
+ }
+ return (false);
+ }
+
+
+ public Set entrySet() {
+ Set set = new HashSet();
+ Enumeration keys = context.getInitParameterNames();
+ while (keys.hasMoreElements()) {
+ set.add(context.getInitParameter((String) keys.nextElement()));
+ }
+ return (set);
+ }
+
+
+ public boolean equals(Object o) {
+ return (context.equals(o));
+ }
+
+
+ public Object get(Object key) {
+ return (context.getInitParameter(key(key)));
+ }
+
+
+ public int hashCode() {
+ return (context.hashCode());
+ }
+
+
+ public boolean isEmpty() {
+ return (size() < 1);
+ }
+
+
+ public Set keySet() {
+ Set set = new HashSet();
+ Enumeration keys = context.getInitParameterNames();
+ while (keys.hasMoreElements()) {
+ set.add(keys.nextElement());
+ }
+ return (set);
+ }
+
+
+ public Object put(Object key, Object value) {
+ throw new UnsupportedOperationException();
+ }
+
+
+ public void putAll(Map map) {
+ throw new UnsupportedOperationException();
+ }
+
+
+ public Object remove(Object key) {
+ throw new UnsupportedOperationException();
+ }
+
+
+ public int size() {
+ int n = 0;
+ Enumeration keys = context.getInitParameterNames();
+ while (keys.hasMoreElements()) {
+ keys.nextElement();
+ n++;
+ }
+ return (n);
+ }
+
+
+ public Collection values() {
+ List list = new ArrayList();
+ Enumeration keys = context.getInitParameterNames();
+ while (keys.hasMoreElements()) {
+ list.add(context.getInitParameter((String) keys.nextElement()));
+ }
+ return (list);
+ }
+
+
+ private String key(Object key) {
+ if (key == null) {
+ throw new IllegalArgumentException();
+ } else if (key instanceof String) {
+ return ((String) key);
+ } else {
+ return (key.toString());
+ }
+ }
+
+
+}
Propchange: struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/context/portlet/PortletInitParamMap.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/context/portlet/PortletInitParamMap.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Added: struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/context/portlet/PortletParamMap.java
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/context/portlet/PortletParamMap.java?rev=405486&view=auto
==============================================================================
--- struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/context/portlet/PortletParamMap.java (added)
+++ struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/context/portlet/PortletParamMap.java Tue May 9 10:55:29 2006
@@ -0,0 +1,158 @@
+/*
+ * $Id$
+ *
+ * Copyright 1999-2006 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.tiles.context.portlet;
+
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Enumeration;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import javax.portlet.PortletRequest;
+
+
+/**
+ * <p>Private implementation of <code>Map</code> for portlet parameter
+ * name-value.</p>
+ *
+ * @version $Rev$ $Date$
+ */
+
+final class PortletParamMap implements Map {
+
+
+ public PortletParamMap(PortletRequest request) {
+ this.request = request;
+ }
+
+
+ private PortletRequest request = null;
+
+
+ public void clear() {
+ throw new UnsupportedOperationException();
+ }
+
+
+ public boolean containsKey(Object key) {
+ return (request.getParameter(key(key)) != null);
+ }
+
+
+ public boolean containsValue(Object value) {
+ Iterator values = values().iterator();
+ while (values.hasNext()) {
+ if (value.equals(values.next())) {
+ return (true);
+ }
+ }
+ return (false);
+ }
+
+
+ public Set entrySet() {
+ Set set = new HashSet();
+ Enumeration keys = request.getParameterNames();
+ while (keys.hasMoreElements()) {
+ set.add(request.getParameter((String) keys.nextElement()));
+ }
+ return (set);
+ }
+
+
+ public boolean equals(Object o) {
+ return (request.equals(o));
+ }
+
+
+ public Object get(Object key) {
+ return (request.getParameter(key(key)));
+ }
+
+
+ public int hashCode() {
+ return (request.hashCode());
+ }
+
+
+ public boolean isEmpty() {
+ return (size() < 1);
+ }
+
+
+ public Set keySet() {
+ Set set = new HashSet();
+ Enumeration keys = request.getParameterNames();
+ while (keys.hasMoreElements()) {
+ set.add(keys.nextElement());
+ }
+ return (set);
+ }
+
+
+ public Object put(Object key, Object value) {
+ throw new UnsupportedOperationException();
+ }
+
+
+ public void putAll(Map map) {
+ throw new UnsupportedOperationException();
+ }
+
+
+ public Object remove(Object key) {
+ throw new UnsupportedOperationException();
+ }
+
+
+ public int size() {
+ int n = 0;
+ Enumeration keys = request.getParameterNames();
+ while (keys.hasMoreElements()) {
+ keys.nextElement();
+ n++;
+ }
+ return (n);
+ }
+
+
+ public Collection values() {
+ List list = new ArrayList();
+ Enumeration keys = request.getParameterNames();
+ while (keys.hasMoreElements()) {
+ list.add(request.getParameter((String) keys.nextElement()));
+ }
+ return (list);
+ }
+
+
+ private String key(Object key) {
+ if (key == null) {
+ throw new IllegalArgumentException();
+ } else if (key instanceof String) {
+ return ((String) key);
+ } else {
+ return (key.toString());
+ }
+ }
+
+
+}
Propchange: struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/context/portlet/PortletParamMap.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/context/portlet/PortletParamMap.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Added: struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/context/portlet/PortletParamValuesMap.java
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/context/portlet/PortletParamValuesMap.java?rev=405486&view=auto
==============================================================================
--- struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/context/portlet/PortletParamValuesMap.java (added)
+++ struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/context/portlet/PortletParamValuesMap.java Tue May 9 10:55:29 2006
@@ -0,0 +1,158 @@
+/*
+ * $Id$
+ *
+ * Copyright 1999-2006 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.tiles.context.portlet;
+
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Enumeration;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import javax.portlet.PortletRequest;
+
+
+/**
+ * <p>Private implementation of <code>Map</code> for portlet parameter
+ * name-values[].</p>
+ *
+ * @version $Rev$ $Date$
+ */
+
+final class PortletParamValuesMap implements Map {
+
+
+ public PortletParamValuesMap(PortletRequest request) {
+ this.request = request;
+ }
+
+
+ private PortletRequest request = null;
+
+
+ public void clear() {
+ throw new UnsupportedOperationException();
+ }
+
+
+ public boolean containsKey(Object key) {
+ return (request.getParameter(key(key)) != null);
+ }
+
+
+ public boolean containsValue(Object value) {
+ Iterator values = values().iterator();
+ while (values.hasNext()) {
+ if (value.equals(values.next())) {
+ return (true);
+ }
+ }
+ return (false);
+ }
+
+
+ public Set entrySet() {
+ Set set = new HashSet();
+ Enumeration keys = request.getParameterNames();
+ while (keys.hasMoreElements()) {
+ set.add(request.getParameterValues((String) keys.nextElement()));
+ }
+ return (set);
+ }
+
+
+ public boolean equals(Object o) {
+ return (request.equals(o));
+ }
+
+
+ public Object get(Object key) {
+ return (request.getParameterValues(key(key)));
+ }
+
+
+ public int hashCode() {
+ return (request.hashCode());
+ }
+
+
+ public boolean isEmpty() {
+ return (size() < 1);
+ }
+
+
+ public Set keySet() {
+ Set set = new HashSet();
+ Enumeration keys = request.getParameterNames();
+ while (keys.hasMoreElements()) {
+ set.add(keys.nextElement());
+ }
+ return (set);
+ }
+
+
+ public Object put(Object key, Object value) {
+ throw new UnsupportedOperationException();
+ }
+
+
+ public void putAll(Map map) {
+ throw new UnsupportedOperationException();
+ }
+
+
+ public Object remove(Object key) {
+ throw new UnsupportedOperationException();
+ }
+
+
+ public int size() {
+ int n = 0;
+ Enumeration keys = request.getParameterNames();
+ while (keys.hasMoreElements()) {
+ keys.nextElement();
+ n++;
+ }
+ return (n);
+ }
+
+
+ public Collection values() {
+ List list = new ArrayList();
+ Enumeration keys = request.getParameterNames();
+ while (keys.hasMoreElements()) {
+ list.add(request.getParameterValues((String) keys.nextElement()));
+ }
+ return (list);
+ }
+
+
+ private String key(Object key) {
+ if (key == null) {
+ throw new IllegalArgumentException();
+ } else if (key instanceof String) {
+ return ((String) key);
+ } else {
+ return (key.toString());
+ }
+ }
+
+
+}
Propchange: struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/context/portlet/PortletParamValuesMap.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/context/portlet/PortletParamValuesMap.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Added: struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/context/portlet/PortletRequestScopeMap.java
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/context/portlet/PortletRequestScopeMap.java?rev=405486&view=auto
==============================================================================
--- struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/context/portlet/PortletRequestScopeMap.java (added)
+++ struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/context/portlet/PortletRequestScopeMap.java Tue May 9 10:55:29 2006
@@ -0,0 +1,178 @@
+/*
+ * $Id$
+ *
+ * Copyright 1999-2006 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.tiles.context.portlet;
+
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Enumeration;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import javax.portlet.PortletRequest;
+
+
+/**
+ * <p>Private implementation of <code>Map</code> for portlet request
+ * attributes.</p>
+ *
+ * @version $Rev$ $Date$
+ */
+
+final class PortletRequestScopeMap implements Map {
+
+
+ public PortletRequestScopeMap(PortletRequest request) {
+ this.request = request;
+ }
+
+
+ private PortletRequest request = null;
+
+
+ public void clear() {
+ Iterator keys = keySet().iterator();
+ while (keys.hasNext()) {
+ request.removeAttribute((String) keys.next());
+ }
+ }
+
+
+ public boolean containsKey(Object key) {
+ return (request.getAttribute(key(key)) != null);
+ }
+
+
+ public boolean containsValue(Object value) {
+ if (value == null) {
+ return (false);
+ }
+ Enumeration keys = request.getAttributeNames();
+ while (keys.hasMoreElements()) {
+ Object next = request.getAttribute((String) keys.nextElement());
+ if (next == value) {
+ return (true);
+ }
+ }
+ return (false);
+ }
+
+
+ public Set entrySet() {
+ Set set = new HashSet();
+ Enumeration keys = request.getAttributeNames();
+ while (keys.hasMoreElements()) {
+ set.add(request.getAttribute((String) keys.nextElement()));
+ }
+ return (set);
+ }
+
+
+ public boolean equals(Object o) {
+ return (request.equals(o));
+ }
+
+
+ public Object get(Object key) {
+ return (request.getAttribute(key(key)));
+ }
+
+
+ public int hashCode() {
+ return (request.hashCode());
+ }
+
+
+ public boolean isEmpty() {
+ return (size() < 1);
+ }
+
+
+ public Set keySet() {
+ Set set = new HashSet();
+ Enumeration keys = request.getAttributeNames();
+ while (keys.hasMoreElements()) {
+ set.add(keys.nextElement());
+ }
+ return (set);
+ }
+
+
+ public Object put(Object key, Object value) {
+ if (value == null) {
+ return (remove(key));
+ }
+ String skey = key(key);
+ Object previous = request.getAttribute(skey);
+ request.setAttribute(skey, value);
+ return (previous);
+ }
+
+
+ public void putAll(Map map) {
+ Iterator keys = map.keySet().iterator();
+ while (keys.hasNext()) {
+ String key = (String) keys.next();
+ request.setAttribute(key, map.get(key));
+ }
+ }
+
+
+ public Object remove(Object key) {
+ String skey = key(key);
+ Object previous = request.getAttribute(skey);
+ request.removeAttribute(skey);
+ return (previous);
+ }
+
+
+ public int size() {
+ int n = 0;
+ Enumeration keys = request.getAttributeNames();
+ while (keys.hasMoreElements()) {
+ keys.nextElement();
+ n++;
+ }
+ return (n);
+ }
+
+
+ public Collection values() {
+ List list = new ArrayList();
+ Enumeration keys = request.getAttributeNames();
+ while (keys.hasMoreElements()) {
+ list.add(request.getAttribute((String) keys.nextElement()));
+ }
+ return (list);
+ }
+
+
+ private String key(Object key) {
+ if (key == null) {
+ throw new IllegalArgumentException();
+ } else if (key instanceof String) {
+ return ((String) key);
+ } else {
+ return (key.toString());
+ }
+ }
+
+
+}
Propchange: struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/context/portlet/PortletRequestScopeMap.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/context/portlet/PortletRequestScopeMap.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Added: struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/context/portlet/PortletSessionScopeMap.java
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/context/portlet/PortletSessionScopeMap.java?rev=405486&view=auto
==============================================================================
--- struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/context/portlet/PortletSessionScopeMap.java (added)
+++ struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/context/portlet/PortletSessionScopeMap.java Tue May 9 10:55:29 2006
@@ -0,0 +1,183 @@
+/*
+ * $Id$
+ *
+ * Copyright 1999-2006 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.tiles.context.portlet;
+
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Enumeration;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import javax.portlet.PortletSession;
+
+
+/**
+ * <p>Private implementation of <code>Map</code> for portlet session
+ * attributes.</p>
+ *
+ * @version $Rev$ $Date$
+ */
+
+final class PortletSessionScopeMap implements Map {
+
+
+ public PortletSessionScopeMap(PortletSession session) {
+ this.session = session;
+ }
+
+
+ private PortletSession session = null;
+
+
+ public void clear() {
+ Iterator keys = keySet().iterator();
+ while (keys.hasNext()) {
+ session.removeAttribute((String) keys.next());
+ }
+ }
+
+
+ public boolean containsKey(Object key) {
+ return (session.getAttribute(key(key)) != null);
+ }
+
+
+ public boolean containsValue(Object value) {
+ if (value == null) {
+ return (false);
+ }
+ Enumeration keys =
+ session.getAttributeNames(PortletSession.PORTLET_SCOPE);
+ while (keys.hasMoreElements()) {
+ Object next = session.getAttribute((String) keys.nextElement());
+ if (next == value) {
+ return (true);
+ }
+ }
+ return (false);
+ }
+
+
+ public Set entrySet() {
+ Set set = new HashSet();
+ Enumeration keys =
+ session.getAttributeNames(PortletSession.PORTLET_SCOPE);
+ while (keys.hasMoreElements()) {
+ set.add(session.getAttribute((String) keys.nextElement()));
+ }
+ return (set);
+ }
+
+
+ public boolean equals(Object o) {
+ return (session.equals(o));
+ }
+
+
+ public Object get(Object key) {
+ return (session.getAttribute(key(key)));
+ }
+
+
+ public int hashCode() {
+ return (session.hashCode());
+ }
+
+
+ public boolean isEmpty() {
+ return (size() < 1);
+ }
+
+
+ public Set keySet() {
+ Set set = new HashSet();
+ Enumeration keys =
+ session.getAttributeNames(PortletSession.PORTLET_SCOPE);
+ while (keys.hasMoreElements()) {
+ set.add(keys.nextElement());
+ }
+ return (set);
+ }
+
+
+ public Object put(Object key, Object value) {
+ if (value == null) {
+ return (remove(key));
+ }
+ String skey = key(key);
+ Object previous = session.getAttribute(skey);
+ session.setAttribute(skey, value);
+ return (previous);
+ }
+
+
+ public void putAll(Map map) {
+ Iterator keys = map.keySet().iterator();
+ while (keys.hasNext()) {
+ String key = (String) keys.next();
+ session.setAttribute(key, map.get(key));
+ }
+ }
+
+
+ public Object remove(Object key) {
+ String skey = key(key);
+ Object previous = session.getAttribute(skey);
+ session.removeAttribute(skey);
+ return (previous);
+ }
+
+
+ public int size() {
+ int n = 0;
+ Enumeration keys =
+ session.getAttributeNames(PortletSession.PORTLET_SCOPE);
+ while (keys.hasMoreElements()) {
+ keys.nextElement();
+ n++;
+ }
+ return (n);
+ }
+
+
+ public Collection values() {
+ List list = new ArrayList();
+ Enumeration keys =
+ session.getAttributeNames(PortletSession.PORTLET_SCOPE);
+ while (keys.hasMoreElements()) {
+ list.add(session.getAttribute((String) keys.nextElement()));
+ }
+ return (list);
+ }
+
+
+ private String key(Object key) {
+ if (key == null) {
+ throw new IllegalArgumentException();
+ } else if (key instanceof String) {
+ return ((String) key);
+ } else {
+ return (key.toString());
+ }
+ }
+
+
+}
Propchange: struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/context/portlet/PortletSessionScopeMap.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/context/portlet/PortletSessionScopeMap.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Added: struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/context/portlet/PortletTilesContext.java
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/context/portlet/PortletTilesContext.java?rev=405486&view=auto
==============================================================================
--- struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/context/portlet/PortletTilesContext.java (added)
+++ struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/context/portlet/PortletTilesContext.java Tue May 9 10:55:29 2006
@@ -0,0 +1,295 @@
+/*
+ * $Id$
+ *
+ * Copyright 1999-2006 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.tiles.context.portlet;
+
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Locale;
+import java.util.Map;
+import javax.portlet.ActionRequest;
+import javax.portlet.PortletContext;
+import javax.portlet.PortletRequest;
+import javax.portlet.PortletResponse;
+import javax.portlet.RenderRequest;
+import javax.portlet.RenderResponse;
+
+import org.apache.tiles.TilesContext;
+
+/**
+ * Portlet-based TilesContext implementation.
+ *
+ * @version $Rev$ $Date$
+ */
+public class PortletTilesContext implements TilesContext {
+
+ /**
+ * <p>The lazily instantiated <code>Map</code> of application scope
+ * attributes.</p>
+ */
+ private Map applicationScope = null;
+
+
+ /**
+ * <p>The <code>PortletContext</code> for this web application.</p>
+ */
+ protected PortletContext context = null;
+
+
+ /**
+ * <p>The lazily instantiated <code>Map</code> of header name-value
+ * combinations (immutable).</p>
+ */
+ private Map header = null;
+
+
+ /**
+ * <p>The lazily instantitated <code>Map</code> of header name-values
+ * combinations (immutable).</p>
+ */
+ private Map headerValues = null;
+
+
+ /**
+ * <p>The lazily instantiated <code>Map</code> of context initialization
+ * parameters.</p>
+ */
+ private Map initParam = null;
+
+
+ /**
+ * <p>The lazily instantiated <code>Map</code> of request
+ * parameter name-value.</p>
+ */
+ private Map param = null;
+
+
+ /**
+ * <p>The lazily instantiated <code>Map</code> of request
+ * parameter name-values.</p>
+ */
+ private Map paramValues = null;
+
+
+ /**
+ * <p>The <code>PortletRequest</code> for this request.</p>
+ */
+ protected PortletRequest request = null;
+
+
+ /**
+ * <p>The lazily instantiated <code>Map</code> of request scope
+ * attributes.</p>
+ */
+ private Map requestScope = null;
+
+
+ /**
+ * <p>The <code>PortletResponse</code> for this request.</p>
+ */
+ protected PortletResponse response = null;
+
+
+ /**
+ * <p>The lazily instantiated <code>Map</code> of session scope
+ * attributes.</p>
+ */
+ private Map sessionScope = null;
+
+
+ /**
+ * <p>Indicates whether the request is an ActionRequest or RenderRequest.
+ */
+ private boolean isRenderRequest;
+
+
+ /** Creates a new instance of PortletTilesContext */
+ public PortletTilesContext(PortletContext context) {
+ initialize(context, null, null);
+ }
+
+ public PortletTilesContext(PortletContext context, PortletRequest request) {
+ initialize(context, request, null);
+ }
+
+ public PortletTilesContext(PortletContext context, PortletRequest request,
+ PortletResponse response) {
+ initialize(context, request, response);
+ }
+
+ /**
+ * <p>Initialize (or reinitialize) this {@link PortletWebContext} instance
+ * for the specified Portlet API objects.</p>
+ *
+ * @param context The <code>PortletContext</code> for this web application
+ * @param request The <code>PortletRequest</code> for this request
+ * @param response The <code>PortletResponse</code> for this request
+ */
+ public void initialize(PortletContext context,
+ PortletRequest request,
+ PortletResponse response) {
+
+ // Save the specified Portlet API object references
+ this.context = context;
+ this.request = request;
+ this.response = response;
+
+ // Perform other setup as needed
+ this.isRenderRequest = false;
+ if (request != null) {
+ if (request instanceof RenderRequest) {
+ isRenderRequest = true;
+ }
+ }
+
+ }
+
+ /**
+ * <p>Release references to allocated resources acquired in
+ * <code>initialize()</code> of via subsequent processing. After this
+ * method is called, subsequent calls to any other method than
+ * <code>initialize()</code> will return undefined results.</p>
+ */
+ public void release() {
+
+ // Release references to allocated collections
+ applicationScope = null;
+ header = null;
+ headerValues = null;
+ initParam = null;
+ param = null;
+ paramValues = null;
+ requestScope = null;
+ sessionScope = null;
+
+ // Release references to Portlet API objects
+ context = null;
+ request = null;
+ response = null;
+
+ }
+
+ /**
+ * <p>Return the {@link PortletContext} for this context.</p>
+ */
+ public PortletContext getContext() {
+ return (this.context);
+ }
+
+ /**
+ * <p>Return the {@link PortletRequest} for this context.</p>
+ */
+ public PortletRequest getRequest() {
+ return (this.request);
+ }
+
+ /**
+ * <p>Return the {@link PortletResponse} for this context.</p>
+ */
+ public PortletResponse getResponse() {
+ return (this.response);
+ }
+
+ public Map getApplicationScope() {
+ if ((applicationScope == null) && (context != null)) {
+ applicationScope = new PortletApplicationScopeMap(context);
+ }
+ return (applicationScope);
+
+ }
+
+ public Map getHeader() {
+ if ((header == null) && (request != null)) {
+ header = Collections.EMPTY_MAP;
+ }
+ return (header);
+ }
+
+ public Map getHeaderValues() {
+ if ((headerValues == null) && (request != null)) {
+ headerValues = Collections.EMPTY_MAP;
+ }
+ return (headerValues);
+ }
+
+ public Map getInitParams() {
+ if ((initParam == null) && (context != null)) {
+ initParam = new PortletInitParamMap(context);
+ }
+ return (initParam);
+
+ }
+
+ public Map getParam() {
+ if ((param == null) && (request != null)) {
+ param = new PortletParamMap(request);
+ }
+ return (param);
+ }
+
+ public Map getParamValues() {
+ if ((paramValues == null) && (request != null)) {
+ paramValues = new PortletParamValuesMap(request);
+ }
+ return (paramValues);
+ }
+
+ public Map getRequestScope() {
+ if ((requestScope == null) && (request != null)) {
+ requestScope = new PortletRequestScopeMap(request);
+ }
+ return (requestScope);
+ }
+
+ public Map getSessionScope() {
+ if ((sessionScope == null) && (request != null)) {
+ sessionScope =
+ new PortletSessionScopeMap(request.getPortletSession());
+ }
+ return (sessionScope);
+ }
+
+ public void dispatch(String path) throws IOException, Exception {
+ include(path);
+ }
+
+ public void include(String path) throws IOException, Exception {
+ if (isRenderRequest) {
+ context.getRequestDispatcher(path).include((RenderRequest) request,
+ (RenderResponse) response);
+ }
+ }
+
+ public URL getResource(String path) throws MalformedURLException {
+ return context.getResource(path);
+ }
+
+ public Locale getRequestLocale() {
+ if (request != null) {
+ return request.getLocale();
+ } else {
+ return null;
+ }
+ }
+
+}
Propchange: struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/context/portlet/PortletTilesContext.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/context/portlet/PortletTilesContext.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Added: struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/context/servlet/ServletApplicationScopeMap.java
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/context/servlet/ServletApplicationScopeMap.java?rev=405486&view=auto
==============================================================================
--- struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/context/servlet/ServletApplicationScopeMap.java (added)
+++ struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/context/servlet/ServletApplicationScopeMap.java Tue May 9 10:55:29 2006
@@ -0,0 +1,181 @@
+/*
+ * $Id$
+ *
+ * Copyright 1999-2004 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.tiles.context.servlet;
+
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Enumeration;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import javax.servlet.ServletContext;
+import org.apache.tiles.context.MapEntry;
+
+
+/**
+ * <p>Private implementation of <code>Map</code> for servlet context
+ * attributes.</p>
+ *
+ * @version $Revision$ $Date$
+ */
+
+final class ServletApplicationScopeMap implements Map {
+
+
+ public ServletApplicationScopeMap(ServletContext context) {
+ this.context = context;
+ }
+
+
+ private ServletContext context = null;
+
+
+ public void clear() {
+ Iterator keys = keySet().iterator();
+ while (keys.hasNext()) {
+ context.removeAttribute((String) keys.next());
+ }
+ }
+
+
+ public boolean containsKey(Object key) {
+ return (context.getAttribute(key(key)) != null);
+ }
+
+
+ public boolean containsValue(Object value) {
+ if (value == null) {
+ return (false);
+ }
+ Enumeration keys = context.getAttributeNames();
+ while (keys.hasMoreElements()) {
+ Object next = context.getAttribute((String) keys.nextElement());
+ if (next == value) {
+ return (true);
+ }
+ }
+ return (false);
+ }
+
+
+ public Set entrySet() {
+ Set set = new HashSet();
+ Enumeration keys = context.getAttributeNames();
+ String key;
+ while (keys.hasMoreElements()) {
+ key = (String)keys.nextElement();
+ set.add(new MapEntry(key, context.getAttribute(key), true));
+ }
+ return (set);
+ }
+
+
+ public boolean equals(Object o) {
+ return (context.equals(o));
+ }
+
+
+ public Object get(Object key) {
+ return (context.getAttribute(key(key)));
+ }
+
+
+ public int hashCode() {
+ return (context.hashCode());
+ }
+
+
+ public boolean isEmpty() {
+ return (size() < 1);
+ }
+
+
+ public Set keySet() {
+ Set set = new HashSet();
+ Enumeration keys = context.getAttributeNames();
+ while (keys.hasMoreElements()) {
+ set.add(keys.nextElement());
+ }
+ return (set);
+ }
+
+
+ public Object put(Object key, Object value) {
+ if (value == null) {
+ return (remove(key));
+ }
+ String skey = key(key);
+ Object previous = context.getAttribute(skey);
+ context.setAttribute(skey, value);
+ return (previous);
+ }
+
+
+ public void putAll(Map map) {
+ Iterator keys = map.keySet().iterator();
+ while (keys.hasNext()) {
+ String key = (String) keys.next();
+ context.setAttribute(key, map.get(key));
+ }
+ }
+
+
+ public Object remove(Object key) {
+ String skey = key(key);
+ Object previous = context.getAttribute(skey);
+ context.removeAttribute(skey);
+ return (previous);
+ }
+
+
+ public int size() {
+ int n = 0;
+ Enumeration keys = context.getAttributeNames();
+ while (keys.hasMoreElements()) {
+ keys.nextElement();
+ n++;
+ }
+ return (n);
+ }
+
+
+ public Collection values() {
+ List list = new ArrayList();
+ Enumeration keys = context.getAttributeNames();
+ while (keys.hasMoreElements()) {
+ list.add(context.getAttribute((String) keys.nextElement()));
+ }
+ return (list);
+ }
+
+
+ private String key(Object key) {
+ if (key == null) {
+ throw new IllegalArgumentException();
+ } else if (key instanceof String) {
+ return ((String) key);
+ } else {
+ return (key.toString());
+ }
+ }
+
+
+}
Propchange: struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/context/servlet/ServletApplicationScopeMap.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/context/servlet/ServletApplicationScopeMap.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Added: struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/context/servlet/ServletHeaderMap.java
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/context/servlet/ServletHeaderMap.java?rev=405486&view=auto
==============================================================================
--- struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/context/servlet/ServletHeaderMap.java (added)
+++ struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/context/servlet/ServletHeaderMap.java Tue May 9 10:55:29 2006
@@ -0,0 +1,161 @@
+/*
+ * $Id$
+ *
+ * Copyright 1999-2004 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.tiles.context.servlet;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Enumeration;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import javax.servlet.http.HttpServletRequest;
+import org.apache.tiles.context.MapEntry;
+
+
+/**
+ * <p>Private implementation of <code>Map</code> for servlet request
+ * name-value.</p>
+ *
+ * @author Craig R. McClanahan
+ * @version $Revision$ $Date$
+ */
+
+final class ServletHeaderMap implements Map {
+
+
+ public ServletHeaderMap(HttpServletRequest request) {
+ this.request = request;
+ }
+
+
+ private HttpServletRequest request = null;
+
+
+ public void clear() {
+ throw new UnsupportedOperationException();
+ }
+
+
+ public boolean containsKey(Object key) {
+ return (request.getHeader(key(key)) != null);
+ }
+
+
+ public boolean containsValue(Object value) {
+ Iterator values = values().iterator();
+ while (values.hasNext()) {
+ if (value.equals(values.next())) {
+ return (true);
+ }
+ }
+ return (false);
+ }
+
+
+ public Set entrySet() {
+ Set set = new HashSet();
+ Enumeration keys = request.getHeaderNames();
+ String key;
+ while (keys.hasMoreElements()) {
+ key = (String) keys.nextElement();
+ set.add(new MapEntry(key, request.getHeader(key), false));
+ }
+ return (set);
+ }
+
+
+ public boolean equals(Object o) {
+ return (request.equals(o));
+ }
+
+
+ public Object get(Object key) {
+ return (request.getHeader(key(key)));
+ }
+
+
+ public int hashCode() {
+ return (request.hashCode());
+ }
+
+
+ public boolean isEmpty() {
+ return (size() < 1);
+ }
+
+
+ public Set keySet() {
+ Set set = new HashSet();
+ Enumeration keys = request.getHeaderNames();
+ while (keys.hasMoreElements()) {
+ set.add(keys.nextElement());
+ }
+ return (set);
+ }
+
+
+ public Object put(Object key, Object value) {
+ throw new UnsupportedOperationException();
+ }
+
+
+ public void putAll(Map map) {
+ throw new UnsupportedOperationException();
+ }
+
+
+ public Object remove(Object key) {
+ throw new UnsupportedOperationException();
+ }
+
+
+ public int size() {
+ int n = 0;
+ Enumeration keys = request.getHeaderNames();
+ while (keys.hasMoreElements()) {
+ keys.nextElement();
+ n++;
+ }
+ return (n);
+ }
+
+
+ public Collection values() {
+ List list = new ArrayList();
+ Enumeration keys = request.getHeaderNames();
+ while (keys.hasMoreElements()) {
+ list.add(request.getHeader((String) keys.nextElement()));
+ }
+ return (list);
+ }
+
+
+ private String key(Object key) {
+ if (key == null) {
+ throw new IllegalArgumentException();
+ } else if (key instanceof String) {
+ return ((String) key);
+ } else {
+ return (key.toString());
+ }
+ }
+
+
+}
\ No newline at end of file
Propchange: struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/context/servlet/ServletHeaderMap.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/context/servlet/ServletHeaderMap.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Added: struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/context/servlet/ServletHeaderValuesMap.java
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/context/servlet/ServletHeaderValuesMap.java?rev=405486&view=auto
==============================================================================
--- struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/context/servlet/ServletHeaderValuesMap.java (added)
+++ struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/context/servlet/ServletHeaderValuesMap.java Tue May 9 10:55:29 2006
@@ -0,0 +1,186 @@
+/*
+ * $Id$
+ *
+ * Copyright 1999-2004 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.tiles.context.servlet;
+
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Enumeration;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import javax.servlet.http.HttpServletRequest;
+import org.apache.tiles.context.MapEntry;
+
+
+/**
+ * <p>Private implementation of <code>Map</code> for servlet request
+ * name-values[].</p>
+ *
+ * @version $Revision$ $Date$
+ */
+
+final class ServletHeaderValuesMap implements Map {
+
+
+ public ServletHeaderValuesMap(HttpServletRequest request) {
+ this.request = request;
+ }
+
+
+ private HttpServletRequest request = null;
+
+
+ public void clear() {
+ throw new UnsupportedOperationException();
+ }
+
+
+ public boolean containsKey(Object key) {
+ return (request.getHeader(key(key)) != null);
+ }
+
+
+ public boolean containsValue(Object value) {
+ if (!(value instanceof String[])) {
+ return (false);
+ }
+ String[] test = (String[]) value;
+ Iterator values = values().iterator();
+ while (values.hasNext()) {
+ String[] actual = (String[]) values.next();
+ if (test.length == actual.length) {
+ boolean matched = true;
+ for (int i = 0; i < test.length; i++) {
+ if (!test[i].equals(actual[i])) {
+ matched = false;
+ break;
+ }
+ }
+ if (matched) {
+ return (true);
+ }
+ }
+ }
+ return (false);
+ }
+
+
+ public Set entrySet() {
+ Set set = new HashSet();
+ Enumeration keys = request.getHeaderNames();
+ String key;
+ while (keys.hasMoreElements()) {
+ key = (String) keys.nextElement();
+ set.add(new MapEntry(key, request.getHeaders(key), false));
+ }
+ return (set);
+ }
+
+
+ public boolean equals(Object o) {
+ return (request.equals(o));
+ }
+
+
+ public Object get(Object key) {
+ List list = new ArrayList();
+ Enumeration values = request.getHeaders(key(key));
+ while (values.hasMoreElements()) {
+ list.add((String) values.nextElement());
+ }
+ return (((String[]) list.toArray(new String[list.size()])));
+ }
+
+
+ public int hashCode() {
+ return (request.hashCode());
+ }
+
+
+ public boolean isEmpty() {
+ return (size() < 1);
+ }
+
+
+ public Set keySet() {
+ Set set = new HashSet();
+ Enumeration keys = request.getHeaderNames();
+ while (keys.hasMoreElements()) {
+ set.add(keys.nextElement());
+ }
+ return (set);
+ }
+
+
+ public Object put(Object key, Object value) {
+ throw new UnsupportedOperationException();
+ }
+
+
+ public void putAll(Map map) {
+ throw new UnsupportedOperationException();
+ }
+
+
+ public Object remove(Object key) {
+ throw new UnsupportedOperationException();
+ }
+
+
+ public int size() {
+ int n = 0;
+ Enumeration keys = request.getHeaderNames();
+ while (keys.hasMoreElements()) {
+ keys.nextElement();
+ n++;
+ }
+ return (n);
+ }
+
+
+ public Collection values() {
+ List list = new ArrayList();
+ Enumeration keys = request.getHeaderNames();
+ while (keys.hasMoreElements()) {
+ String key = (String) keys.nextElement();
+ List list1 = new ArrayList();
+ Enumeration values = request.getHeaders(key);
+ while (values.hasMoreElements()) {
+ list1.add((String) values.nextElement());
+ }
+ list.add(((String[]) list1.toArray(new String[list1.size()])));
+ }
+ return (list);
+ }
+
+
+ private String key(Object key) {
+ if (key == null) {
+ throw new IllegalArgumentException();
+ } else if (key instanceof String) {
+ return ((String) key);
+ } else {
+ return (key.toString());
+ }
+ }
+
+
+}
\ No newline at end of file
Propchange: struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/context/servlet/ServletHeaderValuesMap.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/context/servlet/ServletHeaderValuesMap.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Added: struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/context/servlet/ServletInitParamMap.java
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/context/servlet/ServletInitParamMap.java?rev=405486&view=auto
==============================================================================
--- struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/context/servlet/ServletInitParamMap.java (added)
+++ struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/context/servlet/ServletInitParamMap.java Tue May 9 10:55:29 2006
@@ -0,0 +1,161 @@
+/*
+ * $Id$
+ *
+ * Copyright 1999-2004 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.tiles.context.servlet;
+
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Enumeration;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import javax.servlet.ServletContext;
+import org.apache.tiles.context.MapEntry;
+
+/**
+ * <p>Private implementation of <code>Map</code> for servlet context
+ * init parameters.</p>
+ *
+ * @author Craig R. McClanahan
+ * @version $Revision$ $Date$
+ */
+
+final class ServletInitParamMap implements Map {
+
+
+ public ServletInitParamMap(ServletContext context) {
+ this.context = context;
+ }
+
+
+ private ServletContext context = null;
+
+
+ public void clear() {
+ throw new UnsupportedOperationException();
+ }
+
+
+ public boolean containsKey(Object key) {
+ return (context.getInitParameter(key(key)) != null);
+ }
+
+
+ public boolean containsValue(Object value) {
+ Iterator values = values().iterator();
+ while (values.hasNext()) {
+ if (value.equals(values.next())) {
+ return (true);
+ }
+ }
+ return (false);
+ }
+
+
+ public Set entrySet() {
+ Set set = new HashSet();
+ Enumeration keys = context.getInitParameterNames();
+ String key;
+ while (keys.hasMoreElements()) {
+ key = (String) keys.nextElement();
+ set.add(new MapEntry(key, context.getInitParameter(key), false));
+ }
+ return (set);
+ }
+
+
+ public boolean equals(Object o) {
+ return (context.equals(o));
+ }
+
+
+ public Object get(Object key) {
+ return (context.getInitParameter(key(key)));
+ }
+
+
+ public int hashCode() {
+ return (context.hashCode());
+ }
+
+
+ public boolean isEmpty() {
+ return (size() < 1);
+ }
+
+
+ public Set keySet() {
+ Set set = new HashSet();
+ Enumeration keys = context.getInitParameterNames();
+ while (keys.hasMoreElements()) {
+ set.add(keys.nextElement());
+ }
+ return (set);
+ }
+
+
+ public Object put(Object key, Object value) {
+ throw new UnsupportedOperationException();
+ }
+
+
+ public void putAll(Map map) {
+ throw new UnsupportedOperationException();
+ }
+
+
+ public Object remove(Object key) {
+ throw new UnsupportedOperationException();
+ }
+
+
+ public int size() {
+ int n = 0;
+ Enumeration keys = context.getInitParameterNames();
+ while (keys.hasMoreElements()) {
+ keys.nextElement();
+ n++;
+ }
+ return (n);
+ }
+
+
+ public Collection values() {
+ List list = new ArrayList();
+ Enumeration keys = context.getInitParameterNames();
+ while (keys.hasMoreElements()) {
+ list.add(context.getInitParameter((String) keys.nextElement()));
+ }
+ return (list);
+ }
+
+
+ private String key(Object key) {
+ if (key == null) {
+ throw new IllegalArgumentException();
+ } else if (key instanceof String) {
+ return ((String) key);
+ } else {
+ return (key.toString());
+ }
+ }
+
+
+}
\ No newline at end of file
Propchange: struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/context/servlet/ServletInitParamMap.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/context/servlet/ServletInitParamMap.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Added: struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/context/servlet/ServletParamMap.java
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/context/servlet/ServletParamMap.java?rev=405486&view=auto
==============================================================================
--- struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/context/servlet/ServletParamMap.java (added)
+++ struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/context/servlet/ServletParamMap.java Tue May 9 10:55:29 2006
@@ -0,0 +1,162 @@
+/*
+ * $Id$
+ *
+ * Copyright 1999-2004 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.tiles.context.servlet;
+
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Enumeration;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import javax.servlet.http.HttpServletRequest;
+import org.apache.tiles.context.MapEntry;
+
+
+/**
+ * <p>Private implementation of <code>Map</code> for servlet parameter
+ * name-value.</p>
+ *
+ * @author Craig R. McClanahan
+ * @version $Revision$ $Date$
+ */
+
+final class ServletParamMap implements Map {
+
+
+ public ServletParamMap(HttpServletRequest request) {
+ this.request = request;
+ }
+
+
+ private HttpServletRequest request = null;
+
+
+ public void clear() {
+ throw new UnsupportedOperationException();
+ }
+
+
+ public boolean containsKey(Object key) {
+ return (request.getParameter(key(key)) != null);
+ }
+
+
+ public boolean containsValue(Object value) {
+ Iterator values = values().iterator();
+ while (values.hasNext()) {
+ if (value.equals(values.next())) {
+ return (true);
+ }
+ }
+ return (false);
+ }
+
+
+ public Set entrySet() {
+ Set set = new HashSet();
+ Enumeration keys = request.getParameterNames();
+ String key;
+ while (keys.hasMoreElements()) {
+ key = (String)keys.nextElement();
+ set.add(new MapEntry(key, request.getParameter(key), false));
+ }
+ return (set);
+ }
+
+
+ public boolean equals(Object o) {
+ return (request.equals(o));
+ }
+
+
+ public Object get(Object key) {
+ return (request.getParameter(key(key)));
+ }
+
+
+ public int hashCode() {
+ return (request.hashCode());
+ }
+
+
+ public boolean isEmpty() {
+ return (size() < 1);
+ }
+
+
+ public Set keySet() {
+ Set set = new HashSet();
+ Enumeration keys = request.getParameterNames();
+ while (keys.hasMoreElements()) {
+ set.add(keys.nextElement());
+ }
+ return (set);
+ }
+
+
+ public Object put(Object key, Object value) {
+ throw new UnsupportedOperationException();
+ }
+
+
+ public void putAll(Map map) {
+ throw new UnsupportedOperationException();
+ }
+
+
+ public Object remove(Object key) {
+ throw new UnsupportedOperationException();
+ }
+
+
+ public int size() {
+ int n = 0;
+ Enumeration keys = request.getParameterNames();
+ while (keys.hasMoreElements()) {
+ keys.nextElement();
+ n++;
+ }
+ return (n);
+ }
+
+
+ public Collection values() {
+ List list = new ArrayList();
+ Enumeration keys = request.getParameterNames();
+ while (keys.hasMoreElements()) {
+ list.add(request.getParameter((String) keys.nextElement()));
+ }
+ return (list);
+ }
+
+
+ private String key(Object key) {
+ if (key == null) {
+ throw new IllegalArgumentException();
+ } else if (key instanceof String) {
+ return ((String) key);
+ } else {
+ return (key.toString());
+ }
+ }
+
+
+}
Propchange: struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/context/servlet/ServletParamMap.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/context/servlet/ServletParamMap.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Added: struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/context/servlet/ServletParamValuesMap.java
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/context/servlet/ServletParamValuesMap.java?rev=405486&view=auto
==============================================================================
--- struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/context/servlet/ServletParamValuesMap.java (added)
+++ struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/context/servlet/ServletParamValuesMap.java Tue May 9 10:55:29 2006
@@ -0,0 +1,161 @@
+/*
+ * $Id$
+ *
+ * Copyright 1999-2004 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.tiles.context.servlet;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Enumeration;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import javax.servlet.ServletRequest;
+import org.apache.tiles.context.MapEntry;
+
+
+/**
+ * <p>Private implementation of <code>Map</code> for servlet parameter
+ * name-values[].</p>
+ *
+ * @author Craig R. McClanahan
+ * @version $Revision$ $Date$
+ */
+
+final class ServletParamValuesMap implements Map {
+
+
+ public ServletParamValuesMap(ServletRequest request) {
+ this.request = request;
+ }
+
+
+ private ServletRequest request = null;
+
+
+ public void clear() {
+ throw new UnsupportedOperationException();
+ }
+
+
+ public boolean containsKey(Object key) {
+ return (request.getParameter(key(key)) != null);
+ }
+
+
+ public boolean containsValue(Object value) {
+ Iterator values = values().iterator();
+ while (values.hasNext()) {
+ if (value.equals(values.next())) {
+ return (true);
+ }
+ }
+ return (false);
+ }
+
+
+ public Set entrySet() {
+ Set set = new HashSet();
+ Enumeration keys = request.getParameterNames();
+ String key;
+ while (keys.hasMoreElements()) {
+ key = (String) keys.nextElement();
+ set.add(new MapEntry(key, request.getParameterValues(key), false));
+ }
+ return (set);
+ }
+
+
+ public boolean equals(Object o) {
+ return (request.equals(o));
+ }
+
+
+ public Object get(Object key) {
+ return (request.getParameterValues(key(key)));
+ }
+
+
+ public int hashCode() {
+ return (request.hashCode());
+ }
+
+
+ public boolean isEmpty() {
+ return (size() < 1);
+ }
+
+
+ public Set keySet() {
+ Set set = new HashSet();
+ Enumeration keys = request.getParameterNames();
+ while (keys.hasMoreElements()) {
+ set.add(keys.nextElement());
+ }
+ return (set);
+ }
+
+
+ public Object put(Object key, Object value) {
+ throw new UnsupportedOperationException();
+ }
+
+
+ public void putAll(Map map) {
+ throw new UnsupportedOperationException();
+ }
+
+
+ public Object remove(Object key) {
+ throw new UnsupportedOperationException();
+ }
+
+
+ public int size() {
+ int n = 0;
+ Enumeration keys = request.getParameterNames();
+ while (keys.hasMoreElements()) {
+ keys.nextElement();
+ n++;
+ }
+ return (n);
+ }
+
+
+ public Collection values() {
+ List list = new ArrayList();
+ Enumeration keys = request.getParameterNames();
+ while (keys.hasMoreElements()) {
+ list.add(request.getParameterValues((String) keys.nextElement()));
+ }
+ return (list);
+ }
+
+
+ private String key(Object key) {
+ if (key == null) {
+ throw new IllegalArgumentException();
+ } else if (key instanceof String) {
+ return ((String) key);
+ } else {
+ return (key.toString());
+ }
+ }
+
+
+}
\ No newline at end of file
Propchange: struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/context/servlet/ServletParamValuesMap.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/context/servlet/ServletParamValuesMap.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL