Source Code Cross Referenced for Collector.java in  » Sevlet-Container » apache-tomcat-6.0.14 » org » apache » jasper » compiler » 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 » Sevlet Container » apache tomcat 6.0.14 » org.apache.jasper.compiler 
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:
018:        package org.apache.jasper.compiler;
019:
020:        import org.apache.jasper.JasperException;
021:
022:        /**
023:         * Collect info about the page and nodes, and make them availabe through
024:         * the PageInfo object.
025:         *
026:         * @author Kin-man Chung
027:         * @author Mark Roth
028:         */
029:
030:        class Collector {
031:
032:            /**
033:             * A visitor for collecting information on the page and the body of
034:             * the custom tags.
035:             */
036:            static class CollectVisitor extends Node.Visitor {
037:
038:                private boolean scriptingElementSeen = false;
039:                private boolean usebeanSeen = false;
040:                private boolean includeActionSeen = false;
041:                private boolean paramActionSeen = false;
042:                private boolean setPropertySeen = false;
043:                private boolean hasScriptingVars = false;
044:
045:                public void visit(Node.ParamAction n) throws JasperException {
046:                    if (n.getValue().isExpression()) {
047:                        scriptingElementSeen = true;
048:                    }
049:                    paramActionSeen = true;
050:                }
051:
052:                public void visit(Node.IncludeAction n) throws JasperException {
053:                    if (n.getPage().isExpression()) {
054:                        scriptingElementSeen = true;
055:                    }
056:                    includeActionSeen = true;
057:                    visitBody(n);
058:                }
059:
060:                public void visit(Node.ForwardAction n) throws JasperException {
061:                    if (n.getPage().isExpression()) {
062:                        scriptingElementSeen = true;
063:                    }
064:                    visitBody(n);
065:                }
066:
067:                public void visit(Node.SetProperty n) throws JasperException {
068:                    if (n.getValue() != null && n.getValue().isExpression()) {
069:                        scriptingElementSeen = true;
070:                    }
071:                    setPropertySeen = true;
072:                }
073:
074:                public void visit(Node.UseBean n) throws JasperException {
075:                    if (n.getBeanName() != null
076:                            && n.getBeanName().isExpression()) {
077:                        scriptingElementSeen = true;
078:                    }
079:                    usebeanSeen = true;
080:                    visitBody(n);
081:                }
082:
083:                public void visit(Node.PlugIn n) throws JasperException {
084:                    if (n.getHeight() != null && n.getHeight().isExpression()) {
085:                        scriptingElementSeen = true;
086:                    }
087:                    if (n.getWidth() != null && n.getWidth().isExpression()) {
088:                        scriptingElementSeen = true;
089:                    }
090:                    visitBody(n);
091:                }
092:
093:                public void visit(Node.CustomTag n) throws JasperException {
094:                    // Check to see what kinds of element we see as child elements
095:                    checkSeen(n.getChildInfo(), n);
096:                }
097:
098:                /**
099:                 * Check all child nodes for various elements and update the given
100:                 * ChildInfo object accordingly.  Visits body in the process.
101:                 */
102:                private void checkSeen(Node.ChildInfo ci, Node n)
103:                        throws JasperException {
104:                    // save values collected so far
105:                    boolean scriptingElementSeenSave = scriptingElementSeen;
106:                    scriptingElementSeen = false;
107:                    boolean usebeanSeenSave = usebeanSeen;
108:                    usebeanSeen = false;
109:                    boolean includeActionSeenSave = includeActionSeen;
110:                    includeActionSeen = false;
111:                    boolean paramActionSeenSave = paramActionSeen;
112:                    paramActionSeen = false;
113:                    boolean setPropertySeenSave = setPropertySeen;
114:                    setPropertySeen = false;
115:                    boolean hasScriptingVarsSave = hasScriptingVars;
116:                    hasScriptingVars = false;
117:
118:                    // Scan attribute list for expressions
119:                    if (n instanceof  Node.CustomTag) {
120:                        Node.CustomTag ct = (Node.CustomTag) n;
121:                        Node.JspAttribute[] attrs = ct.getJspAttributes();
122:                        for (int i = 0; attrs != null && i < attrs.length; i++) {
123:                            if (attrs[i].isExpression()) {
124:                                scriptingElementSeen = true;
125:                                break;
126:                            }
127:                        }
128:                    }
129:
130:                    visitBody(n);
131:
132:                    if ((n instanceof  Node.CustomTag) && !hasScriptingVars) {
133:                        Node.CustomTag ct = (Node.CustomTag) n;
134:                        hasScriptingVars = ct.getVariableInfos().length > 0
135:                                || ct.getTagVariableInfos().length > 0;
136:                    }
137:
138:                    // Record if the tag element and its body contains any scriptlet.
139:                    ci.setScriptless(!scriptingElementSeen);
140:                    ci.setHasUseBean(usebeanSeen);
141:                    ci.setHasIncludeAction(includeActionSeen);
142:                    ci.setHasParamAction(paramActionSeen);
143:                    ci.setHasSetProperty(setPropertySeen);
144:                    ci.setHasScriptingVars(hasScriptingVars);
145:
146:                    // Propagate value of scriptingElementSeen up.
147:                    scriptingElementSeen = scriptingElementSeen
148:                            || scriptingElementSeenSave;
149:                    usebeanSeen = usebeanSeen || usebeanSeenSave;
150:                    setPropertySeen = setPropertySeen || setPropertySeenSave;
151:                    includeActionSeen = includeActionSeen
152:                            || includeActionSeenSave;
153:                    paramActionSeen = paramActionSeen || paramActionSeenSave;
154:                    hasScriptingVars = hasScriptingVars || hasScriptingVarsSave;
155:                }
156:
157:                public void visit(Node.JspElement n) throws JasperException {
158:                    if (n.getNameAttribute().isExpression())
159:                        scriptingElementSeen = true;
160:
161:                    Node.JspAttribute[] attrs = n.getJspAttributes();
162:                    for (int i = 0; i < attrs.length; i++) {
163:                        if (attrs[i].isExpression()) {
164:                            scriptingElementSeen = true;
165:                            break;
166:                        }
167:                    }
168:                    visitBody(n);
169:                }
170:
171:                public void visit(Node.JspBody n) throws JasperException {
172:                    checkSeen(n.getChildInfo(), n);
173:                }
174:
175:                public void visit(Node.NamedAttribute n) throws JasperException {
176:                    checkSeen(n.getChildInfo(), n);
177:                }
178:
179:                public void visit(Node.Declaration n) throws JasperException {
180:                    scriptingElementSeen = true;
181:                }
182:
183:                public void visit(Node.Expression n) throws JasperException {
184:                    scriptingElementSeen = true;
185:                }
186:
187:                public void visit(Node.Scriptlet n) throws JasperException {
188:                    scriptingElementSeen = true;
189:                }
190:
191:                public void updatePageInfo(PageInfo pageInfo) {
192:                    pageInfo.setScriptless(!scriptingElementSeen);
193:                }
194:            }
195:
196:            public static void collect(Compiler compiler, Node.Nodes page)
197:                    throws JasperException {
198:
199:                CollectVisitor collectVisitor = new CollectVisitor();
200:                page.visit(collectVisitor);
201:                collectVisitor.updatePageInfo(compiler.getPageInfo());
202:
203:            }
204:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.