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