Source Code Cross Referenced for MapMessageResources.java in  » Testing » mockrunner-0.4 » com » mockrunner » struts » 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 » Testing » mockrunner 0.4 » com.mockrunner.struts 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package com.mockrunner.struts;
002:
003:        import java.io.File;
004:        import java.io.FileInputStream;
005:        import java.util.HashMap;
006:        import java.util.Locale;
007:        import java.util.Map;
008:        import java.util.Properties;
009:
010:        import org.apache.commons.logging.Log;
011:        import org.apache.commons.logging.LogFactory;
012:        import org.apache.struts.util.MessageResources;
013:        import org.apache.struts.util.MessageResourcesFactory;
014:
015:        /**
016:         * This implementation of <code>MessageResources</code>
017:         * takes the messages from a <code>Map</code> and can be
018:         * used for testing purposes. The <code>Map</code> can
019:         * also be filled with the contents of a property file.
020:         * Note: This implementation ignores the specified <code>Locale</code>.
021:         */
022:        public class MapMessageResources extends MessageResources {
023:            private final static Log log = LogFactory
024:                    .getLog(MapMessageResources.class);
025:            private Map messages;
026:
027:            /**
028:             * Creates an empty resources object
029:             */
030:            public MapMessageResources() {
031:                this (null);
032:            }
033:
034:            /**
035:             * Creates a resources object based on the specified
036:             * map.
037:             * @param messages the map of messages
038:             */
039:            public MapMessageResources(Map messages) {
040:                this (messages, null, "", true);
041:            }
042:
043:            /**
044:             * Creates a resources object based on the specified
045:             * map.
046:             * @param messages the map of messages
047:             * @param factory the MessageResourcesFactory that created us
048:             * @param config the configuration parameter
049:             */
050:            public MapMessageResources(Map messages,
051:                    MessageResourcesFactory factory, String config) {
052:                super (factory, config);
053:                this .messages = messages;
054:                if (null == this .messages)
055:                    this .messages = new HashMap();
056:            }
057:
058:            /**
059:             * Creates a resources object based on the specified
060:             * map.
061:             * @param messages the map of messages
062:             * @param factory the MessageResourcesFactory that created us
063:             * @param config the configuration parameter
064:             * @param returnNull the returnNull property
065:             */
066:            public MapMessageResources(Map messages,
067:                    MessageResourcesFactory factory, String config,
068:                    boolean returnNull) {
069:                super (factory, config, returnNull);
070:                this .messages = messages;
071:                if (null == this .messages)
072:                    this .messages = new HashMap();
073:            }
074:
075:            /**
076:             * Returns the message for the specified key. The locale
077:             * is ignored.
078:             * @param locale the locale (ignored)
079:             * @param key the message key
080:             * @return the message
081:             */
082:            public String getMessage(Locale locale, String key) {
083:                return (String) messages.get(key);
084:            }
085:
086:            /**
087:             * Adds a message for the specified key.
088:             * @param key the message key
089:             * @param value the message
090:             */
091:            public void putMessage(String key, String value) {
092:                messages.put(key, value);
093:            }
094:
095:            /**
096:             * Adds all messages in the specified map.
097:             * @param messages the message map
098:             */
099:            public void putMessages(Map messages) {
100:                this .messages.putAll(messages);
101:            }
102:
103:            /**
104:             * Loads a property file and adds all messages
105:             * from the file.
106:             * @param propertyFileName the file name
107:             */
108:            public void putMessages(String propertyFileName) {
109:                putMessages(new File(propertyFileName));
110:            }
111:
112:            /**
113:             * Loads a property file and adds all messages
114:             * from the file.
115:             * @param propertyFile the file
116:             */
117:            public void putMessages(File propertyFile) {
118:                try {
119:                    FileInputStream inputStream = new FileInputStream(
120:                            propertyFile);
121:                    Properties properties = new Properties();
122:                    properties.load(inputStream);
123:                    putMessages(properties);
124:                } catch (Exception exc) {
125:                    log.error(exc.getMessage(), exc);
126:                }
127:            }
128:
129:            /**
130:             * Clears all messages.
131:             */
132:            public void clear() {
133:                super.formats.clear();
134:                messages.clear();
135:            }
136:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.