Source Code Cross Referenced for RequestMap.java in  » J2EE » webwork-2.2.6 » com » opensymphony » webwork » 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 » J2EE » webwork 2.2.6 » com.opensymphony.webwork.dispatcher 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright (c) 2002-2003 by OpenSymphony
003:         * All rights reserved.
004:         */
005:        package com.opensymphony.webwork.dispatcher;
006:
007:        import javax.servlet.http.HttpServletRequest;
008:        import java.io.Serializable;
009:        import java.util.AbstractMap;
010:        import java.util.Enumeration;
011:        import java.util.HashSet;
012:        import java.util.Set;
013:
014:        /**
015:         * A simple implementation of the {@link java.util.Map} interface to handle a collection of request attributes.
016:         *
017:         * @author Patrick Lightbody
018:         * @author Bill Lynch (docs)
019:         */
020:        public class RequestMap extends AbstractMap implements  Serializable {
021:
022:            Set entries;
023:            private HttpServletRequest request;
024:
025:            /**
026:             * Saves the request to use as the backing for getting and setting values
027:             *
028:             * @param request the http servlet request.
029:             */
030:            public RequestMap(final HttpServletRequest request) {
031:                this .request = request;
032:            }
033:
034:            /**
035:             * Removes all attributes from the request as well as clears entries in this map.
036:             */
037:            public void clear() {
038:                entries = null;
039:                Enumeration keys = request.getAttributeNames();
040:
041:                while (keys.hasMoreElements()) {
042:                    String key = (String) keys.nextElement();
043:                    request.removeAttribute(key);
044:                }
045:            }
046:
047:            /**
048:             * Returns a Set of attributes from the http request.
049:             *
050:             * @return a Set of attributes from the http request.
051:             */
052:            public Set entrySet() {
053:                if (entries == null) {
054:                    entries = new HashSet();
055:
056:                    Enumeration enumeration = request.getAttributeNames();
057:
058:                    while (enumeration.hasMoreElements()) {
059:                        final String key = enumeration.nextElement().toString();
060:                        final Object value = request.getAttribute(key);
061:                        entries.add(new Entry() {
062:                            public boolean equals(Object obj) {
063:                                Entry entry = (Entry) obj;
064:
065:                                return ((key == null) ? (entry.getKey() == null)
066:                                        : key.equals(entry.getKey()))
067:                                        && ((value == null) ? (entry.getValue() == null)
068:                                                : value
069:                                                        .equals(entry
070:                                                                .getValue()));
071:                            }
072:
073:                            public int hashCode() {
074:                                return ((key == null) ? 0 : key.hashCode())
075:                                        ^ ((value == null) ? 0 : value
076:                                                .hashCode());
077:                            }
078:
079:                            public Object getKey() {
080:                                return key;
081:                            }
082:
083:                            public Object getValue() {
084:                                return value;
085:                            }
086:
087:                            public Object setValue(Object obj) {
088:                                request.setAttribute(key.toString(), obj);
089:
090:                                return value;
091:                            }
092:                        });
093:                    }
094:                }
095:
096:                return entries;
097:            }
098:
099:            /**
100:             * Returns the request attribute associated with the given key or <tt>null</tt> if it doesn't exist.
101:             *
102:             * @param key the name of the request attribute.
103:             * @return the request attribute or <tt>null</tt> if it doesn't exist.
104:             */
105:            public Object get(Object key) {
106:                return request.getAttribute(key.toString());
107:            }
108:
109:            /**
110:             * Saves an attribute in the request.
111:             *
112:             * @param key   the name of the request attribute.
113:             * @param value the value to set.
114:             * @return the object that was just set.
115:             */
116:            public Object put(Object key, Object value) {
117:                entries = null;
118:                request.setAttribute(key.toString(), value);
119:
120:                return get(key);
121:            }
122:
123:            /**
124:             * Removes the specified request attribute.
125:             *
126:             * @param key the name of the attribute to remove.
127:             * @return the value that was removed or <tt>null</tt> if the value was not found (and hence, not removed).
128:             */
129:            public Object remove(Object key) {
130:                entries = null;
131:
132:                Object value = get(key);
133:                request.removeAttribute(key.toString());
134:
135:                return value;
136:            }
137:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.