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


001:        /*
002:         * Copyright (c) 2002-2006 by OpenSymphony
003:         * All rights reserved.
004:         */
005:        package com.opensymphony.webwork.portlet;
006:
007:        import java.io.Serializable;
008:        import java.util.AbstractMap;
009:        import java.util.Enumeration;
010:        import java.util.HashSet;
011:        import java.util.Map;
012:        import java.util.Set;
013:
014:        import javax.portlet.PortletContext;
015:
016:        /**
017:         * Portlet specific {@link java.util.Map} implementation representing the
018:         * {@link javax.portlet.PortletContext} of a Portlet.
019:         * 
020:         * @author Nils-Helge Garli
021:         */
022:        public class PortletApplicationMap extends AbstractMap implements 
023:                Serializable {
024:
025:            PortletContext context;
026:
027:            Set entries;
028:
029:            /**
030:             * Creates a new map object given the {@link PortletContext}.
031:             * 
032:             * @param ctx The portlet context.
033:             */
034:            public PortletApplicationMap(PortletContext ctx) {
035:                this .context = ctx;
036:            }
037:
038:            /**
039:             * Removes all entries from the Map and removes all attributes from the
040:             * portlet context.
041:             */
042:            public void clear() {
043:                entries = null;
044:
045:                Enumeration e = context.getAttributeNames();
046:
047:                while (e.hasMoreElements()) {
048:                    context.removeAttribute(e.nextElement().toString());
049:                }
050:            }
051:
052:            /**
053:             * Creates a Set of all portlet context attributes as well as context init
054:             * parameters.
055:             * 
056:             * @return a Set of all portlet context attributes as well as context init
057:             *         parameters.
058:             */
059:            public Set entrySet() {
060:                if (entries == null) {
061:                    entries = new HashSet();
062:
063:                    // Add portlet context attributes
064:                    Enumeration enumeration = context.getAttributeNames();
065:
066:                    while (enumeration.hasMoreElements()) {
067:                        final String key = enumeration.nextElement().toString();
068:                        final Object value = context.getAttribute(key);
069:                        entries.add(new Map.Entry() {
070:                            public boolean equals(Object obj) {
071:                                Map.Entry entry = (Map.Entry) obj;
072:
073:                                return ((key == null) ? (entry.getKey() == null)
074:                                        : key.equals(entry.getKey()))
075:                                        && ((value == null) ? (entry.getValue() == null)
076:                                                : value
077:                                                        .equals(entry
078:                                                                .getValue()));
079:                            }
080:
081:                            public int hashCode() {
082:                                return ((key == null) ? 0 : key.hashCode())
083:                                        ^ ((value == null) ? 0 : value
084:                                                .hashCode());
085:                            }
086:
087:                            public Object getKey() {
088:                                return key;
089:                            }
090:
091:                            public Object getValue() {
092:                                return value;
093:                            }
094:
095:                            public Object setValue(Object obj) {
096:                                context.setAttribute(key.toString(), obj);
097:
098:                                return value;
099:                            }
100:                        });
101:                    }
102:
103:                    // Add portlet context init params
104:                    enumeration = context.getInitParameterNames();
105:
106:                    while (enumeration.hasMoreElements()) {
107:                        final String key = enumeration.nextElement().toString();
108:                        final Object value = context.getInitParameter(key);
109:                        entries.add(new Map.Entry() {
110:                            public boolean equals(Object obj) {
111:                                Map.Entry entry = (Map.Entry) obj;
112:
113:                                return ((key == null) ? (entry.getKey() == null)
114:                                        : key.equals(entry.getKey()))
115:                                        && ((value == null) ? (entry.getValue() == null)
116:                                                : value
117:                                                        .equals(entry
118:                                                                .getValue()));
119:                            }
120:
121:                            public int hashCode() {
122:                                return ((key == null) ? 0 : key.hashCode())
123:                                        ^ ((value == null) ? 0 : value
124:                                                .hashCode());
125:                            }
126:
127:                            public Object getKey() {
128:                                return key;
129:                            }
130:
131:                            public Object getValue() {
132:                                return value;
133:                            }
134:
135:                            public Object setValue(Object obj) {
136:                                context.setAttribute(key.toString(), obj);
137:
138:                                return value;
139:                            }
140:                        });
141:                    }
142:                }
143:
144:                return entries;
145:            }
146:
147:            /**
148:             * Returns the portlet context attribute or init parameter based on the
149:             * given key. If the entry is not found, <tt>null</tt> is returned.
150:             * 
151:             * @param key
152:             *            the entry key.
153:             * @return the portlet context attribute or init parameter or <tt>null</tt>
154:             *         if the entry is not found.
155:             */
156:            public Object get(Object key) {
157:                // Try context attributes first, then init params
158:                // This gives the proper shadowing effects
159:                String keyString = key.toString();
160:                Object value = context.getAttribute(keyString);
161:
162:                return (value == null) ? context.getInitParameter(keyString)
163:                        : value;
164:            }
165:
166:            /**
167:             * Sets a portlet context attribute given a attribute name and value.
168:             * 
169:             * @param key
170:             *            the name of the attribute.
171:             * @param value
172:             *            the value to set.
173:             * @return the attribute that was just set.
174:             */
175:            public Object put(Object key, Object value) {
176:                entries = null;
177:                context.setAttribute(key.toString(), value);
178:
179:                return get(key);
180:            }
181:
182:            /**
183:             * Removes the specified portlet context attribute.
184:             * 
185:             * @param key
186:             *            the attribute to remove.
187:             * @return the entry that was just removed.
188:             */
189:            public Object remove(Object key) {
190:                entries = null;
191:
192:                Object value = get(key);
193:                context.removeAttribute(key.toString());
194:
195:                return value;
196:            }
197:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.