Source Code Cross Referenced for TKLanguageTag.java in  » Content-Management-System » webman » com » teamkonzept » lib » templates » 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 » webman » com.teamkonzept.lib.templates 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package com.teamkonzept.lib.templates;
002:
003:        import com.teamkonzept.lib.*;
004:
005:        import java.io.*;
006:        import java.util.*;
007:        import java.text.*;
008:        import com.teamkonzept.international.LanguageManager;
009:
010:        /**
011:         * Tag fuer sprachabhängige Texte
012:         * @author  $Author: alex $
013:         * @version $Revision: 1.20 $
014:         */
015:        public class TKLanguageTag extends TKLabelTag {
016:
017:            /** Identifier des Tags */
018:            public static final int TAG_TYPE = TKDateTag.TAG_TYPE + 1;
019:
020:            /** bei Subtags wird hier der Parameter String bis zum apply gehalten */
021:            String paramsString = null;
022:
023:            /** Parameter werden hier gehalten */
024:            TKVector params = null;
025:
026:            /**
027:             * Konstruktor 1
028:             * Ein Syntaxbaum fuer ein Template wird erzeugt.
029:             */
030:            public TKLanguageTag(TKTemplateSyntax parent, String def,
031:                    boolean hasSubTags) throws TKTemplateSyntaxException {
032:                super (parent, def, hasSubTags);
033:                if (hasSubTags)
034:                    paramsString = def;
035:                else
036:                    label = getParams(def, false, null);
037:            }
038:
039:            /**
040:             *
041:             */
042:            public String apply(TKTemplateData td)
043:                    throws TKTemplateSyntaxException {
044:                return getText(td);
045:            }
046:
047:            public void apply(TKTemplateData td, Writer writer)
048:                    throws TKTemplateSyntaxException, IOException {
049:
050:                writer.write(getText(td));
051:            }
052:
053:            protected void makeParam(StringBuffer name, StringBuffer value,
054:                    boolean hasSubTags, TKTemplateData td)
055:                    throws TKTemplateSyntaxException {
056:                String valString = value == null ? "" : value.toString();
057:
058:                if (hasSubTags) {
059:
060:                    TKTemplateSyntax syntax = parent.newChild(valString, parent
061:                            .getSource(), true);
062:                    TKTemplateData subTd = td;
063:                    String decoding = (String) subTd
064:                            .getVariable("TEMPLATE_SYNTAX_DEFAULT_ENCODING");
065:                    if (subTd != null) {
066:                        // muss hier sein, da ansonsten spätere Encoder falsche Ergebnisse liefern
067:                        subTd.setLocalVariable(
068:                                "TEMPLATE_SYNTAX_DEFAULT_ENCODING",
069:                                TKAnsiConverter.CONV_ID);
070:                    }
071:                    valString = syntax.apply(subTd);
072:                    // Decoding wieder zruecksetzen
073:                    if (decoding != null)
074:                        subTd.setLocalVariable(
075:                                "TEMPLATE_SYNTAX_DEFAULT_ENCODING", decoding);
076:                    else
077:                        subTd
078:                                .removeVariable("TEMPLATE_SYNTAX_DEFAULT_ENCODING");
079:                }
080:                params.addElement(valString);
081:            }
082:
083:            protected String getParams(String def, boolean hasSubTags,
084:                    TKTemplateData td) throws TKTemplateSyntaxException {
085:                params = new TKVector();
086:                int pos = def.indexOf(':');
087:                if (pos < 0) {
088:                    if (hasSubTags) {
089:                        return parent.newChild(def, parent.getSource(),
090:                                hasSubTags).apply(td);
091:                    } else {
092:                        return def;
093:                    }
094:                }
095:                String label = def.substring(0, pos++);
096:                if (hasSubTags) {
097:                    label = parent.newChild(label, parent.getSource(),
098:                            hasSubTags).apply(td);
099:                }
100:                StringBuffer name = null;
101:                StringBuffer value = null;
102:                boolean inName = true;
103:                while (pos < def.length()) {
104:                    char chr = def.charAt(pos++);
105:                    if (chr == ';') {
106:                        if (name != null) {
107:                            makeParam(name, value, hasSubTags, td);
108:                        }
109:                        inName = true;
110:                        name = null;
111:                        value = null;
112:                        continue;
113:                    }
114:                    if (chr == '=') {
115:                        inName = false;
116:                        continue;
117:                    }
118:                    if ((chr == '\\') && (pos < def.length())) {
119:                        chr = def.charAt(pos++);
120:                    }
121:                    (inName ? (name == null ? (name = new StringBuffer())
122:                            : name)
123:                            : (value == null ? (value = new StringBuffer())
124:                                    : value)).append(chr);
125:                }
126:                if (name != null) {
127:                    makeParam(name, value, hasSubTags, td);
128:                }
129:                return label;
130:            }
131:
132:            /**
133:            	liefert den localisierten String zurueck
134:            	Format des labels ist CONTEXT.IDENTIFIER
135:             */
136:            private String getText(TKTemplateData td)
137:                    throws TKTemplateSyntaxException {
138:                String label = null;
139:                if (paramsString != null) {
140:                    label = getParams(paramsString, true, td);
141:                } else {
142:                    label = getRealLabel(td);
143:                }
144:                label = label.trim();
145:                int index = label.indexOf(".");
146:                if (index < 1) {
147:                    return "wrong_format";
148:                }
149:                String context = label.substring(0, index);
150:                String ident = label.substring(index + 1, label.length());
151:                Object[] args = new Object[params.size()];
152:                params.copyInto(args);
153:                /**for (int j = 0; j < args.length; j++)
154:                	System.out.println(args[j]);     */
155:
156:                String back = LanguageManager.getText(context, ident, args);
157:                String encoding = parent.getDefaultEncoding(td);
158:                TKConverter encoder = TKConverter.getConverter(encoding);
159:                if (encoder == null) {
160:                    throw new Error("missing converter for encoding "
161:                            + encoding);
162:                }
163:                return new String(encoder.stringToBytes(back), 0);
164:
165:            }
166:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.