Source Code Cross Referenced for CmsMessageContainer.java in  » Content-Management-System » opencms » org » opencms » 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 » Content Management System » opencms » org.opencms.i18n 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * File   : $Source: /usr/local/cvs/opencms/src/org/opencms/i18n/CmsMessageContainer.java,v $
003:         * Date   : $Date: 2008-02-27 12:05:47 $
004:         * Version: $Revision: 1.12 $
005:         *
006:         * This library is part of OpenCms -
007:         * the Open Source Content Management System
008:         *
009:         * Copyright (c) 2002 - 2008 Alkacon Software GmbH (http://www.alkacon.com)
010:         *
011:         * This library is free software; you can redistribute it and/or
012:         * modify it under the terms of the GNU Lesser General Public
013:         * License as published by the Free Software Foundation; either
014:         * version 2.1 of the License, or (at your option) any later version.
015:         *
016:         * This library is distributed in the hope that it will be useful,
017:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
018:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
019:         * Lesser General Public License for more details.
020:         *
021:         * For further information about Alkacon Software GmbH, please see the
022:         * company website: http://www.alkacon.com
023:         *
024:         * For further information about OpenCms, please see the
025:         * project website: http://www.opencms.org
026:         * 
027:         * You should have received a copy of the GNU Lesser General Public
028:         * License along with this library; if not, write to the Free Software
029:         * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
030:         */
031:
032:        package org.opencms.i18n;
033:
034:        import java.io.Serializable;
035:        import java.util.Locale;
036:
037:        /**
038:         * Contains a localized message key, it's arguments and a <code>{@link I_CmsMessageBundle}</code>.<p>
039:         * 
040:         * Used for delaying the actual message lookup from the bundle to the time the message is displayed, 
041:         * not generated. This is used for localizing internal OpenCms messages. If a message is generated internally by OpenCms,
042:         * at the time no information about the context of the current user may be available. The message is therefore 
043:         * passed to the class generating the output, where a user context usually exists. Finally, the message is rendered
044:         * with the locale of the available user, or the OpenCms default locale if no user is available.<p> 
045:         * 
046:         * @author Alexander Kandzior 
047:         *
048:         * @version $Revision: 1.12 $ 
049:         * 
050:         * @since 6.0.0 
051:         *   
052:         * @see org.opencms.i18n.I_CmsMessageBundle
053:         */
054:        public class CmsMessageContainer implements  Serializable {
055:
056:            /** Serial version UID required for safe serialization. */
057:            private static final long serialVersionUID = 2844402574674092147L;
058:
059:            /** The message arguments to use. */
060:            protected Object[] m_args;
061:
062:            /** The OpenCms message bundle to read the message from. */
063:            protected I_CmsMessageBundle m_bundle;
064:
065:            /** The message key to use. */
066:            protected String m_key;
067:
068:            /**
069:             * Creates a new message container for a key without arguments.<p>
070:             * 
071:             * @param bundle the OpenCms message bundle to read the message from
072:             * @param key the message key to use
073:             */
074:            public CmsMessageContainer(I_CmsMessageBundle bundle, String key) {
075:
076:                m_bundle = bundle;
077:                m_key = key;
078:            }
079:
080:            /**
081:             * Creates a new message container.<p>
082:             * 
083:             * @param bundle the OpenCms message bundle to read the message from
084:             * @param key the message key to use
085:             * @param args the message arguments to use
086:             */
087:            public CmsMessageContainer(I_CmsMessageBundle bundle, String key,
088:                    Object[] args) {
089:
090:                m_bundle = bundle;
091:                m_key = key;
092:                m_args = args;
093:            }
094:
095:            /**
096:             * Returns the message arguments to use.<p>
097:             *
098:             * @return the message arguments to use
099:             */
100:            public Object[] getArgs() {
101:
102:                return m_args;
103:            }
104:
105:            /**
106:             * Returns the message bundle used by this container.<p>
107:             *
108:             * @return the message bundle used by this container
109:             */
110:            public I_CmsMessageBundle getBundle() {
111:
112:                return m_bundle;
113:            }
114:
115:            /**
116:             * Returns the message key to use.<p>
117:             *
118:             * @return the message key to use
119:             */
120:            public String getKey() {
121:
122:                return m_key;
123:            }
124:
125:            /**
126:             * Returns the localized message described by this container for the OpenCms default locale.<p>
127:             * 
128:             * @return the localized message described by this container for the OpenCms default locale
129:             */
130:            public String key() {
131:
132:                if (getBundle() == null) {
133:                    return getKey();
134:                }
135:                return getBundle().getBundle().key(getKey(), getArgs());
136:            }
137:
138:            /**
139:             * Returns the localized message described by this container for the given locale.<p>
140:             * 
141:             * @param locale the locale to use
142:             * @return the localized message described by this container for the given locale
143:             */
144:            public String key(Locale locale) {
145:
146:                if (getBundle() == null) {
147:                    return getKey();
148:                }
149:                return getBundle().getBundle(locale).key(getKey(), getArgs());
150:            }
151:
152:            /**
153:             * @see java.lang.Object#toString()
154:             */
155:            public String toString() {
156:
157:                StringBuffer result = new StringBuffer();
158:
159:                result.append('[');
160:                result.append(this .getClass().getName());
161:                result.append(", bundle: ");
162:                result.append(getBundle().getBundleName());
163:                result.append(", key: ");
164:                result.append(getKey());
165:                Object[] args = getArgs();
166:                if (args != null) {
167:                    for (int i = 0; i < args.length; i++) {
168:                        result.append(", arg");
169:                        result.append(i + 1);
170:                        result.append(": ");
171:                        result.append(args[i]);
172:                    }
173:                }
174:                result.append(']');
175:
176:                return result.toString();
177:            }
178:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.