Source Code Cross Referenced for RequestMap.java in  » Web-Framework » struts-2.0.11 » org » apache » struts2 » dispatcher » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Web Framework » struts 2.0.11 » org.apache.struts2.dispatcher 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * $Id: RequestMap.java 471756 2006-11-06 15:01:43Z husted $
003:         *
004:         * Licensed to the Apache Software Foundation (ASF) under one
005:         * or more contributor license agreements.  See the NOTICE file
006:         * distributed with this work for additional information
007:         * regarding copyright ownership.  The ASF licenses this file
008:         * to you under the Apache License, Version 2.0 (the
009:         * "License"); you may not use this file except in compliance
010:         * with the License.  You may obtain a copy of the License at
011:         *
012:         *  http://www.apache.org/licenses/LICENSE-2.0
013:         *
014:         * Unless required by applicable law or agreed to in writing,
015:         * software distributed under the License is distributed on an
016:         * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
017:         * KIND, either express or implied.  See the License for the
018:         * specific language governing permissions and limitations
019:         * under the License.
020:         */
021:        package org.apache.struts2.dispatcher;
022:
023:        import java.io.Serializable;
024:        import java.util.AbstractMap;
025:        import java.util.Enumeration;
026:        import java.util.HashSet;
027:        import java.util.Set;
028:
029:        import javax.servlet.http.HttpServletRequest;
030:
031:        /**
032:         * A simple implementation of the {@link java.util.Map} interface to handle a collection of request attributes.
033:         */
034:        public class RequestMap extends AbstractMap implements  Serializable {
035:
036:            private static final long serialVersionUID = -7675640869293787926L;
037:
038:            private Set<Object> entries;
039:            private HttpServletRequest request;
040:
041:            /**
042:             * Saves the request to use as the backing for getting and setting values
043:             *
044:             * @param request the http servlet request.
045:             */
046:            public RequestMap(final HttpServletRequest request) {
047:                this .request = request;
048:            }
049:
050:            /**
051:             * Removes all attributes from the request as well as clears entries in this map.
052:             */
053:            public void clear() {
054:                entries = null;
055:                Enumeration keys = request.getAttributeNames();
056:
057:                while (keys.hasMoreElements()) {
058:                    String key = (String) keys.nextElement();
059:                    request.removeAttribute(key);
060:                }
061:            }
062:
063:            /**
064:             * Returns a Set of attributes from the http request.
065:             *
066:             * @return a Set of attributes from the http request.
067:             */
068:            public Set entrySet() {
069:                if (entries == null) {
070:                    entries = new HashSet<Object>();
071:
072:                    Enumeration enumeration = request.getAttributeNames();
073:
074:                    while (enumeration.hasMoreElements()) {
075:                        final String key = enumeration.nextElement().toString();
076:                        final Object value = request.getAttribute(key);
077:                        entries.add(new Entry() {
078:                            public boolean equals(Object obj) {
079:                                Entry entry = (Entry) obj;
080:
081:                                return ((key == null) ? (entry.getKey() == null)
082:                                        : key.equals(entry.getKey()))
083:                                        && ((value == null) ? (entry.getValue() == null)
084:                                                : value
085:                                                        .equals(entry
086:                                                                .getValue()));
087:                            }
088:
089:                            public int hashCode() {
090:                                return ((key == null) ? 0 : key.hashCode())
091:                                        ^ ((value == null) ? 0 : value
092:                                                .hashCode());
093:                            }
094:
095:                            public Object getKey() {
096:                                return key;
097:                            }
098:
099:                            public Object getValue() {
100:                                return value;
101:                            }
102:
103:                            public Object setValue(Object obj) {
104:                                request.setAttribute(key.toString(), obj);
105:
106:                                return value;
107:                            }
108:                        });
109:                    }
110:                }
111:
112:                return entries;
113:            }
114:
115:            /**
116:             * Returns the request attribute associated with the given key or <tt>null</tt> if it doesn't exist.
117:             *
118:             * @param key the name of the request attribute.
119:             * @return the request attribute or <tt>null</tt> if it doesn't exist.
120:             */
121:            public Object get(Object key) {
122:                return request.getAttribute(key.toString());
123:            }
124:
125:            /**
126:             * Saves an attribute in the request.
127:             *
128:             * @param key   the name of the request attribute.
129:             * @param value the value to set.
130:             * @return the object that was just set.
131:             */
132:            public Object put(Object key, Object value) {
133:                entries = null;
134:                request.setAttribute(key.toString(), value);
135:
136:                return get(key);
137:            }
138:
139:            /**
140:             * Removes the specified request attribute.
141:             *
142:             * @param key the name of the attribute to remove.
143:             * @return the value that was removed or <tt>null</tt> if the value was not found (and hence, not removed).
144:             */
145:            public Object remove(Object key) {
146:                entries = null;
147:
148:                Object value = get(key);
149:                request.removeAttribute(key.toString());
150:
151:                return value;
152:            }
153:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.