Source Code Cross Referenced for TKSwitchTag.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 java.io.*;
004:        import java.util.*;
005:
006:        import com.teamkonzept.lib.*;
007:
008:        /**
009:         * SwitchTag:
010:         * <TK_SWITCH:name:[alt=]tmpl;...>
011:         * @author  $Author: alex $
012:         * @version $Revision: 1.12 $
013:         */
014:        public class TKSwitchTag extends TKTag {
015:            public static final int TAG_TYPE = TKNotTag.TAG_TYPE + 1;;
016:            public static final String ATTR_LABEL = "label";
017:            public static final String ATTR_SIZE = "size";
018:            public static final String ATTR_NAME = "attrName";
019:            public static final String ATTR_LOCATION = "attrLocation";
020:
021:            public static final String SYNTAX_ALTERNATIVES = "alternatives";
022:
023:            public String label = null;
024:            public TKHashtable alternatives = null;
025:            public TKTemplateSyntax alternativesSyntax = null;
026:
027:            /**
028:             * Konstruktor 1
029:             * Ein Syntaxbaum fuer ein Template wird erzeugt.
030:             *
031:             * @param String def, Name des Tags
032:             * @param boolean hasSubTags
033:             */
034:            public TKSwitchTag(TKTemplateSyntax parent, String def,
035:                    boolean hasSubTags) throws TKTemplateSyntaxException {
036:                super (parent);
037:                if (hasSubTags) {
038:                    alternativesSyntax = parent.newChild(def, parent
039:                            .getSource(), hasSubTags);
040:                } else {
041:                    alternatives = new TKHashtable();
042:                    label = getAlternatives(def, alternatives);
043:                }
044:            }
045:
046:            /**
047:            	holt sich die CASE Bloecke
048:             */
049:            protected static String getAlternatives(String def,
050:                    TKHashtable alternatives) {
051:                int pos = def.indexOf(':');
052:                String label = def.substring(0, pos);
053:                Enumeration alts = new StringTokenizer(def.substring(pos + 1),
054:                        ";");
055:                while (alts.hasMoreElements()) {
056:                    String currAlt = ((String) alts.nextElement()).trim();
057:                    if (currAlt.length() > 0) {
058:                        pos = currAlt.indexOf('=');
059:                        if (pos < 0) {
060:                            alternatives.put(currAlt, currAlt);
061:                        } else {
062:                            alternatives.put(currAlt.substring(0, pos).trim(),
063:                                    currAlt.substring(pos + 1).trim());
064:                        }
065:                    }
066:                }
067:                return label;
068:            }
069:
070:            /**
071:             * Die apply-Methode  von TKSyntax wird aufgerufen und das entsprechende
072:             * Template wird included.
073:             *
074:             * @param TKTemplateData td
075:             */
076:            public String apply(TKTemplateData td)
077:                    throws TKTemplateSyntaxException {
078:                String tmpLabel = label;
079:                TKHashtable tmpAlternatives = alternatives;
080:
081:                if (tmpLabel == null) {
082:                    tmpAlternatives = new TKHashtable();
083:                    tmpLabel = getAlternatives(alternativesSyntax.apply(td),
084:                            tmpAlternatives);
085:                }
086:
087:                Object selection = td.getVariable(tmpLabel);
088:                if (selection == null)
089:                    return null;
090:
091:                String theFile = (String) tmpAlternatives.get(selection);
092:                if (theFile == null)
093:                    return null;
094:
095:                // TKLog.println ("TKSwitchTag.apply, fn="+theFile);
096:
097:                TKTemplateSyntax syntax = TKTemplateCache.getSyntax(theFile,
098:                        parent);
099:                return syntax.apply(td);
100:            }
101:
102:            /**
103:             * Die apply-Methode  von TKSyntax wird aufgerufen und das entsprechende
104:             * Template wird included.
105:             *
106:             * @param td TKTemplateData
107:             * @param writer the Writer to which the result is written
108:             */
109:            public void apply(TKTemplateData td, Writer writer)
110:                    throws TKTemplateSyntaxException, IOException {
111:                String tmpLabel = label;
112:                TKHashtable tmpAlternatives = alternatives;
113:
114:                if (tmpLabel == null) {
115:                    tmpAlternatives = new TKHashtable();
116:                    tmpLabel = getAlternatives(alternativesSyntax.apply(td),
117:                            tmpAlternatives);
118:                }
119:
120:                Object selection = td.getVariable(tmpLabel);
121:                if (selection == null)
122:                    return;
123:
124:                String theFile = (String) tmpAlternatives.get(selection);
125:                if (theFile == null)
126:                    return;
127:
128:                // TKLog.println ("TKSwitchTag.apply, fn="+theFile);
129:
130:                TKTemplateSyntax syntax = TKTemplateCache.getSyntax(theFile,
131:                        parent);
132:                syntax.apply(td, writer);
133:            }
134:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.