Source Code Cross Referenced for I18nMessage.java in  » Content-Management-System » apache-lenya-2.0 » org » apache » cocoon » forms » 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 » Content Management System » apache lenya 2.0 » org.apache.cocoon.forms.util 
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:        package org.apache.cocoon.forms.util;
018:
019:        import java.util.Arrays;
020:
021:        import org.apache.cocoon.transformation.I18nTransformer;
022:        import org.apache.cocoon.xml.AttributesImpl;
023:        import org.apache.cocoon.xml.XMLUtils;
024:        import org.apache.commons.lang.ObjectUtils;
025:        import org.apache.excalibur.xml.sax.XMLizable;
026:        import org.xml.sax.ContentHandler;
027:        import org.xml.sax.SAXException;
028:
029:        /**
030:         * A XMLizable implementation that will produce SAX events for the
031:         * I18nTransformer in its toSAX method, based on the information
032:         * given in the constructor.
033:         *
034:         * <p>This generates an autonomous SAX-blurb, i.e. all necessary namespace
035:         * declarations will be made, and no start/endDocument events will be generated.
036:         *
037:         * @version $Id: I18nMessage.java 449149 2006-09-23 03:58:05Z crossley $
038:         */
039:        public class I18nMessage implements  XMLizable {
040:            private String key;
041:            private String catalogue;
042:            private String[] parameters;
043:            private boolean[] keys;
044:
045:            /**
046:             * @param key a message key, to be translated by the I18nTransformer
047:             */
048:            public I18nMessage(String key) {
049:                this (key, (String) null);
050:            }
051:
052:            /**
053:             * @param key a message key, to be translated by the I18nTransformer
054:             * @param catalogue a named I18nTransformer catalogue to use
055:             */
056:            public I18nMessage(String key, String catalogue) {
057:                this .key = key;
058:                this .catalogue = catalogue;
059:            }
060:
061:            /**
062:             * @param key a message key, to be translated by the I18nTransformer
063:             * @param parameters parameters to be substituted in the errorMessage (will be
064:             * done by the I18nTransformer)
065:             */
066:            public I18nMessage(String key, String[] parameters) {
067:                this (key, parameters, (String) null);
068:            }
069:
070:            /**
071:             * @param key a message key, to be translated by the I18nTransformer
072:             * @param parameters parameters to be substituted in the errorMessage (will be
073:             * done by the I18nTransformer)
074:             * @param catalogue a named I18nTransformer catalogue to use
075:             */
076:            public I18nMessage(String key, String[] parameters, String catalogue) {
077:                this .key = key;
078:                this .parameters = parameters;
079:                this .catalogue = catalogue;
080:            }
081:
082:            /**
083:             * @param key a message key, to be translated by the I18nTransformer
084:             * @param parameters parameters to be substituted in the errorMessage (will be
085:             * done by the I18nTransformer)
086:             * @param keys Each element in the keys array corresponds to a string in the parameters array
087:             * and indicates whether that parameter is in itself again a key.
088:             */
089:            public I18nMessage(String key, String[] parameters, boolean[] keys) {
090:                this (key, parameters, keys, null);
091:            }
092:
093:            /**
094:             * @param key a message key, to be translated by the I18nTransformer
095:             * @param parameters parameters to be substituted in the errorMessage (will be
096:             * done by the I18nTransformer)
097:             * @param keys Each element in the keys array corresponds to a string in the parameters array
098:             * and indicates whether that parameter is in itself again a key.
099:             * @param catalogue a named I18nTransformer catalogue to use
100:             */
101:            public I18nMessage(String key, String[] parameters, boolean[] keys,
102:                    String catalogue) {
103:                this .key = key;
104:                this .parameters = parameters;
105:                this .keys = keys;
106:                this .catalogue = catalogue;
107:            }
108:
109:            public void toSAX(ContentHandler contentHandler)
110:                    throws SAXException {
111:                contentHandler.startPrefixMapping("i18n",
112:                        I18nTransformer.I18N_NAMESPACE_URI);
113:                if (parameters != null) {
114:                    contentHandler.startElement(
115:                            I18nTransformer.I18N_NAMESPACE_URI,
116:                            I18nTransformer.I18N_TRANSLATE_ELEMENT, "i18n:"
117:                                    + I18nTransformer.I18N_TRANSLATE_ELEMENT,
118:                            XMLUtils.EMPTY_ATTRIBUTES);
119:                }
120:
121:                AttributesImpl i18nAttrs = new AttributesImpl();
122:                if (catalogue != null) {
123:                    i18nAttrs.addCDATAAttribute(
124:                            I18nTransformer.I18N_NAMESPACE_URI,
125:                            I18nTransformer.I18N_CATALOGUE_ATTRIBUTE, "i18n:"
126:                                    + I18nTransformer.I18N_CATALOGUE_ATTRIBUTE,
127:                            catalogue);
128:                }
129:
130:                contentHandler.startElement(I18nTransformer.I18N_NAMESPACE_URI,
131:                        I18nTransformer.I18N_TEXT_ELEMENT, "i18n:"
132:                                + I18nTransformer.I18N_TEXT_ELEMENT, i18nAttrs);
133:                contentHandler.characters(key.toCharArray(), 0, key.length());
134:                contentHandler.endElement(I18nTransformer.I18N_NAMESPACE_URI,
135:                        I18nTransformer.I18N_TEXT_ELEMENT, "i18n:"
136:                                + I18nTransformer.I18N_TEXT_ELEMENT);
137:
138:                // the parameters
139:                if (parameters != null) {
140:                    for (int i = 0; i < parameters.length; i++) {
141:                        contentHandler.startElement(
142:                                I18nTransformer.I18N_NAMESPACE_URI,
143:                                I18nTransformer.I18N_PARAM_ELEMENT, "i18n:"
144:                                        + I18nTransformer.I18N_PARAM_ELEMENT,
145:                                XMLUtils.EMPTY_ATTRIBUTES);
146:                        if (keys != null && keys[i]) {
147:                            contentHandler
148:                                    .startElement(
149:                                            I18nTransformer.I18N_NAMESPACE_URI,
150:                                            I18nTransformer.I18N_TEXT_ELEMENT,
151:                                            "i18n:"
152:                                                    + I18nTransformer.I18N_TEXT_ELEMENT,
153:                                            i18nAttrs);
154:                        }
155:                        final String aParam = String.valueOf(parameters[i]);
156:                        contentHandler.characters(aParam.toCharArray(), 0,
157:                                aParam.length());
158:                        if (keys != null && keys[i]) {
159:                            contentHandler
160:                                    .endElement(
161:                                            I18nTransformer.I18N_NAMESPACE_URI,
162:                                            I18nTransformer.I18N_TEXT_ELEMENT,
163:                                            "i18n:"
164:                                                    + I18nTransformer.I18N_TEXT_ELEMENT);
165:                        }
166:                        contentHandler.endElement(
167:                                I18nTransformer.I18N_NAMESPACE_URI,
168:                                I18nTransformer.I18N_PARAM_ELEMENT, "i18n:"
169:                                        + I18nTransformer.I18N_PARAM_ELEMENT);
170:                    }
171:                    contentHandler.endElement(
172:                            I18nTransformer.I18N_NAMESPACE_URI,
173:                            I18nTransformer.I18N_TRANSLATE_ELEMENT, "i18n:"
174:                                    + I18nTransformer.I18N_TRANSLATE_ELEMENT);
175:                }
176:                contentHandler.endPrefixMapping("i18n");
177:            }
178:
179:            public boolean equals(Object obj) {
180:                if (obj instanceof  I18nMessage) {
181:                    I18nMessage other = (I18nMessage) obj;
182:                    return ObjectUtils.equals(this .catalogue, other.catalogue)
183:                            && ObjectUtils.equals(this .key, other.key)
184:                            && Arrays.equals(this .keys, other.keys)
185:                            && Arrays.equals(this .parameters, other.parameters);
186:                } else {
187:                    return false;
188:                }
189:            }
190:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.