Source Code Cross Referenced for Localizer.java in  » Sevlet-Container » apache-tomcat-6.0.14 » org » apache » jasper » compiler » 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 » Sevlet Container » apache tomcat 6.0.14 » org.apache.jasper.compiler 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Licensed to the Apache Software Foundation (ASF) under one or more
003:         * contributor license agreements.  See the NOTICE file distributed with
004:         * this work for additional information regarding copyright ownership.
005:         * The ASF licenses this file to You under the Apache License, Version 2.0
006:         * (the "License"); you may not use this file except in compliance with
007:         * the License.  You may obtain a copy of the License at
008:         * 
009:         *      http://www.apache.org/licenses/LICENSE-2.0
010:         * 
011:         * Unless required by applicable law or agreed to in writing, software
012:         * distributed under the License is distributed on an "AS IS" BASIS,
013:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         * See the License for the specific language governing permissions and
015:         * limitations under the License.
016:         */
017:
018:        package org.apache.jasper.compiler;
019:
020:        import java.text.MessageFormat;
021:        import java.util.MissingResourceException;
022:        import java.util.ResourceBundle;
023:
024:        /**
025:         * Class responsible for converting error codes to corresponding localized
026:         * error messages.
027:         *
028:         * @author Jan Luehe
029:         */
030:        public class Localizer {
031:
032:            private static ResourceBundle bundle = null;
033:
034:            static {
035:                try {
036:                    bundle = ResourceBundle
037:                            .getBundle("org.apache.jasper.resources.LocalStrings");
038:                } catch (Throwable t) {
039:                    t.printStackTrace();
040:                }
041:            }
042:
043:            /*
044:             * Returns the localized error message corresponding to the given error
045:             * code.
046:             *
047:             * If the given error code is not defined in the resource bundle for
048:             * localized error messages, it is used as the error message.
049:             *
050:             * @param errCode Error code to localize
051:             * 
052:             * @return Localized error message
053:             */
054:            public static String getMessage(String errCode) {
055:                String errMsg = errCode;
056:                try {
057:                    errMsg = bundle.getString(errCode);
058:                } catch (MissingResourceException e) {
059:                }
060:                return errMsg;
061:            }
062:
063:            /* 
064:             * Returns the localized error message corresponding to the given error
065:             * code.
066:             *
067:             * If the given error code is not defined in the resource bundle for
068:             * localized error messages, it is used as the error message.
069:             *
070:             * @param errCode Error code to localize
071:             * @param arg Argument for parametric replacement
072:             *
073:             * @return Localized error message
074:             */
075:            public static String getMessage(String errCode, String arg) {
076:                return getMessage(errCode, new Object[] { arg });
077:            }
078:
079:            /* 
080:             * Returns the localized error message corresponding to the given error
081:             * code.
082:             *
083:             * If the given error code is not defined in the resource bundle for
084:             * localized error messages, it is used as the error message.
085:             *
086:             * @param errCode Error code to localize
087:             * @param arg1 First argument for parametric replacement
088:             * @param arg2 Second argument for parametric replacement
089:             *
090:             * @return Localized error message
091:             */
092:            public static String getMessage(String errCode, String arg1,
093:                    String arg2) {
094:                return getMessage(errCode, new Object[] { arg1, arg2 });
095:            }
096:
097:            /* 
098:             * Returns the localized error message corresponding to the given error
099:             * code.
100:             *
101:             * If the given error code is not defined in the resource bundle for
102:             * localized error messages, it is used as the error message.
103:             *
104:             * @param errCode Error code to localize
105:             * @param arg1 First argument for parametric replacement
106:             * @param arg2 Second argument for parametric replacement
107:             * @param arg3 Third argument for parametric replacement
108:             *
109:             * @return Localized error message
110:             */
111:            public static String getMessage(String errCode, String arg1,
112:                    String arg2, String arg3) {
113:                return getMessage(errCode, new Object[] { arg1, arg2, arg3 });
114:            }
115:
116:            /* 
117:             * Returns the localized error message corresponding to the given error
118:             * code.
119:             *
120:             * If the given error code is not defined in the resource bundle for
121:             * localized error messages, it is used as the error message.
122:             *
123:             * @param errCode Error code to localize
124:             * @param arg1 First argument for parametric replacement
125:             * @param arg2 Second argument for parametric replacement
126:             * @param arg3 Third argument for parametric replacement
127:             * @param arg4 Fourth argument for parametric replacement
128:             *
129:             * @return Localized error message
130:             */
131:            public static String getMessage(String errCode, String arg1,
132:                    String arg2, String arg3, String arg4) {
133:                return getMessage(errCode, new Object[] { arg1, arg2, arg3,
134:                        arg4 });
135:            }
136:
137:            /*
138:             * Returns the localized error message corresponding to the given error
139:             * code.
140:             *
141:             * If the given error code is not defined in the resource bundle for
142:             * localized error messages, it is used as the error message.
143:             *
144:             * @param errCode Error code to localize
145:             * @param args Arguments for parametric replacement
146:             *
147:             * @return Localized error message
148:             */
149:            public static String getMessage(String errCode, Object[] args) {
150:                String errMsg = errCode;
151:                try {
152:                    errMsg = bundle.getString(errCode);
153:                    if (args != null) {
154:                        MessageFormat formatter = new MessageFormat(errMsg);
155:                        errMsg = formatter.format(args);
156:                    }
157:                } catch (MissingResourceException e) {
158:                }
159:
160:                return errMsg;
161:            }
162:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.