Source Code Cross Referenced for MessageBundle.java in  » Web-Services-AXIS2 » kernal » org » apache » axis2 » i18n » 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 Services AXIS2 » kernal » org.apache.axis2.i18n 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Licensed to the Apache Software Foundation (ASF) under one
003:         * or more contributor license agreements. See the NOTICE file
004:         * distributed with this work for additional information
005:         * regarding copyright ownership. The ASF licenses this file
006:         * to you under the Apache License, Version 2.0 (the
007:         * "License"); you may not use this file except in compliance
008:         * with the License. You may obtain a copy of the License at
009:         *
010:         * http://www.apache.org/licenses/LICENSE-2.0
011:         *
012:         * Unless required by applicable law or agreed to in writing,
013:         * software distributed under the License is distributed on an
014:         * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015:         * KIND, either express or implied. See the License for the
016:         * specific language governing permissions and limitations
017:         * under the License.
018:         */
019:
020:        package org.apache.axis2.i18n;
021:
022:        import java.text.MessageFormat;
023:        import java.util.Locale;
024:        import java.util.MissingResourceException;
025:        import java.util.ResourceBundle;
026:
027:        /**
028:         * Accept parameters for ProjectResourceBundle,
029:         * but defer object instantiation (and therefore
030:         * resource bundle loading) until required.
031:         */
032:        public class MessageBundle {
033:            private boolean loaded = false;
034:
035:            private ProjectResourceBundle _resourceBundle = null;
036:
037:            private final String projectName;
038:            private final String packageName;
039:            private final String resourceName;
040:            private final Locale locale;
041:            private final ClassLoader classLoader;
042:            private final ResourceBundle parent;
043:
044:            public final ProjectResourceBundle getResourceBundle() {
045:                if (!loaded) {
046:                    _resourceBundle = ProjectResourceBundle.getBundle(
047:                            projectName, packageName, resourceName, locale,
048:                            classLoader, parent);
049:                    loaded = true;
050:                }
051:                return _resourceBundle;
052:            }
053:
054:            /**
055:             * Construct a new ExtendMessages
056:             */
057:            public MessageBundle(String projectName, String packageName,
058:                    String resourceName, Locale locale,
059:                    ClassLoader classLoader, ResourceBundle parent)
060:                    throws MissingResourceException {
061:                this .projectName = projectName;
062:                this .packageName = packageName;
063:                this .resourceName = resourceName;
064:                this .locale = locale;
065:                this .classLoader = classLoader;
066:                this .parent = parent;
067:            }
068:
069:            /**
070:             * Gets a string message from the resource bundle for the given key
071:             *
072:             * @param key The resource key
073:             * @return The message
074:             */
075:            public String getMessage(String key)
076:                    throws MissingResourceException {
077:                return getMessage(key, (String[]) null);
078:            }
079:
080:            /**
081:             * <p>Gets a string message from the resource bundle for the given key. The
082:             * message may contain variables that will be substituted with the given
083:             * arguments. Variables have the format:</p>
084:             * <dir>
085:             * This message has two variables: {0} and {1}
086:             * </dir>
087:             *
088:             * @param key  The resource key
089:             * @param arg0 The argument to place in variable {0}
090:             * @return The message
091:             */
092:            public String getMessage(String key, String arg0)
093:                    throws MissingResourceException {
094:                return getMessage(key, new String[] { arg0 });
095:            }
096:
097:            /**
098:             * <p>Gets a string message from the resource bundle for the given key. The
099:             * message may contain variables that will be substituted with the given
100:             * arguments. Variables have the format:</p>
101:             * <dir>
102:             * This message has two variables: {0} and {1}
103:             * </dir>
104:             *
105:             * @param key  The resource key
106:             * @param arg0 The argument to place in variable {0}
107:             * @param arg1 The argument to place in variable {1}
108:             * @return The message
109:             */
110:            public String getMessage(String key, String arg0, String arg1)
111:                    throws MissingResourceException {
112:                return getMessage(key, new String[] { arg0, arg1 });
113:            }
114:
115:            /**
116:             * <p>Gets a string message from the resource bundle for the given key. The
117:             * message may contain variables that will be substituted with the given
118:             * arguments. Variables have the format:</p>
119:             * <dir>
120:             * This message has two variables: {0} and {1}
121:             * </dir>
122:             *
123:             * @param key  The resource key
124:             * @param arg0 The argument to place in variable {0}
125:             * @param arg1 The argument to place in variable {1}
126:             * @param arg2 The argument to place in variable {2}
127:             * @return The message
128:             */
129:            public String getMessage(String key, String arg0, String arg1,
130:                    String arg2) throws MissingResourceException {
131:                return getMessage(key, new String[] { arg0, arg1, arg2 });
132:            }
133:
134:            /**
135:             * <p>Gets a string message from the resource bundle for the given key. The
136:             * message may contain variables that will be substituted with the given
137:             * arguments. Variables have the format:</p>
138:             * <dir>
139:             * This message has two variables: {0} and {1}
140:             * </dir>
141:             *
142:             * @param key  The resource key
143:             * @param arg0 The argument to place in variable {0}
144:             * @param arg1 The argument to place in variable {1}
145:             * @param arg2 The argument to place in variable {2}
146:             * @param arg3 The argument to place in variable {3}
147:             * @return The message
148:             */
149:            public String getMessage(String key, String arg0, String arg1,
150:                    String arg2, String arg3) throws MissingResourceException {
151:                return getMessage(key, new String[] { arg0, arg1, arg2, arg3 });
152:            }
153:
154:            /**
155:             * <p>Gets a string message from the resource bundle for the given key. The
156:             * message may contain variables that will be substituted with the given
157:             * arguments. Variables have the format:</p>
158:             * <dir>
159:             * This message has two variables: {0} and {1}
160:             * </dir>
161:             *
162:             * @param key  The resource key
163:             * @param arg0 The argument to place in variable {0}
164:             * @param arg1 The argument to place in variable {1}
165:             * @param arg2 The argument to place in variable {2}
166:             * @param arg3 The argument to place in variable {3}
167:             * @param arg4 The argument to place in variable {4}
168:             * @return The message
169:             */
170:            public String getMessage(String key, String arg0, String arg1,
171:                    String arg2, String arg3, String arg4)
172:                    throws MissingResourceException {
173:                return getMessage(key, new String[] { arg0, arg1, arg2, arg3,
174:                        arg4 });
175:            }
176:
177:            /**
178:             * <p>Gets a string message from the resource bundle for the given key. The
179:             * message may contain variables that will be substituted with the given
180:             * arguments. Variables have the format:</p>
181:             * <dir>
182:             * This message has two variables: {0} and {1}
183:             * </dir>
184:             *
185:             * @param key   The resource key
186:             * @param array An array of objects to place in corresponding variables
187:             * @return The message
188:             */
189:            public String getMessage(String key, String[] array)
190:                    throws MissingResourceException {
191:                String msg = null;
192:                if (getResourceBundle() != null) {
193:                    msg = getResourceBundle().getString(key);
194:                }
195:
196:                if (msg == null) {
197:                    throw new MissingResourceException(
198:                            "Cannot find resource key \"" + key
199:                                    + "\" in base name "
200:                                    + getResourceBundle().getResourceName(),
201:                            getResourceBundle().getResourceName(), key);
202:                }
203:
204:                return MessageFormat.format(msg, array);
205:            }
206:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.