Source Code Cross Referenced for MessagesMap.java in  » Web-Framework » struts-1.3.8 » org » apache » struts » faces » util » 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 1.3.8 » org.apache.struts.faces.util 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * $Id: MessagesMap.java 471754 2006-11-06 14:55:09Z 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:
022:        package org.apache.struts.faces.util;
023:
024:        import java.util.Collection;
025:        import java.util.Locale;
026:        import java.util.Map;
027:        import java.util.Set;
028:
029:        import org.apache.struts.util.MessageResources;
030:
031:        /**
032:         * <p>A limited immutable <code>Map</code> implementation that wraps the
033:         * <code>MessageResources</code> instance for the specified
034:         * <code>Locale</code>.  Exposing the messages as a <code>Map</code>
035:         * makes them easily accessible via value binding expressions, as
036:         * well as JSP 2.0 expression language expressions.
037:         */
038:
039:        public class MessagesMap implements  Map {
040:
041:            // ------------------------------------------------------------ Constructors
042:
043:            /**
044:             * <p>Construct a new {@link MessagesMap} instance that wraps the
045:             * specified <code>MessageResources</code> instance, and returns messages
046:             * for the specified <code>Locale</code>.</p>
047:             *
048:             * @param messages <code>MessageResources</code> instance to wrap
049:             * @param locale <code>Locale</code> for which to retrieve messages,
050:             *  or <code>null</code> for the system default <code>Locale</code>
051:             *
052:             * @exception NullPointerException if <code>messages</code>
053:             *  is <code>null</code>
054:             */
055:            public MessagesMap(MessageResources messages, Locale locale) {
056:
057:                super ();
058:                if (messages == null) {
059:                    throw new NullPointerException();
060:                }
061:                this .messages = messages;
062:                this .locale = locale;
063:
064:            }
065:
066:            // ------------------------------------------------------ Instance Variables
067:
068:            /**
069:             * <p>The <code>Locale</code> for which to return messages, or
070:             * <code>null</code> for the system default <code>Locale</code>.</p>
071:             */
072:            private Locale locale = null;
073:
074:            /**
075:             * <p>The <code>MessageResources</code> being wrapped by this
076:             * {@link MessagesMap}.</p>
077:             */
078:            private MessageResources messages = null;
079:
080:            // ---------------------------------------------------------- Public Methods
081:
082:            /**
083:             * <p>The <code>clear()</code> method is not supported.</p>
084:             */
085:            public void clear() {
086:
087:                throw new UnsupportedOperationException();
088:
089:            }
090:
091:            /**
092:             * <p>Return <code>true</code> if there is a message for the
093:             * specified key.</p>
094:             *
095:             * @param key Message key to evaluate
096:             */
097:            public boolean containsKey(Object key) {
098:
099:                if (key == null) {
100:                    return (false);
101:                } else {
102:                    return (messages.isPresent(locale, key.toString()));
103:                }
104:
105:            }
106:
107:            /**
108:             * <p>The <code>containsValue()</code> method is not supported.</p>
109:             *
110:             * @param value Value to evaluate
111:             */
112:            public boolean containsValue(Object value) {
113:
114:                throw new UnsupportedOperationException();
115:
116:            }
117:
118:            /**
119:             * <p>The <code>entrySet()</code> method is not supported.</p>
120:             */
121:            public Set entrySet() {
122:
123:                throw new UnsupportedOperationException();
124:
125:            }
126:
127:            /**
128:             * <p>The <code>equals</code> method checks whether equal
129:             * <code>MessageResources</code> and <code>Locale</code> are
130:             * being wrapped.</p>
131:             *
132:             * @param o The object to be compared
133:             */
134:            public boolean equals(Object o) {
135:
136:                if (!(o instanceof  MessagesMap)) {
137:                    return (false);
138:                }
139:                MessagesMap other = (MessagesMap) o;
140:                if (!messages.equals(other.getMessages())) {
141:                    return (false);
142:                }
143:                if (locale == null) {
144:                    return (other.getLocale() == null);
145:                } else {
146:                    return (locale.equals(other.getLocale()));
147:                }
148:
149:            }
150:
151:            /**
152:             * <p>Return the message string for the specified key.</p>
153:             *
154:             * @param key Key for message to return
155:             */
156:            public Object get(Object key) {
157:
158:                if (key == null) {
159:                    return ("??????");
160:                } else {
161:                    return (messages.getMessage(locale, key.toString()));
162:                }
163:
164:            }
165:
166:            /**
167:             * <p>The <code>hashCode()</code> method returns values that will
168:             * be identical if the <code>equals</code> method returns <code>true</code>.
169:             * </p>
170:             */
171:            public int hashCode() {
172:
173:                int value = messages.hashCode();
174:                if (locale != null) {
175:                    value = value ^ locale.hashCode();
176:                }
177:                return (value);
178:
179:            }
180:
181:            /**
182:             * <p>The <code>isEmpty()</code> method returns <code>false</code>, on the
183:             * assumption that there is always at least one message available.</p>
184:             */
185:            public boolean isEmpty() {
186:
187:                return (false);
188:
189:            }
190:
191:            /**
192:             * <p>The <code>keySet()</code> method is not supported.</p>
193:             */
194:            public Set keySet() {
195:
196:                throw new UnsupportedOperationException();
197:
198:            }
199:
200:            /**
201:             * <p>The <code>put()</code> method is not supported.</p>
202:             *
203:             * @param key Key to store
204:             * @param value Value to store
205:             */
206:            public Object put(Object key, Object value) {
207:
208:                throw new UnsupportedOperationException();
209:
210:            }
211:
212:            /**
213:             * <p>The <code>putAll()</code> method is not supported.</p>
214:             *
215:             * @param map Keys and values to store
216:             */
217:            public void putAll(Map map) {
218:
219:                throw new UnsupportedOperationException();
220:
221:            }
222:
223:            /**
224:             * <p>The <code>remove()</code> method is not supported.</p>
225:             *
226:             * @param key Key to remove
227:             */
228:            public Object remove(Object key) {
229:
230:                throw new UnsupportedOperationException();
231:
232:            }
233:
234:            /**
235:             * <p>The <code>size()</code> method is not supported.</p>
236:             */
237:            public int size() {
238:
239:                throw new UnsupportedOperationException();
240:
241:            }
242:
243:            /**
244:             * <p>The <code>values()</code> method is not supported.</p>
245:             */
246:            public Collection values() {
247:
248:                throw new UnsupportedOperationException();
249:
250:            }
251:
252:            // --------------------------------------------------------- Package Methods
253:
254:            /**
255:             * <p>Return the <code>Locale</code> we object we are wrapping.</p>
256:             */
257:            Locale getLocale() {
258:
259:                return (this .locale);
260:
261:            }
262:
263:            /**
264:             * <p>Return the <code>MessageResources</code> object we are wrapping.</p>
265:             */
266:            MessageResources getMessages() {
267:
268:                return (this.messages);
269:
270:            }
271:
272:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.