Source Code Cross Referenced for Node.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) 


0001:        /*
0002:         * Licensed to the Apache Software Foundation (ASF) under one or more
0003:         * contributor license agreements.  See the NOTICE file distributed with
0004:         * this work for additional information regarding copyright ownership.
0005:         * The ASF licenses this file to You under the Apache License, Version 2.0
0006:         * (the "License"); you may not use this file except in compliance with
0007:         * the License.  You may obtain a copy of the License at
0008:         * 
0009:         *      http://www.apache.org/licenses/LICENSE-2.0
0010:         * 
0011:         * Unless required by applicable law or agreed to in writing, software
0012:         * distributed under the License is distributed on an "AS IS" BASIS,
0013:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
0014:         * See the License for the specific language governing permissions and
0015:         * limitations under the License.
0016:         */
0017:
0018:        package org.apache.jasper.compiler;
0019:
0020:        import java.util.Iterator;
0021:        import java.util.List;
0022:        import java.util.Vector;
0023:        import java.util.ArrayList;
0024:
0025:        import javax.el.ELContext;
0026:        import javax.el.ELException;
0027:        import javax.el.ExpressionFactory;
0028:        import javax.el.ValueExpression;
0029:        import javax.servlet.jsp.tagext.BodyTag;
0030:        import javax.servlet.jsp.tagext.DynamicAttributes;
0031:        import javax.servlet.jsp.tagext.IterationTag;
0032:        import javax.servlet.jsp.tagext.JspIdConsumer;
0033:        import javax.servlet.jsp.tagext.SimpleTag;
0034:        import javax.servlet.jsp.tagext.TagAttributeInfo;
0035:        import javax.servlet.jsp.tagext.TagData;
0036:        import javax.servlet.jsp.tagext.TagFileInfo;
0037:        import javax.servlet.jsp.tagext.TagInfo;
0038:        import javax.servlet.jsp.tagext.TagVariableInfo;
0039:        import javax.servlet.jsp.tagext.TryCatchFinally;
0040:        import javax.servlet.jsp.tagext.VariableInfo;
0041:
0042:        import org.apache.jasper.JasperException;
0043:        import org.apache.jasper.compiler.tagplugin.TagPluginContext;
0044:        import org.xml.sax.Attributes;
0045:
0046:        /**
0047:         * An internal data representation of a JSP page or a JSP docuement (XML). Also
0048:         * included here is a visitor class for tranversing nodes.
0049:         * 
0050:         * @author Kin-man Chung
0051:         * @author Jan Luehe
0052:         * @author Shawn Bayern
0053:         * @author Mark Roth
0054:         */
0055:
0056:        abstract class Node implements  TagConstants {
0057:
0058:            private static final VariableInfo[] ZERO_VARIABLE_INFO = {};
0059:
0060:            protected Attributes attrs;
0061:
0062:            // xmlns attributes that represent tag libraries (only in XML syntax)
0063:            protected Attributes taglibAttrs;
0064:
0065:            /*
0066:             * xmlns attributes that do not represent tag libraries (only in XML syntax)
0067:             */
0068:            protected Attributes nonTaglibXmlnsAttrs;
0069:
0070:            protected Nodes body;
0071:
0072:            protected String text;
0073:
0074:            protected Mark startMark;
0075:
0076:            protected int beginJavaLine;
0077:
0078:            protected int endJavaLine;
0079:
0080:            protected Node parent;
0081:
0082:            protected Nodes namedAttributeNodes; // cached for performance
0083:
0084:            protected String qName;
0085:
0086:            protected String localName;
0087:
0088:            /*
0089:             * The name of the inner class to which the codes for this node and its body
0090:             * are generated. For instance, for <jsp:body> in foo.jsp, this is
0091:             * "foo_jspHelper". This is primarily used for communicating such info from
0092:             * Generator to Smap generator.
0093:             */
0094:            protected String innerClassName;
0095:
0096:            private boolean isDummy;
0097:
0098:            /**
0099:             * Zero-arg Constructor.
0100:             */
0101:            public Node() {
0102:                this .isDummy = true;
0103:            }
0104:
0105:            /**
0106:             * Constructor.
0107:             * 
0108:             * @param start
0109:             *            The location of the jsp page
0110:             * @param parent
0111:             *            The enclosing node
0112:             */
0113:            public Node(Mark start, Node parent) {
0114:                this .startMark = start;
0115:                this .isDummy = (start == null);
0116:                addToParent(parent);
0117:            }
0118:
0119:            /**
0120:             * Constructor.
0121:             * 
0122:             * @param qName
0123:             *            The action's qualified name
0124:             * @param localName
0125:             *            The action's local name
0126:             * @param start
0127:             *            The location of the jsp page
0128:             * @param parent
0129:             *            The enclosing node
0130:             */
0131:            public Node(String qName, String localName, Mark start, Node parent) {
0132:                this .qName = qName;
0133:                this .localName = localName;
0134:                this .startMark = start;
0135:                this .isDummy = (start == null);
0136:                addToParent(parent);
0137:            }
0138:
0139:            /**
0140:             * Constructor for Nodes parsed from standard syntax.
0141:             * 
0142:             * @param qName
0143:             *            The action's qualified name
0144:             * @param localName
0145:             *            The action's local name
0146:             * @param attrs
0147:             *            The attributes for this node
0148:             * @param start
0149:             *            The location of the jsp page
0150:             * @param parent
0151:             *            The enclosing node
0152:             */
0153:            public Node(String qName, String localName, Attributes attrs,
0154:                    Mark start, Node parent) {
0155:                this .qName = qName;
0156:                this .localName = localName;
0157:                this .attrs = attrs;
0158:                this .startMark = start;
0159:                this .isDummy = (start == null);
0160:                addToParent(parent);
0161:            }
0162:
0163:            /**
0164:             * Constructor for Nodes parsed from XML syntax.
0165:             * 
0166:             * @param qName
0167:             *            The action's qualified name
0168:             * @param localName
0169:             *            The action's local name
0170:             * @param attrs
0171:             *            The action's attributes whose name does not start with xmlns
0172:             * @param nonTaglibXmlnsAttrs
0173:             *            The action's xmlns attributes that do not represent tag
0174:             *            libraries
0175:             * @param taglibAttrs
0176:             *            The action's xmlns attributes that represent tag libraries
0177:             * @param start
0178:             *            The location of the jsp page
0179:             * @param parent
0180:             *            The enclosing node
0181:             */
0182:            public Node(String qName, String localName, Attributes attrs,
0183:                    Attributes nonTaglibXmlnsAttrs, Attributes taglibAttrs,
0184:                    Mark start, Node parent) {
0185:                this .qName = qName;
0186:                this .localName = localName;
0187:                this .attrs = attrs;
0188:                this .nonTaglibXmlnsAttrs = nonTaglibXmlnsAttrs;
0189:                this .taglibAttrs = taglibAttrs;
0190:                this .startMark = start;
0191:                this .isDummy = (start == null);
0192:                addToParent(parent);
0193:            }
0194:
0195:            /*
0196:             * Constructor.
0197:             * 
0198:             * @param qName The action's qualified name @param localName The action's
0199:             * local name @param text The text associated with this node @param start
0200:             * The location of the jsp page @param parent The enclosing node
0201:             */
0202:            public Node(String qName, String localName, String text,
0203:                    Mark start, Node parent) {
0204:                this .qName = qName;
0205:                this .localName = localName;
0206:                this .text = text;
0207:                this .startMark = start;
0208:                this .isDummy = (start == null);
0209:                addToParent(parent);
0210:            }
0211:
0212:            public String getQName() {
0213:                return this .qName;
0214:            }
0215:
0216:            public String getLocalName() {
0217:                return this .localName;
0218:            }
0219:
0220:            /*
0221:             * Gets this Node's attributes.
0222:             * 
0223:             * In the case of a Node parsed from standard syntax, this method returns
0224:             * all the Node's attributes.
0225:             * 
0226:             * In the case of a Node parsed from XML syntax, this method returns only
0227:             * those attributes whose name does not start with xmlns.
0228:             */
0229:            public Attributes getAttributes() {
0230:                return this .attrs;
0231:            }
0232:
0233:            /*
0234:             * Gets this Node's xmlns attributes that represent tag libraries (only
0235:             * meaningful for Nodes parsed from XML syntax)
0236:             */
0237:            public Attributes getTaglibAttributes() {
0238:                return this .taglibAttrs;
0239:            }
0240:
0241:            /*
0242:             * Gets this Node's xmlns attributes that do not represent tag libraries
0243:             * (only meaningful for Nodes parsed from XML syntax)
0244:             */
0245:            public Attributes getNonTaglibXmlnsAttributes() {
0246:                return this .nonTaglibXmlnsAttrs;
0247:            }
0248:
0249:            public void setAttributes(Attributes attrs) {
0250:                this .attrs = attrs;
0251:            }
0252:
0253:            public String getAttributeValue(String name) {
0254:                return (attrs == null) ? null : attrs.getValue(name);
0255:            }
0256:
0257:            /**
0258:             * Get the attribute that is non request time expression, either from the
0259:             * attribute of the node, or from a jsp:attrbute
0260:             */
0261:            public String getTextAttribute(String name) {
0262:
0263:                String attr = getAttributeValue(name);
0264:                if (attr != null) {
0265:                    return attr;
0266:                }
0267:
0268:                NamedAttribute namedAttribute = getNamedAttributeNode(name);
0269:                if (namedAttribute == null) {
0270:                    return null;
0271:                }
0272:
0273:                return namedAttribute.getText();
0274:            }
0275:
0276:            /**
0277:             * Searches all subnodes of this node for jsp:attribute standard actions
0278:             * with the given name, and returns the NamedAttribute node of the matching
0279:             * named attribute, nor null if no such node is found.
0280:             * <p>
0281:             * This should always be called and only be called for nodes that accept
0282:             * dynamic runtime attribute expressions.
0283:             */
0284:            public NamedAttribute getNamedAttributeNode(String name) {
0285:                NamedAttribute result = null;
0286:
0287:                // Look for the attribute in NamedAttribute children
0288:                Nodes nodes = getNamedAttributeNodes();
0289:                int numChildNodes = nodes.size();
0290:                for (int i = 0; i < numChildNodes; i++) {
0291:                    NamedAttribute na = (NamedAttribute) nodes.getNode(i);
0292:                    boolean found = false;
0293:                    int index = name.indexOf(':');
0294:                    if (index != -1) {
0295:                        // qualified name
0296:                        found = na.getName().equals(name);
0297:                    } else {
0298:                        found = na.getLocalName().equals(name);
0299:                    }
0300:                    if (found) {
0301:                        result = na;
0302:                        break;
0303:                    }
0304:                }
0305:
0306:                return result;
0307:            }
0308:
0309:            /**
0310:             * Searches all subnodes of this node for jsp:attribute standard actions,
0311:             * and returns that set of nodes as a Node.Nodes object.
0312:             * 
0313:             * @return Possibly empty Node.Nodes object containing any jsp:attribute
0314:             *         subnodes of this Node
0315:             */
0316:            public Node.Nodes getNamedAttributeNodes() {
0317:
0318:                if (namedAttributeNodes != null) {
0319:                    return namedAttributeNodes;
0320:                }
0321:
0322:                Node.Nodes result = new Node.Nodes();
0323:
0324:                // Look for the attribute in NamedAttribute children
0325:                Nodes nodes = getBody();
0326:                if (nodes != null) {
0327:                    int numChildNodes = nodes.size();
0328:                    for (int i = 0; i < numChildNodes; i++) {
0329:                        Node n = nodes.getNode(i);
0330:                        if (n instanceof  NamedAttribute) {
0331:                            result.add(n);
0332:                        } else if (!(n instanceof  Comment)) {
0333:                            // Nothing can come before jsp:attribute, and only
0334:                            // jsp:body can come after it.
0335:                            break;
0336:                        }
0337:                    }
0338:                }
0339:
0340:                namedAttributeNodes = result;
0341:                return result;
0342:            }
0343:
0344:            public Nodes getBody() {
0345:                return body;
0346:            }
0347:
0348:            public void setBody(Nodes body) {
0349:                this .body = body;
0350:            }
0351:
0352:            public String getText() {
0353:                return text;
0354:            }
0355:
0356:            public Mark getStart() {
0357:                return startMark;
0358:            }
0359:
0360:            public Node getParent() {
0361:                return parent;
0362:            }
0363:
0364:            public int getBeginJavaLine() {
0365:                return beginJavaLine;
0366:            }
0367:
0368:            public void setBeginJavaLine(int begin) {
0369:                beginJavaLine = begin;
0370:            }
0371:
0372:            public int getEndJavaLine() {
0373:                return endJavaLine;
0374:            }
0375:
0376:            public void setEndJavaLine(int end) {
0377:                endJavaLine = end;
0378:            }
0379:
0380:            public boolean isDummy() {
0381:                return isDummy;
0382:            }
0383:
0384:            public Node.Root getRoot() {
0385:                Node n = this ;
0386:                while (!(n instanceof  Node.Root)) {
0387:                    n = n.getParent();
0388:                }
0389:                return (Node.Root) n;
0390:            }
0391:
0392:            public String getInnerClassName() {
0393:                return innerClassName;
0394:            }
0395:
0396:            public void setInnerClassName(String icn) {
0397:                innerClassName = icn;
0398:            }
0399:
0400:            /**
0401:             * Selects and invokes a method in the visitor class based on the node type.
0402:             * This is abstract and should be overrode by the extending classes.
0403:             * 
0404:             * @param v
0405:             *            The visitor class
0406:             */
0407:            abstract void accept(Visitor v) throws JasperException;
0408:
0409:            // *********************************************************************
0410:            // Private utility methods
0411:
0412:            /*
0413:             * Adds this Node to the body of the given parent.
0414:             */
0415:            private void addToParent(Node parent) {
0416:                if (parent != null) {
0417:                    this .parent = parent;
0418:                    Nodes parentBody = parent.getBody();
0419:                    if (parentBody == null) {
0420:                        parentBody = new Nodes();
0421:                        parent.setBody(parentBody);
0422:                    }
0423:                    parentBody.add(this );
0424:                }
0425:            }
0426:
0427:            /***************************************************************************
0428:             * Child classes
0429:             */
0430:
0431:            /**
0432:             * Represents the root of a Jsp page or Jsp document
0433:             */
0434:            public static class Root extends Node {
0435:
0436:                private Root parentRoot;
0437:
0438:                private boolean isXmlSyntax;
0439:
0440:                // Source encoding of the page containing this Root
0441:                private String pageEnc;
0442:
0443:                // Page encoding specified in JSP config element
0444:                private String jspConfigPageEnc;
0445:
0446:                /*
0447:                 * Flag indicating if the default page encoding is being used (only
0448:                 * applicable with standard syntax).
0449:                 * 
0450:                 * True if the page does not provide a page directive with a
0451:                 * 'contentType' attribute (or the 'contentType' attribute doesn't have
0452:                 * a CHARSET value), the page does not provide a page directive with a
0453:                 * 'pageEncoding' attribute, and there is no JSP configuration element
0454:                 * page-encoding whose URL pattern matches the page.
0455:                 */
0456:                private boolean isDefaultPageEncoding;
0457:
0458:                /*
0459:                 * Indicates whether an encoding has been explicitly specified in the
0460:                 * page's XML prolog (only used for pages in XML syntax). This
0461:                 * information is used to decide whether a translation error must be
0462:                 * reported for encoding conflicts.
0463:                 */
0464:                private boolean isEncodingSpecifiedInProlog;
0465:
0466:                /*
0467:                 * Indicates whether an encoding has been explicitly specified in the
0468:                 * page's bom.
0469:                 */
0470:                private boolean isBomPresent;
0471:
0472:                /*
0473:                 * Constructor.
0474:                 */
0475:                Root(Mark start, Node parent, boolean isXmlSyntax) {
0476:                    super (start, parent);
0477:                    this .isXmlSyntax = isXmlSyntax;
0478:                    this .qName = JSP_ROOT_ACTION;
0479:                    this .localName = ROOT_ACTION;
0480:
0481:                    // Figure out and set the parent root
0482:                    Node r = parent;
0483:                    while ((r != null) && !(r instanceof  Node.Root))
0484:                        r = r.getParent();
0485:                    parentRoot = (Node.Root) r;
0486:                }
0487:
0488:                public void accept(Visitor v) throws JasperException {
0489:                    v.visit(this );
0490:                }
0491:
0492:                public boolean isXmlSyntax() {
0493:                    return isXmlSyntax;
0494:                }
0495:
0496:                /*
0497:                 * Sets the encoding specified in the JSP config element whose URL
0498:                 * pattern matches the page containing this Root.
0499:                 */
0500:                public void setJspConfigPageEncoding(String enc) {
0501:                    jspConfigPageEnc = enc;
0502:                }
0503:
0504:                /*
0505:                 * Gets the encoding specified in the JSP config element whose URL
0506:                 * pattern matches the page containing this Root.
0507:                 */
0508:                public String getJspConfigPageEncoding() {
0509:                    return jspConfigPageEnc;
0510:                }
0511:
0512:                public void setPageEncoding(String enc) {
0513:                    pageEnc = enc;
0514:                }
0515:
0516:                public String getPageEncoding() {
0517:                    return pageEnc;
0518:                }
0519:
0520:                public void setIsDefaultPageEncoding(boolean isDefault) {
0521:                    isDefaultPageEncoding = isDefault;
0522:                }
0523:
0524:                public boolean isDefaultPageEncoding() {
0525:                    return isDefaultPageEncoding;
0526:                }
0527:
0528:                public void setIsEncodingSpecifiedInProlog(boolean isSpecified) {
0529:                    isEncodingSpecifiedInProlog = isSpecified;
0530:                }
0531:
0532:                public boolean isEncodingSpecifiedInProlog() {
0533:                    return isEncodingSpecifiedInProlog;
0534:                }
0535:
0536:                public void setIsBomPresent(boolean isBom) {
0537:                    isBomPresent = isBom;
0538:                }
0539:
0540:                public boolean isBomPresent() {
0541:                    return isBomPresent;
0542:                }
0543:
0544:                /**
0545:                 * @return The enclosing root to this Root. Usually represents the page
0546:                 *         that includes this one.
0547:                 */
0548:                public Root getParentRoot() {
0549:                    return parentRoot;
0550:                }
0551:            }
0552:
0553:            /**
0554:             * Represents the root of a Jsp document (XML syntax)
0555:             */
0556:            public static class JspRoot extends Node {
0557:
0558:                public JspRoot(String qName, Attributes attrs,
0559:                        Attributes nonTaglibXmlnsAttrs, Attributes taglibAttrs,
0560:                        Mark start, Node parent) {
0561:                    super (qName, ROOT_ACTION, attrs, nonTaglibXmlnsAttrs,
0562:                            taglibAttrs, start, parent);
0563:                }
0564:
0565:                public void accept(Visitor v) throws JasperException {
0566:                    v.visit(this );
0567:                }
0568:            }
0569:
0570:            /**
0571:             * Represents a page directive
0572:             */
0573:            public static class PageDirective extends Node {
0574:
0575:                private Vector imports;
0576:
0577:                public PageDirective(Attributes attrs, Mark start, Node parent) {
0578:                    this (JSP_PAGE_DIRECTIVE_ACTION, attrs, null, null, start,
0579:                            parent);
0580:                }
0581:
0582:                public PageDirective(String qName, Attributes attrs,
0583:                        Attributes nonTaglibXmlnsAttrs, Attributes taglibAttrs,
0584:                        Mark start, Node parent) {
0585:                    super (qName, PAGE_DIRECTIVE_ACTION, attrs,
0586:                            nonTaglibXmlnsAttrs, taglibAttrs, start, parent);
0587:                    imports = new Vector();
0588:                }
0589:
0590:                public void accept(Visitor v) throws JasperException {
0591:                    v.visit(this );
0592:                }
0593:
0594:                /**
0595:                 * Parses the comma-separated list of class or package names in the
0596:                 * given attribute value and adds each component to this PageDirective's
0597:                 * vector of imported classes and packages.
0598:                 * 
0599:                 * @param value
0600:                 *            A comma-separated string of imports.
0601:                 */
0602:                public void addImport(String value) {
0603:                    int start = 0;
0604:                    int index;
0605:                    while ((index = value.indexOf(',', start)) != -1) {
0606:                        imports.add(value.substring(start, index).trim());
0607:                        start = index + 1;
0608:                    }
0609:                    if (start == 0) {
0610:                        // No comma found
0611:                        imports.add(value.trim());
0612:                    } else {
0613:                        imports.add(value.substring(start).trim());
0614:                    }
0615:                }
0616:
0617:                public List getImports() {
0618:                    return imports;
0619:                }
0620:            }
0621:
0622:            /**
0623:             * Represents an include directive
0624:             */
0625:            public static class IncludeDirective extends Node {
0626:
0627:                public IncludeDirective(Attributes attrs, Mark start,
0628:                        Node parent) {
0629:                    this (JSP_INCLUDE_DIRECTIVE_ACTION, attrs, null, null,
0630:                            start, parent);
0631:                }
0632:
0633:                public IncludeDirective(String qName, Attributes attrs,
0634:                        Attributes nonTaglibXmlnsAttrs, Attributes taglibAttrs,
0635:                        Mark start, Node parent) {
0636:                    super (qName, INCLUDE_DIRECTIVE_ACTION, attrs,
0637:                            nonTaglibXmlnsAttrs, taglibAttrs, start, parent);
0638:                }
0639:
0640:                public void accept(Visitor v) throws JasperException {
0641:                    v.visit(this );
0642:                }
0643:            }
0644:
0645:            /**
0646:             * Represents a custom taglib directive
0647:             */
0648:            public static class TaglibDirective extends Node {
0649:
0650:                public TaglibDirective(Attributes attrs, Mark start, Node parent) {
0651:                    super (JSP_TAGLIB_DIRECTIVE_ACTION, TAGLIB_DIRECTIVE_ACTION,
0652:                            attrs, start, parent);
0653:                }
0654:
0655:                public void accept(Visitor v) throws JasperException {
0656:                    v.visit(this );
0657:                }
0658:            }
0659:
0660:            /**
0661:             * Represents a tag directive
0662:             */
0663:            public static class TagDirective extends Node {
0664:                private Vector imports;
0665:
0666:                public TagDirective(Attributes attrs, Mark start, Node parent) {
0667:                    this (JSP_TAG_DIRECTIVE_ACTION, attrs, null, null, start,
0668:                            parent);
0669:                }
0670:
0671:                public TagDirective(String qName, Attributes attrs,
0672:                        Attributes nonTaglibXmlnsAttrs, Attributes taglibAttrs,
0673:                        Mark start, Node parent) {
0674:                    super (qName, TAG_DIRECTIVE_ACTION, attrs,
0675:                            nonTaglibXmlnsAttrs, taglibAttrs, start, parent);
0676:                    imports = new Vector();
0677:                }
0678:
0679:                public void accept(Visitor v) throws JasperException {
0680:                    v.visit(this );
0681:                }
0682:
0683:                /**
0684:                 * Parses the comma-separated list of class or package names in the
0685:                 * given attribute value and adds each component to this PageDirective's
0686:                 * vector of imported classes and packages.
0687:                 * 
0688:                 * @param value
0689:                 *            A comma-separated string of imports.
0690:                 */
0691:                public void addImport(String value) {
0692:                    int start = 0;
0693:                    int index;
0694:                    while ((index = value.indexOf(',', start)) != -1) {
0695:                        imports.add(value.substring(start, index).trim());
0696:                        start = index + 1;
0697:                    }
0698:                    if (start == 0) {
0699:                        // No comma found
0700:                        imports.add(value.trim());
0701:                    } else {
0702:                        imports.add(value.substring(start).trim());
0703:                    }
0704:                }
0705:
0706:                public List getImports() {
0707:                    return imports;
0708:                }
0709:            }
0710:
0711:            /**
0712:             * Represents an attribute directive
0713:             */
0714:            public static class AttributeDirective extends Node {
0715:
0716:                public AttributeDirective(Attributes attrs, Mark start,
0717:                        Node parent) {
0718:                    this (JSP_ATTRIBUTE_DIRECTIVE_ACTION, attrs, null, null,
0719:                            start, parent);
0720:                }
0721:
0722:                public AttributeDirective(String qName, Attributes attrs,
0723:                        Attributes nonTaglibXmlnsAttrs, Attributes taglibAttrs,
0724:                        Mark start, Node parent) {
0725:                    super (qName, ATTRIBUTE_DIRECTIVE_ACTION, attrs,
0726:                            nonTaglibXmlnsAttrs, taglibAttrs, start, parent);
0727:                }
0728:
0729:                public void accept(Visitor v) throws JasperException {
0730:                    v.visit(this );
0731:                }
0732:            }
0733:
0734:            /**
0735:             * Represents a variable directive
0736:             */
0737:            public static class VariableDirective extends Node {
0738:
0739:                public VariableDirective(Attributes attrs, Mark start,
0740:                        Node parent) {
0741:                    this (JSP_VARIABLE_DIRECTIVE_ACTION, attrs, null, null,
0742:                            start, parent);
0743:                }
0744:
0745:                public VariableDirective(String qName, Attributes attrs,
0746:                        Attributes nonTaglibXmlnsAttrs, Attributes taglibAttrs,
0747:                        Mark start, Node parent) {
0748:                    super (qName, VARIABLE_DIRECTIVE_ACTION, attrs,
0749:                            nonTaglibXmlnsAttrs, taglibAttrs, start, parent);
0750:                }
0751:
0752:                public void accept(Visitor v) throws JasperException {
0753:                    v.visit(this );
0754:                }
0755:            }
0756:
0757:            /**
0758:             * Represents a <jsp:invoke> tag file action
0759:             */
0760:            public static class InvokeAction extends Node {
0761:
0762:                public InvokeAction(Attributes attrs, Mark start, Node parent) {
0763:                    this (JSP_INVOKE_ACTION, attrs, null, null, start, parent);
0764:                }
0765:
0766:                public InvokeAction(String qName, Attributes attrs,
0767:                        Attributes nonTaglibXmlnsAttrs, Attributes taglibAttrs,
0768:                        Mark start, Node parent) {
0769:                    super (qName, INVOKE_ACTION, attrs, nonTaglibXmlnsAttrs,
0770:                            taglibAttrs, start, parent);
0771:                }
0772:
0773:                public void accept(Visitor v) throws JasperException {
0774:                    v.visit(this );
0775:                }
0776:            }
0777:
0778:            /**
0779:             * Represents a <jsp:doBody> tag file action
0780:             */
0781:            public static class DoBodyAction extends Node {
0782:
0783:                public DoBodyAction(Attributes attrs, Mark start, Node parent) {
0784:                    this (JSP_DOBODY_ACTION, attrs, null, null, start, parent);
0785:                }
0786:
0787:                public DoBodyAction(String qName, Attributes attrs,
0788:                        Attributes nonTaglibXmlnsAttrs, Attributes taglibAttrs,
0789:                        Mark start, Node parent) {
0790:                    super (qName, DOBODY_ACTION, attrs, nonTaglibXmlnsAttrs,
0791:                            taglibAttrs, start, parent);
0792:                }
0793:
0794:                public void accept(Visitor v) throws JasperException {
0795:                    v.visit(this );
0796:                }
0797:            }
0798:
0799:            /**
0800:             * Represents a Jsp comment Comments are kept for completeness.
0801:             */
0802:            public static class Comment extends Node {
0803:
0804:                public Comment(String text, Mark start, Node parent) {
0805:                    super (null, null, text, start, parent);
0806:                }
0807:
0808:                public void accept(Visitor v) throws JasperException {
0809:                    v.visit(this );
0810:                }
0811:            }
0812:
0813:            /**
0814:             * Represents an expression, declaration, or scriptlet
0815:             */
0816:            public static abstract class ScriptingElement extends Node {
0817:
0818:                public ScriptingElement(String qName, String localName,
0819:                        String text, Mark start, Node parent) {
0820:                    super (qName, localName, text, start, parent);
0821:                }
0822:
0823:                public ScriptingElement(String qName, String localName,
0824:                        Attributes nonTaglibXmlnsAttrs, Attributes taglibAttrs,
0825:                        Mark start, Node parent) {
0826:                    super (qName, localName, null, nonTaglibXmlnsAttrs,
0827:                            taglibAttrs, start, parent);
0828:                }
0829:
0830:                /**
0831:                 * When this node was created from a JSP page in JSP syntax, its text
0832:                 * was stored as a String in the "text" field, whereas when this node
0833:                 * was created from a JSP document, its text was stored as one or more
0834:                 * TemplateText nodes in its body. This method handles either case.
0835:                 * 
0836:                 * @return The text string
0837:                 */
0838:                public String getText() {
0839:                    String ret = text;
0840:                    if ((ret == null) && (body != null)) {
0841:                        StringBuffer buf = new StringBuffer();
0842:                        for (int i = 0; i < body.size(); i++) {
0843:                            buf.append(body.getNode(i).getText());
0844:                        }
0845:                        ret = buf.toString();
0846:                    }
0847:                    return ret;
0848:                }
0849:
0850:                /**
0851:                 * For the same reason as above, the source line information in the
0852:                 * contained TemplateText node should be used.
0853:                 */
0854:                public Mark getStart() {
0855:                    if (text == null && body != null && body.size() > 0) {
0856:                        return body.getNode(0).getStart();
0857:                    } else {
0858:                        return super .getStart();
0859:                    }
0860:                }
0861:            }
0862:
0863:            /**
0864:             * Represents a declaration
0865:             */
0866:            public static class Declaration extends ScriptingElement {
0867:
0868:                public Declaration(String text, Mark start, Node parent) {
0869:                    super (JSP_DECLARATION_ACTION, DECLARATION_ACTION, text,
0870:                            start, parent);
0871:                }
0872:
0873:                public Declaration(String qName,
0874:                        Attributes nonTaglibXmlnsAttrs, Attributes taglibAttrs,
0875:                        Mark start, Node parent) {
0876:                    super (qName, DECLARATION_ACTION, nonTaglibXmlnsAttrs,
0877:                            taglibAttrs, start, parent);
0878:                }
0879:
0880:                public void accept(Visitor v) throws JasperException {
0881:                    v.visit(this );
0882:                }
0883:            }
0884:
0885:            /**
0886:             * Represents an expression. Expressions in attributes are embedded in the
0887:             * attribute string and not here.
0888:             */
0889:            public static class Expression extends ScriptingElement {
0890:
0891:                public Expression(String text, Mark start, Node parent) {
0892:                    super (JSP_EXPRESSION_ACTION, EXPRESSION_ACTION, text,
0893:                            start, parent);
0894:                }
0895:
0896:                public Expression(String qName, Attributes nonTaglibXmlnsAttrs,
0897:                        Attributes taglibAttrs, Mark start, Node parent) {
0898:                    super (qName, EXPRESSION_ACTION, nonTaglibXmlnsAttrs,
0899:                            taglibAttrs, start, parent);
0900:                }
0901:
0902:                public void accept(Visitor v) throws JasperException {
0903:                    v.visit(this );
0904:                }
0905:            }
0906:
0907:            /**
0908:             * Represents a scriptlet
0909:             */
0910:            public static class Scriptlet extends ScriptingElement {
0911:
0912:                public Scriptlet(String text, Mark start, Node parent) {
0913:                    super (JSP_SCRIPTLET_ACTION, SCRIPTLET_ACTION, text, start,
0914:                            parent);
0915:                }
0916:
0917:                public Scriptlet(String qName, Attributes nonTaglibXmlnsAttrs,
0918:                        Attributes taglibAttrs, Mark start, Node parent) {
0919:                    super (qName, SCRIPTLET_ACTION, nonTaglibXmlnsAttrs,
0920:                            taglibAttrs, start, parent);
0921:                }
0922:
0923:                public void accept(Visitor v) throws JasperException {
0924:                    v.visit(this );
0925:                }
0926:            }
0927:
0928:            /**
0929:             * Represents an EL expression. Expressions in attributes are embedded in
0930:             * the attribute string and not here.
0931:             */
0932:            public static class ELExpression extends Node {
0933:
0934:                private ELNode.Nodes el;
0935:
0936:                private final char type;
0937:
0938:                public ELExpression(char type, String text, Mark start,
0939:                        Node parent) {
0940:                    super (null, null, text, start, parent);
0941:                    this .type = type;
0942:                }
0943:
0944:                public void accept(Visitor v) throws JasperException {
0945:                    v.visit(this );
0946:                }
0947:
0948:                public void setEL(ELNode.Nodes el) {
0949:                    this .el = el;
0950:                }
0951:
0952:                public ELNode.Nodes getEL() {
0953:                    return el;
0954:                }
0955:
0956:                public char getType() {
0957:                    return this .type;
0958:                }
0959:            }
0960:
0961:            /**
0962:             * Represents a param action
0963:             */
0964:            public static class ParamAction extends Node {
0965:
0966:                JspAttribute value;
0967:
0968:                public ParamAction(Attributes attrs, Mark start, Node parent) {
0969:                    this (JSP_PARAM_ACTION, attrs, null, null, start, parent);
0970:                }
0971:
0972:                public ParamAction(String qName, Attributes attrs,
0973:                        Attributes nonTaglibXmlnsAttrs, Attributes taglibAttrs,
0974:                        Mark start, Node parent) {
0975:                    super (qName, PARAM_ACTION, attrs, nonTaglibXmlnsAttrs,
0976:                            taglibAttrs, start, parent);
0977:                }
0978:
0979:                public void accept(Visitor v) throws JasperException {
0980:                    v.visit(this );
0981:                }
0982:
0983:                public void setValue(JspAttribute value) {
0984:                    this .value = value;
0985:                }
0986:
0987:                public JspAttribute getValue() {
0988:                    return value;
0989:                }
0990:            }
0991:
0992:            /**
0993:             * Represents a params action
0994:             */
0995:            public static class ParamsAction extends Node {
0996:
0997:                public ParamsAction(Mark start, Node parent) {
0998:                    this (JSP_PARAMS_ACTION, null, null, start, parent);
0999:                }
1000:
1001:                public ParamsAction(String qName,
1002:                        Attributes nonTaglibXmlnsAttrs, Attributes taglibAttrs,
1003:                        Mark start, Node parent) {
1004:                    super (qName, PARAMS_ACTION, null, nonTaglibXmlnsAttrs,
1005:                            taglibAttrs, start, parent);
1006:                }
1007:
1008:                public void accept(Visitor v) throws JasperException {
1009:                    v.visit(this );
1010:                }
1011:            }
1012:
1013:            /**
1014:             * Represents a fallback action
1015:             */
1016:            public static class FallBackAction extends Node {
1017:
1018:                public FallBackAction(Mark start, Node parent) {
1019:                    this (JSP_FALLBACK_ACTION, null, null, start, parent);
1020:                }
1021:
1022:                public FallBackAction(String qName,
1023:                        Attributes nonTaglibXmlnsAttrs, Attributes taglibAttrs,
1024:                        Mark start, Node parent) {
1025:                    super (qName, FALLBACK_ACTION, null, nonTaglibXmlnsAttrs,
1026:                            taglibAttrs, start, parent);
1027:                }
1028:
1029:                public void accept(Visitor v) throws JasperException {
1030:                    v.visit(this );
1031:                }
1032:            }
1033:
1034:            /**
1035:             * Represents an include action
1036:             */
1037:            public static class IncludeAction extends Node {
1038:
1039:                private JspAttribute page;
1040:
1041:                public IncludeAction(Attributes attrs, Mark start, Node parent) {
1042:                    this (JSP_INCLUDE_ACTION, attrs, null, null, start, parent);
1043:                }
1044:
1045:                public IncludeAction(String qName, Attributes attrs,
1046:                        Attributes nonTaglibXmlnsAttrs, Attributes taglibAttrs,
1047:                        Mark start, Node parent) {
1048:                    super (qName, INCLUDE_ACTION, attrs, nonTaglibXmlnsAttrs,
1049:                            taglibAttrs, start, parent);
1050:                }
1051:
1052:                public void accept(Visitor v) throws JasperException {
1053:                    v.visit(this );
1054:                }
1055:
1056:                public void setPage(JspAttribute page) {
1057:                    this .page = page;
1058:                }
1059:
1060:                public JspAttribute getPage() {
1061:                    return page;
1062:                }
1063:            }
1064:
1065:            /**
1066:             * Represents a forward action
1067:             */
1068:            public static class ForwardAction extends Node {
1069:
1070:                private JspAttribute page;
1071:
1072:                public ForwardAction(Attributes attrs, Mark start, Node parent) {
1073:                    this (JSP_FORWARD_ACTION, attrs, null, null, start, parent);
1074:                }
1075:
1076:                public ForwardAction(String qName, Attributes attrs,
1077:                        Attributes nonTaglibXmlnsAttrs, Attributes taglibAttrs,
1078:                        Mark start, Node parent) {
1079:                    super (qName, FORWARD_ACTION, attrs, nonTaglibXmlnsAttrs,
1080:                            taglibAttrs, start, parent);
1081:                }
1082:
1083:                public void accept(Visitor v) throws JasperException {
1084:                    v.visit(this );
1085:                }
1086:
1087:                public void setPage(JspAttribute page) {
1088:                    this .page = page;
1089:                }
1090:
1091:                public JspAttribute getPage() {
1092:                    return page;
1093:                }
1094:            }
1095:
1096:            /**
1097:             * Represents a getProperty action
1098:             */
1099:            public static class GetProperty extends Node {
1100:
1101:                public GetProperty(Attributes attrs, Mark start, Node parent) {
1102:                    this (JSP_GET_PROPERTY_ACTION, attrs, null, null, start,
1103:                            parent);
1104:                }
1105:
1106:                public GetProperty(String qName, Attributes attrs,
1107:                        Attributes nonTaglibXmlnsAttrs, Attributes taglibAttrs,
1108:                        Mark start, Node parent) {
1109:                    super (qName, GET_PROPERTY_ACTION, attrs,
1110:                            nonTaglibXmlnsAttrs, taglibAttrs, start, parent);
1111:                }
1112:
1113:                public void accept(Visitor v) throws JasperException {
1114:                    v.visit(this );
1115:                }
1116:            }
1117:
1118:            /**
1119:             * Represents a setProperty action
1120:             */
1121:            public static class SetProperty extends Node {
1122:
1123:                private JspAttribute value;
1124:
1125:                public SetProperty(Attributes attrs, Mark start, Node parent) {
1126:                    this (JSP_SET_PROPERTY_ACTION, attrs, null, null, start,
1127:                            parent);
1128:                }
1129:
1130:                public SetProperty(String qName, Attributes attrs,
1131:                        Attributes nonTaglibXmlnsAttrs, Attributes taglibAttrs,
1132:                        Mark start, Node parent) {
1133:                    super (qName, SET_PROPERTY_ACTION, attrs,
1134:                            nonTaglibXmlnsAttrs, taglibAttrs, start, parent);
1135:                }
1136:
1137:                public void accept(Visitor v) throws JasperException {
1138:                    v.visit(this );
1139:                }
1140:
1141:                public void setValue(JspAttribute value) {
1142:                    this .value = value;
1143:                }
1144:
1145:                public JspAttribute getValue() {
1146:                    return value;
1147:                }
1148:            }
1149:
1150:            /**
1151:             * Represents a useBean action
1152:             */
1153:            public static class UseBean extends Node {
1154:
1155:                JspAttribute beanName;
1156:
1157:                public UseBean(Attributes attrs, Mark start, Node parent) {
1158:                    this (JSP_USE_BEAN_ACTION, attrs, null, null, start, parent);
1159:                }
1160:
1161:                public UseBean(String qName, Attributes attrs,
1162:                        Attributes nonTaglibXmlnsAttrs, Attributes taglibAttrs,
1163:                        Mark start, Node parent) {
1164:                    super (qName, USE_BEAN_ACTION, attrs, nonTaglibXmlnsAttrs,
1165:                            taglibAttrs, start, parent);
1166:                }
1167:
1168:                public void accept(Visitor v) throws JasperException {
1169:                    v.visit(this );
1170:                }
1171:
1172:                public void setBeanName(JspAttribute beanName) {
1173:                    this .beanName = beanName;
1174:                }
1175:
1176:                public JspAttribute getBeanName() {
1177:                    return beanName;
1178:                }
1179:            }
1180:
1181:            /**
1182:             * Represents a plugin action
1183:             */
1184:            public static class PlugIn extends Node {
1185:
1186:                private JspAttribute width;
1187:
1188:                private JspAttribute height;
1189:
1190:                public PlugIn(Attributes attrs, Mark start, Node parent) {
1191:                    this (JSP_PLUGIN_ACTION, attrs, null, null, start, parent);
1192:                }
1193:
1194:                public PlugIn(String qName, Attributes attrs,
1195:                        Attributes nonTaglibXmlnsAttrs, Attributes taglibAttrs,
1196:                        Mark start, Node parent) {
1197:                    super (qName, PLUGIN_ACTION, attrs, nonTaglibXmlnsAttrs,
1198:                            taglibAttrs, start, parent);
1199:                }
1200:
1201:                public void accept(Visitor v) throws JasperException {
1202:                    v.visit(this );
1203:                }
1204:
1205:                public void setHeight(JspAttribute height) {
1206:                    this .height = height;
1207:                }
1208:
1209:                public void setWidth(JspAttribute width) {
1210:                    this .width = width;
1211:                }
1212:
1213:                public JspAttribute getHeight() {
1214:                    return height;
1215:                }
1216:
1217:                public JspAttribute getWidth() {
1218:                    return width;
1219:                }
1220:            }
1221:
1222:            /**
1223:             * Represents an uninterpreted tag, from a Jsp document
1224:             */
1225:            public static class UninterpretedTag extends Node {
1226:
1227:                private JspAttribute[] jspAttrs;
1228:
1229:                public UninterpretedTag(String qName, String localName,
1230:                        Attributes attrs, Attributes nonTaglibXmlnsAttrs,
1231:                        Attributes taglibAttrs, Mark start, Node parent) {
1232:                    super (qName, localName, attrs, nonTaglibXmlnsAttrs,
1233:                            taglibAttrs, start, parent);
1234:                }
1235:
1236:                public void accept(Visitor v) throws JasperException {
1237:                    v.visit(this );
1238:                }
1239:
1240:                public void setJspAttributes(JspAttribute[] jspAttrs) {
1241:                    this .jspAttrs = jspAttrs;
1242:                }
1243:
1244:                public JspAttribute[] getJspAttributes() {
1245:                    return jspAttrs;
1246:                }
1247:            }
1248:
1249:            /**
1250:             * Represents a <jsp:element>.
1251:             */
1252:            public static class JspElement extends Node {
1253:
1254:                private JspAttribute[] jspAttrs;
1255:
1256:                private JspAttribute nameAttr;
1257:
1258:                public JspElement(Attributes attrs, Mark start, Node parent) {
1259:                    this (JSP_ELEMENT_ACTION, attrs, null, null, start, parent);
1260:                }
1261:
1262:                public JspElement(String qName, Attributes attrs,
1263:                        Attributes nonTaglibXmlnsAttrs, Attributes taglibAttrs,
1264:                        Mark start, Node parent) {
1265:                    super (qName, ELEMENT_ACTION, attrs, nonTaglibXmlnsAttrs,
1266:                            taglibAttrs, start, parent);
1267:                }
1268:
1269:                public void accept(Visitor v) throws JasperException {
1270:                    v.visit(this );
1271:                }
1272:
1273:                public void setJspAttributes(JspAttribute[] jspAttrs) {
1274:                    this .jspAttrs = jspAttrs;
1275:                }
1276:
1277:                public JspAttribute[] getJspAttributes() {
1278:                    return jspAttrs;
1279:                }
1280:
1281:                /*
1282:                 * Sets the XML-style 'name' attribute
1283:                 */
1284:                public void setNameAttribute(JspAttribute nameAttr) {
1285:                    this .nameAttr = nameAttr;
1286:                }
1287:
1288:                /*
1289:                 * Gets the XML-style 'name' attribute
1290:                 */
1291:                public JspAttribute getNameAttribute() {
1292:                    return this .nameAttr;
1293:                }
1294:            }
1295:
1296:            /**
1297:             * Represents a <jsp:output>.
1298:             */
1299:            public static class JspOutput extends Node {
1300:
1301:                public JspOutput(String qName, Attributes attrs,
1302:                        Attributes nonTaglibXmlnsAttrs, Attributes taglibAttrs,
1303:                        Mark start, Node parent) {
1304:                    super (qName, OUTPUT_ACTION, attrs, nonTaglibXmlnsAttrs,
1305:                            taglibAttrs, start, parent);
1306:                }
1307:
1308:                public void accept(Visitor v) throws JasperException {
1309:                    v.visit(this );
1310:                }
1311:            }
1312:
1313:            /**
1314:             * Collected information about child elements. Used by nodes like CustomTag,
1315:             * JspBody, and NamedAttribute. The information is set in the Collector.
1316:             */
1317:            public static class ChildInfo {
1318:                private boolean scriptless; // true if the tag and its body
1319:
1320:                // contain no scripting elements.
1321:                private boolean hasUseBean;
1322:
1323:                private boolean hasIncludeAction;
1324:
1325:                private boolean hasParamAction;
1326:
1327:                private boolean hasSetProperty;
1328:
1329:                private boolean hasScriptingVars;
1330:
1331:                public void setScriptless(boolean s) {
1332:                    scriptless = s;
1333:                }
1334:
1335:                public boolean isScriptless() {
1336:                    return scriptless;
1337:                }
1338:
1339:                public void setHasUseBean(boolean u) {
1340:                    hasUseBean = u;
1341:                }
1342:
1343:                public boolean hasUseBean() {
1344:                    return hasUseBean;
1345:                }
1346:
1347:                public void setHasIncludeAction(boolean i) {
1348:                    hasIncludeAction = i;
1349:                }
1350:
1351:                public boolean hasIncludeAction() {
1352:                    return hasIncludeAction;
1353:                }
1354:
1355:                public void setHasParamAction(boolean i) {
1356:                    hasParamAction = i;
1357:                }
1358:
1359:                public boolean hasParamAction() {
1360:                    return hasParamAction;
1361:                }
1362:
1363:                public void setHasSetProperty(boolean s) {
1364:                    hasSetProperty = s;
1365:                }
1366:
1367:                public boolean hasSetProperty() {
1368:                    return hasSetProperty;
1369:                }
1370:
1371:                public void setHasScriptingVars(boolean s) {
1372:                    hasScriptingVars = s;
1373:                }
1374:
1375:                public boolean hasScriptingVars() {
1376:                    return hasScriptingVars;
1377:                }
1378:            }
1379:
1380:            /**
1381:             * Represents a custom tag
1382:             */
1383:            public static class CustomTag extends Node {
1384:
1385:                private String uri;
1386:
1387:                private String prefix;
1388:
1389:                private JspAttribute[] jspAttrs;
1390:
1391:                private TagData tagData;
1392:
1393:                private String tagHandlerPoolName;
1394:
1395:                private TagInfo tagInfo;
1396:
1397:                private TagFileInfo tagFileInfo;
1398:
1399:                private Class tagHandlerClass;
1400:
1401:                private VariableInfo[] varInfos;
1402:
1403:                private int customNestingLevel;
1404:
1405:                private ChildInfo childInfo;
1406:
1407:                private boolean implements IterationTag;
1408:
1409:                private boolean implements BodyTag;
1410:
1411:                private boolean implements TryCatchFinally;
1412:
1413:                private boolean implements JspIdConsumer;
1414:
1415:                private boolean implements SimpleTag;
1416:
1417:                private boolean implements DynamicAttributes;
1418:
1419:                private Vector atBeginScriptingVars;
1420:
1421:                private Vector atEndScriptingVars;
1422:
1423:                private Vector nestedScriptingVars;
1424:
1425:                private Node.CustomTag customTagParent;
1426:
1427:                private Integer numCount;
1428:
1429:                private boolean useTagPlugin;
1430:
1431:                private TagPluginContext tagPluginContext;
1432:
1433:                /**
1434:                 * The following two fields are used for holding the Java scriptlets
1435:                 * that the tag plugins may generate. Meaningful only if useTagPlugin is
1436:                 * true; Could move them into TagPluginContextImpl, but we'll need to
1437:                 * cast tagPluginContext to TagPluginContextImpl all the time...
1438:                 */
1439:                private Nodes atSTag;
1440:
1441:                private Nodes atETag;
1442:
1443:                /*
1444:                 * Constructor for custom action implemented by tag handler.
1445:                 */
1446:                public CustomTag(String qName, String prefix, String localName,
1447:                        String uri, Attributes attrs, Mark start, Node parent,
1448:                        TagInfo tagInfo, Class tagHandlerClass) {
1449:                    this (qName, prefix, localName, uri, attrs, null, null,
1450:                            start, parent, tagInfo, tagHandlerClass);
1451:                }
1452:
1453:                /*
1454:                 * Constructor for custom action implemented by tag handler.
1455:                 */
1456:                public CustomTag(String qName, String prefix, String localName,
1457:                        String uri, Attributes attrs,
1458:                        Attributes nonTaglibXmlnsAttrs, Attributes taglibAttrs,
1459:                        Mark start, Node parent, TagInfo tagInfo,
1460:                        Class tagHandlerClass) {
1461:                    super (qName, localName, attrs, nonTaglibXmlnsAttrs,
1462:                            taglibAttrs, start, parent);
1463:
1464:                    this .uri = uri;
1465:                    this .prefix = prefix;
1466:                    this .tagInfo = tagInfo;
1467:                    this .tagHandlerClass = tagHandlerClass;
1468:                    this .customNestingLevel = makeCustomNestingLevel();
1469:                    this .childInfo = new ChildInfo();
1470:
1471:                    this .implements IterationTag = IterationTag.class
1472:                            .isAssignableFrom(tagHandlerClass);
1473:                    this .implements BodyTag = BodyTag.class
1474:                            .isAssignableFrom(tagHandlerClass);
1475:                    this .implements TryCatchFinally = TryCatchFinally.class
1476:                            .isAssignableFrom(tagHandlerClass);
1477:                    this .implements SimpleTag = SimpleTag.class
1478:                            .isAssignableFrom(tagHandlerClass);
1479:                    this .implements DynamicAttributes = DynamicAttributes.class
1480:                            .isAssignableFrom(tagHandlerClass);
1481:                    this .implements JspIdConsumer = JspIdConsumer.class
1482:                            .isAssignableFrom(tagHandlerClass);
1483:                }
1484:
1485:                /*
1486:                 * Constructor for custom action implemented by tag file.
1487:                 */
1488:                public CustomTag(String qName, String prefix, String localName,
1489:                        String uri, Attributes attrs, Mark start, Node parent,
1490:                        TagFileInfo tagFileInfo) {
1491:                    this (qName, prefix, localName, uri, attrs, null, null,
1492:                            start, parent, tagFileInfo);
1493:                }
1494:
1495:                /*
1496:                 * Constructor for custom action implemented by tag file.
1497:                 */
1498:                public CustomTag(String qName, String prefix, String localName,
1499:                        String uri, Attributes attrs,
1500:                        Attributes nonTaglibXmlnsAttrs, Attributes taglibAttrs,
1501:                        Mark start, Node parent, TagFileInfo tagFileInfo) {
1502:
1503:                    super (qName, localName, attrs, nonTaglibXmlnsAttrs,
1504:                            taglibAttrs, start, parent);
1505:
1506:                    this .uri = uri;
1507:                    this .prefix = prefix;
1508:                    this .tagFileInfo = tagFileInfo;
1509:                    this .tagInfo = tagFileInfo.getTagInfo();
1510:                    this .customNestingLevel = makeCustomNestingLevel();
1511:                    this .childInfo = new ChildInfo();
1512:
1513:                    this .implements IterationTag = false;
1514:                    this .implements BodyTag = false;
1515:                    this .implements TryCatchFinally = false;
1516:                    this .implements SimpleTag = true;
1517:                    this .implements JspIdConsumer = false;
1518:                    this .implements DynamicAttributes = tagInfo
1519:                            .hasDynamicAttributes();
1520:                }
1521:
1522:                public void accept(Visitor v) throws JasperException {
1523:                    v.visit(this );
1524:                }
1525:
1526:                /**
1527:                 * @return The URI namespace that this custom action belongs to
1528:                 */
1529:                public String getURI() {
1530:                    return this .uri;
1531:                }
1532:
1533:                /**
1534:                 * @return The tag prefix
1535:                 */
1536:                public String getPrefix() {
1537:                    return prefix;
1538:                }
1539:
1540:                public void setJspAttributes(JspAttribute[] jspAttrs) {
1541:                    this .jspAttrs = jspAttrs;
1542:                }
1543:
1544:                public TagAttributeInfo getTagAttributeInfo(String name) {
1545:                    TagInfo info = this .getTagInfo();
1546:                    if (info == null)
1547:                        return null;
1548:                    TagAttributeInfo[] tai = info.getAttributes();
1549:                    for (int i = 0; i < tai.length; i++) {
1550:                        if (tai[i].getName().equals(name)) {
1551:                            return tai[i];
1552:                        }
1553:                    }
1554:                    return null;
1555:                }
1556:
1557:                public JspAttribute[] getJspAttributes() {
1558:                    return jspAttrs;
1559:                }
1560:
1561:                public ChildInfo getChildInfo() {
1562:                    return childInfo;
1563:                }
1564:
1565:                public void setTagData(TagData tagData) {
1566:                    this .tagData = tagData;
1567:                    this .varInfos = tagInfo.getVariableInfo(tagData);
1568:                    if (this .varInfos == null) {
1569:                        this .varInfos = ZERO_VARIABLE_INFO;
1570:                    }
1571:                }
1572:
1573:                public TagData getTagData() {
1574:                    return tagData;
1575:                }
1576:
1577:                public void setTagHandlerPoolName(String s) {
1578:                    tagHandlerPoolName = s;
1579:                }
1580:
1581:                public String getTagHandlerPoolName() {
1582:                    return tagHandlerPoolName;
1583:                }
1584:
1585:                public TagInfo getTagInfo() {
1586:                    return tagInfo;
1587:                }
1588:
1589:                public TagFileInfo getTagFileInfo() {
1590:                    return tagFileInfo;
1591:                }
1592:
1593:                /*
1594:                 * @return true if this custom action is supported by a tag file, false
1595:                 * otherwise
1596:                 */
1597:                public boolean isTagFile() {
1598:                    return tagFileInfo != null;
1599:                }
1600:
1601:                public Class getTagHandlerClass() {
1602:                    return tagHandlerClass;
1603:                }
1604:
1605:                public void setTagHandlerClass(Class hc) {
1606:                    tagHandlerClass = hc;
1607:                }
1608:
1609:                public boolean implements IterationTag() {
1610:                    return implements IterationTag;
1611:                }
1612:
1613:                public boolean implements BodyTag() {
1614:                    return implements BodyTag;
1615:                }
1616:
1617:                public boolean implements TryCatchFinally() {
1618:                    return implements TryCatchFinally;
1619:                }
1620:
1621:                public boolean implements JspIdConsumer() {
1622:                    return implements JspIdConsumer;
1623:                }
1624:
1625:                public boolean implements SimpleTag() {
1626:                    return implements SimpleTag;
1627:                }
1628:
1629:                public boolean implements DynamicAttributes() {
1630:                    return implements DynamicAttributes;
1631:                }
1632:
1633:                public TagVariableInfo[] getTagVariableInfos() {
1634:                    return tagInfo.getTagVariableInfos();
1635:                }
1636:
1637:                public VariableInfo[] getVariableInfos() {
1638:                    return varInfos;
1639:                }
1640:
1641:                public void setCustomTagParent(Node.CustomTag n) {
1642:                    this .customTagParent = n;
1643:                }
1644:
1645:                public Node.CustomTag getCustomTagParent() {
1646:                    return this .customTagParent;
1647:                }
1648:
1649:                public void setNumCount(Integer count) {
1650:                    this .numCount = count;
1651:                }
1652:
1653:                public Integer getNumCount() {
1654:                    return this .numCount;
1655:                }
1656:
1657:                public void setScriptingVars(Vector vec, int scope) {
1658:                    switch (scope) {
1659:                    case VariableInfo.AT_BEGIN:
1660:                        this .atBeginScriptingVars = vec;
1661:                        break;
1662:                    case VariableInfo.AT_END:
1663:                        this .atEndScriptingVars = vec;
1664:                        break;
1665:                    case VariableInfo.NESTED:
1666:                        this .nestedScriptingVars = vec;
1667:                        break;
1668:                    }
1669:                }
1670:
1671:                /*
1672:                 * Gets the scripting variables for the given scope that need to be
1673:                 * declared.
1674:                 */
1675:                public Vector getScriptingVars(int scope) {
1676:                    Vector vec = null;
1677:
1678:                    switch (scope) {
1679:                    case VariableInfo.AT_BEGIN:
1680:                        vec = this .atBeginScriptingVars;
1681:                        break;
1682:                    case VariableInfo.AT_END:
1683:                        vec = this .atEndScriptingVars;
1684:                        break;
1685:                    case VariableInfo.NESTED:
1686:                        vec = this .nestedScriptingVars;
1687:                        break;
1688:                    }
1689:
1690:                    return vec;
1691:                }
1692:
1693:                /*
1694:                 * Gets this custom tag's custom nesting level, which is given as the
1695:                 * number of times this custom tag is nested inside itself.
1696:                 */
1697:                public int getCustomNestingLevel() {
1698:                    return customNestingLevel;
1699:                }
1700:
1701:                /**
1702:                 * Checks to see if the attribute of the given name is of type
1703:                 * JspFragment.
1704:                 */
1705:                public boolean checkIfAttributeIsJspFragment(String name) {
1706:                    boolean result = false;
1707:
1708:                    TagAttributeInfo[] attributes = tagInfo.getAttributes();
1709:                    for (int i = 0; i < attributes.length; i++) {
1710:                        if (attributes[i].getName().equals(name)
1711:                                && attributes[i].isFragment()) {
1712:                            result = true;
1713:                            break;
1714:                        }
1715:                    }
1716:
1717:                    return result;
1718:                }
1719:
1720:                public void setUseTagPlugin(boolean use) {
1721:                    useTagPlugin = use;
1722:                }
1723:
1724:                public boolean useTagPlugin() {
1725:                    return useTagPlugin;
1726:                }
1727:
1728:                public void setTagPluginContext(
1729:                        TagPluginContext tagPluginContext) {
1730:                    this .tagPluginContext = tagPluginContext;
1731:                }
1732:
1733:                public TagPluginContext getTagPluginContext() {
1734:                    return tagPluginContext;
1735:                }
1736:
1737:                public void setAtSTag(Nodes sTag) {
1738:                    atSTag = sTag;
1739:                }
1740:
1741:                public Nodes getAtSTag() {
1742:                    return atSTag;
1743:                }
1744:
1745:                public void setAtETag(Nodes eTag) {
1746:                    atETag = eTag;
1747:                }
1748:
1749:                public Nodes getAtETag() {
1750:                    return atETag;
1751:                }
1752:
1753:                /*
1754:                 * Computes this custom tag's custom nesting level, which corresponds to
1755:                 * the number of times this custom tag is nested inside itself.
1756:                 * 
1757:                 * Example:
1758:                 * 
1759:                 * <g:h> <a:b> -- nesting level 0 <c:d> <e:f> <a:b> -- nesting level 1
1760:                 * <a:b> -- nesting level 2 </a:b> </a:b> <a:b> -- nesting level 1
1761:                 * </a:b> </e:f> </c:d> </a:b> </g:h>
1762:                 * 
1763:                 * @return Custom tag's nesting level
1764:                 */
1765:                private int makeCustomNestingLevel() {
1766:                    int n = 0;
1767:                    Node p = parent;
1768:                    while (p != null) {
1769:                        if ((p instanceof  Node.CustomTag)
1770:                                && qName.equals(((Node.CustomTag) p).qName)) {
1771:                            n++;
1772:                        }
1773:                        p = p.parent;
1774:                    }
1775:                    return n;
1776:                }
1777:
1778:                /**
1779:                 * Returns true if this custom action has an empty body, and false
1780:                 * otherwise.
1781:                 * 
1782:                 * A custom action is considered to have an empty body if the following
1783:                 * holds true: - getBody() returns null, or - all immediate children are
1784:                 * jsp:attribute actions, or - the action's jsp:body is empty.
1785:                 */
1786:                public boolean hasEmptyBody() {
1787:                    boolean hasEmptyBody = true;
1788:                    Nodes nodes = getBody();
1789:                    if (nodes != null) {
1790:                        int numChildNodes = nodes.size();
1791:                        for (int i = 0; i < numChildNodes; i++) {
1792:                            Node n = nodes.getNode(i);
1793:                            if (!(n instanceof  NamedAttribute)) {
1794:                                if (n instanceof  JspBody) {
1795:                                    hasEmptyBody = (n.getBody() == null);
1796:                                } else {
1797:                                    hasEmptyBody = false;
1798:                                }
1799:                                break;
1800:                            }
1801:                        }
1802:                    }
1803:
1804:                    return hasEmptyBody;
1805:                }
1806:            }
1807:
1808:            /**
1809:             * Used as a placeholder for the evaluation code of a custom action
1810:             * attribute (used by the tag plugin machinery only).
1811:             */
1812:            public static class AttributeGenerator extends Node {
1813:                String name; // name of the attribute
1814:
1815:                CustomTag tag; // The tag this attribute belongs to
1816:
1817:                public AttributeGenerator(Mark start, String name, CustomTag tag) {
1818:                    super (start, null);
1819:                    this .name = name;
1820:                    this .tag = tag;
1821:                }
1822:
1823:                public void accept(Visitor v) throws JasperException {
1824:                    v.visit(this );
1825:                }
1826:
1827:                public String getName() {
1828:                    return name;
1829:                }
1830:
1831:                public CustomTag getTag() {
1832:                    return tag;
1833:                }
1834:            }
1835:
1836:            /**
1837:             * Represents the body of a &lt;jsp:text&gt; element
1838:             */
1839:            public static class JspText extends Node {
1840:
1841:                public JspText(String qName, Attributes nonTaglibXmlnsAttrs,
1842:                        Attributes taglibAttrs, Mark start, Node parent) {
1843:                    super (qName, TEXT_ACTION, null, nonTaglibXmlnsAttrs,
1844:                            taglibAttrs, start, parent);
1845:                }
1846:
1847:                public void accept(Visitor v) throws JasperException {
1848:                    v.visit(this );
1849:                }
1850:            }
1851:
1852:            /**
1853:             * Represents a Named Attribute (&lt;jsp:attribute&gt;)
1854:             */
1855:            public static class NamedAttribute extends Node {
1856:
1857:                // A unique temporary variable name suitable for code generation
1858:                private String temporaryVariableName;
1859:
1860:                // True if this node is to be trimmed, or false otherwise
1861:                private boolean trim = true;
1862:
1863:                private ChildInfo childInfo;
1864:
1865:                private String name;
1866:
1867:                private String localName;
1868:
1869:                private String prefix;
1870:
1871:                public NamedAttribute(Attributes attrs, Mark start, Node parent) {
1872:                    this (JSP_ATTRIBUTE_ACTION, attrs, null, null, start, parent);
1873:                }
1874:
1875:                public NamedAttribute(String qName, Attributes attrs,
1876:                        Attributes nonTaglibXmlnsAttrs, Attributes taglibAttrs,
1877:                        Mark start, Node parent) {
1878:
1879:                    super (qName, ATTRIBUTE_ACTION, attrs, nonTaglibXmlnsAttrs,
1880:                            taglibAttrs, start, parent);
1881:                    if ("false".equals(this .getAttributeValue("trim"))) {
1882:                        // (if null or true, leave default of true)
1883:                        trim = false;
1884:                    }
1885:                    childInfo = new ChildInfo();
1886:                    name = this .getAttributeValue("name");
1887:                    if (name != null) {
1888:                        // Mandatary attribute "name" will be checked in Validator
1889:                        localName = name;
1890:                        int index = name.indexOf(':');
1891:                        if (index != -1) {
1892:                            prefix = name.substring(0, index);
1893:                            localName = name.substring(index + 1);
1894:                        }
1895:                    }
1896:                }
1897:
1898:                public void accept(Visitor v) throws JasperException {
1899:                    v.visit(this );
1900:                }
1901:
1902:                public String getName() {
1903:                    return this .name;
1904:                }
1905:
1906:                public String getLocalName() {
1907:                    return this .localName;
1908:                }
1909:
1910:                public String getPrefix() {
1911:                    return this .prefix;
1912:                }
1913:
1914:                public ChildInfo getChildInfo() {
1915:                    return this .childInfo;
1916:                }
1917:
1918:                public boolean isTrim() {
1919:                    return trim;
1920:                }
1921:
1922:                /**
1923:                 * @return A unique temporary variable name to store the result in.
1924:                 *         (this probably could go elsewhere, but it's convenient here)
1925:                 */
1926:                public String getTemporaryVariableName() {
1927:                    if (temporaryVariableName == null) {
1928:                        temporaryVariableName = JspUtil
1929:                                .nextTemporaryVariableName();
1930:                    }
1931:                    return temporaryVariableName;
1932:                }
1933:
1934:                /*
1935:                 * Get the attribute value from this named attribute (<jsp:attribute>).
1936:                 * Since this method is only for attributes that are not rtexpr, we can
1937:                 * assume the body of the jsp:attribute is a template text.
1938:                 */
1939:                public String getText() {
1940:
1941:                    class AttributeVisitor extends Visitor {
1942:                        String attrValue = null;
1943:
1944:                        public void visit(TemplateText txt) {
1945:                            attrValue = new String(txt.getText());
1946:                        }
1947:
1948:                        public String getAttrValue() {
1949:                            return attrValue;
1950:                        }
1951:                    }
1952:
1953:                    // According to JSP 2.0, if the body of the <jsp:attribute>
1954:                    // action is empty, it is equivalent of specifying "" as the value
1955:                    // of the attribute.
1956:                    String text = "";
1957:                    if (getBody() != null) {
1958:                        AttributeVisitor attributeVisitor = new AttributeVisitor();
1959:                        try {
1960:                            getBody().visit(attributeVisitor);
1961:                        } catch (JasperException e) {
1962:                        }
1963:                        text = attributeVisitor.getAttrValue();
1964:                    }
1965:
1966:                    return text;
1967:                }
1968:            }
1969:
1970:            /**
1971:             * Represents a JspBody node (&lt;jsp:body&gt;)
1972:             */
1973:            public static class JspBody extends Node {
1974:
1975:                private ChildInfo childInfo;
1976:
1977:                public JspBody(Mark start, Node parent) {
1978:                    this (JSP_BODY_ACTION, null, null, start, parent);
1979:                }
1980:
1981:                public JspBody(String qName, Attributes nonTaglibXmlnsAttrs,
1982:                        Attributes taglibAttrs, Mark start, Node parent) {
1983:                    super (qName, BODY_ACTION, null, nonTaglibXmlnsAttrs,
1984:                            taglibAttrs, start, parent);
1985:                    this .childInfo = new ChildInfo();
1986:                }
1987:
1988:                public void accept(Visitor v) throws JasperException {
1989:                    v.visit(this );
1990:                }
1991:
1992:                public ChildInfo getChildInfo() {
1993:                    return childInfo;
1994:                }
1995:            }
1996:
1997:            /**
1998:             * Represents a template text string
1999:             */
2000:            public static class TemplateText extends Node {
2001:
2002:                private ArrayList extraSmap = null;
2003:
2004:                public TemplateText(String text, Mark start, Node parent) {
2005:                    super (null, null, text, start, parent);
2006:                }
2007:
2008:                public void accept(Visitor v) throws JasperException {
2009:                    v.visit(this );
2010:                }
2011:
2012:                /**
2013:                 * Trim all whitespace from the left of the template text
2014:                 */
2015:                public void ltrim() {
2016:                    int index = 0;
2017:                    while ((index < text.length())
2018:                            && (text.charAt(index) <= ' ')) {
2019:                        index++;
2020:                    }
2021:                    text = text.substring(index);
2022:                }
2023:
2024:                public void setText(String text) {
2025:                    this .text = text;
2026:                }
2027:
2028:                /**
2029:                 * Trim all whitespace from the right of the template text
2030:                 */
2031:                public void rtrim() {
2032:                    int index = text.length();
2033:                    while ((index > 0) && (text.charAt(index - 1) <= ' ')) {
2034:                        index--;
2035:                    }
2036:                    text = text.substring(0, index);
2037:                }
2038:
2039:                /**
2040:                 * Returns true if this template text contains whitespace only.
2041:                 */
2042:                public boolean isAllSpace() {
2043:                    boolean isAllSpace = true;
2044:                    for (int i = 0; i < text.length(); i++) {
2045:                        if (!Character.isWhitespace(text.charAt(i))) {
2046:                            isAllSpace = false;
2047:                            break;
2048:                        }
2049:                    }
2050:                    return isAllSpace;
2051:                }
2052:
2053:                /**
2054:                 * Add a source to Java line mapping
2055:                 * 
2056:                 * @param srcLine
2057:                 *            The postion of the source line, relative to the line at
2058:                 *            the start of this node. The corresponding java line is
2059:                 *            assumed to be consecutive, i.e. one more than the last.
2060:                 */
2061:                public void addSmap(int srcLine) {
2062:                    if (extraSmap == null) {
2063:                        extraSmap = new ArrayList();
2064:                    }
2065:                    extraSmap.add(new Integer(srcLine));
2066:                }
2067:
2068:                public ArrayList getExtraSmap() {
2069:                    return extraSmap;
2070:                }
2071:            }
2072:
2073:            /***************************************************************************
2074:             * Auxillary classes used in Node
2075:             */
2076:
2077:            /**
2078:             * Represents attributes that can be request time expressions.
2079:             * 
2080:             * Can either be a plain attribute, an attribute that represents a request
2081:             * time expression value, or a named attribute (specified using the
2082:             * jsp:attribute standard action).
2083:             */
2084:
2085:            public static class JspAttribute {
2086:
2087:                private String qName;
2088:
2089:                private String uri;
2090:
2091:                private String localName;
2092:
2093:                private String value;
2094:
2095:                private boolean expression;
2096:
2097:                private boolean dynamic;
2098:
2099:                private final ELNode.Nodes el;
2100:
2101:                private final TagAttributeInfo tai;
2102:
2103:                // If true, this JspAttribute represents a <jsp:attribute>
2104:                private boolean namedAttribute;
2105:
2106:                // The node in the parse tree for the NamedAttribute
2107:                private NamedAttribute namedAttributeNode;
2108:
2109:                JspAttribute(TagAttributeInfo tai, String qName, String uri,
2110:                        String localName, String value, boolean expr,
2111:                        ELNode.Nodes el, boolean dyn) {
2112:                    this .qName = qName;
2113:                    this .uri = uri;
2114:                    this .localName = localName;
2115:                    this .value = value;
2116:                    this .namedAttributeNode = null;
2117:                    this .expression = expr;
2118:                    this .el = el;
2119:                    this .dynamic = dyn;
2120:                    this .namedAttribute = false;
2121:                    this .tai = tai;
2122:                }
2123:
2124:                /**
2125:                 * Allow node to validate itself
2126:                 * 
2127:                 * @param ef
2128:                 * @param ctx
2129:                 * @throws ELException
2130:                 */
2131:                public void validateEL(ExpressionFactory ef, ELContext ctx)
2132:                        throws ELException {
2133:                    if (this .el != null) {
2134:                        // determine exact type
2135:                        ValueExpression ve = ef.createValueExpression(ctx,
2136:                                this .value, String.class);
2137:                    }
2138:                }
2139:
2140:                /**
2141:                 * Use this constructor if the JspAttribute represents a named
2142:                 * attribute. In this case, we have to store the nodes of the body of
2143:                 * the attribute.
2144:                 */
2145:                JspAttribute(NamedAttribute na, TagAttributeInfo tai,
2146:                        boolean dyn) {
2147:                    this .qName = na.getName();
2148:                    this .localName = na.getLocalName();
2149:                    this .value = null;
2150:                    this .namedAttributeNode = na;
2151:                    this .expression = false;
2152:                    this .el = null;
2153:                    this .dynamic = dyn;
2154:                    this .namedAttribute = true;
2155:                    this .tai = null;
2156:                }
2157:
2158:                /**
2159:                 * @return The name of the attribute
2160:                 */
2161:                public String getName() {
2162:                    return qName;
2163:                }
2164:
2165:                /**
2166:                 * @return The local name of the attribute
2167:                 */
2168:                public String getLocalName() {
2169:                    return localName;
2170:                }
2171:
2172:                /**
2173:                 * @return The namespace of the attribute, or null if in the default
2174:                 *         namespace
2175:                 */
2176:                public String getURI() {
2177:                    return uri;
2178:                }
2179:
2180:                public TagAttributeInfo getTagAttributeInfo() {
2181:                    return this .tai;
2182:                }
2183:
2184:                /**
2185:                 * 
2186:                 * @return return true if there's TagAttributeInfo meaning we need to
2187:                 *         assign a ValueExpression
2188:                 */
2189:                public boolean isDeferredInput() {
2190:                    return (this .tai != null) ? this .tai.isDeferredValue()
2191:                            : false;
2192:                }
2193:
2194:                /**
2195:                 * 
2196:                 * @return return true if there's TagAttributeInfo meaning we need to
2197:                 *         assign a MethodExpression
2198:                 */
2199:                public boolean isDeferredMethodInput() {
2200:                    return (this .tai != null) ? this .tai.isDeferredMethod()
2201:                            : false;
2202:                }
2203:
2204:                public String getExpectedTypeName() {
2205:                    if (this .tai != null) {
2206:                        if (this .isDeferredInput()) {
2207:                            return this .tai.getExpectedTypeName();
2208:                        } else if (this .isDeferredMethodInput()) {
2209:                            String m = this .tai.getMethodSignature();
2210:                            if (m != null) {
2211:                                int rti = m.trim().indexOf(' ');
2212:                                if (rti > 0) {
2213:                                    return m.substring(0, rti).trim();
2214:                                }
2215:                            }
2216:                        }
2217:                    }
2218:                    return "java.lang.Object";
2219:                }
2220:
2221:                public String[] getParameterTypeNames() {
2222:                    if (this .tai != null) {
2223:                        if (this .isDeferredMethodInput()) {
2224:                            String m = this .tai.getMethodSignature();
2225:                            if (m != null) {
2226:                                m = m.trim();
2227:                                m = m.substring(m.indexOf('(') + 1);
2228:                                m = m.substring(0, m.length() - 1);
2229:                                if (m.trim().length() > 0) {
2230:                                    String[] p = m.split(",");
2231:                                    for (int i = 0; i < p.length; i++) {
2232:                                        p[i] = p[i].trim();
2233:                                    }
2234:                                    return p;
2235:                                }
2236:                            }
2237:                        }
2238:                    }
2239:                    return new String[0];
2240:                }
2241:
2242:                /**
2243:                 * Only makes sense if namedAttribute is false.
2244:                 * 
2245:                 * @return the value for the attribute, or the expression string
2246:                 *         (stripped of "<%=", "%>", "%=", or "%" but containing "${"
2247:                 *         and "}" for EL expressions)
2248:                 */
2249:                public String getValue() {
2250:                    return value;
2251:                }
2252:
2253:                /**
2254:                 * Only makes sense if namedAttribute is true.
2255:                 * 
2256:                 * @return the nodes that evaluate to the body of this attribute.
2257:                 */
2258:                public NamedAttribute getNamedAttributeNode() {
2259:                    return namedAttributeNode;
2260:                }
2261:
2262:                /**
2263:                 * @return true if the value represents a traditional rtexprvalue
2264:                 */
2265:                public boolean isExpression() {
2266:                    return expression;
2267:                }
2268:
2269:                /**
2270:                 * @return true if the value represents a NamedAttribute value.
2271:                 */
2272:                public boolean isNamedAttribute() {
2273:                    return namedAttribute;
2274:                }
2275:
2276:                /**
2277:                 * @return true if the value represents an expression that should be fed
2278:                 *         to the expression interpreter
2279:                 * @return false for string literals or rtexprvalues that should not be
2280:                 *         interpreted or reevaluated
2281:                 */
2282:                public boolean isELInterpreterInput() {
2283:                    return el != null || this .isDeferredInput()
2284:                            || this .isDeferredMethodInput();
2285:                }
2286:
2287:                /**
2288:                 * @return true if the value is a string literal known at translation
2289:                 *         time.
2290:                 */
2291:                public boolean isLiteral() {
2292:                    return !expression && (el != null) && !namedAttribute;
2293:                }
2294:
2295:                /**
2296:                 * XXX
2297:                 */
2298:                public boolean isDynamic() {
2299:                    return dynamic;
2300:                }
2301:
2302:                public ELNode.Nodes getEL() {
2303:                    return el;
2304:                }
2305:            }
2306:
2307:            /**
2308:             * An ordered list of Node, used to represent the body of an element, or a
2309:             * jsp page of jsp document.
2310:             */
2311:            public static class Nodes {
2312:
2313:                private List list;
2314:
2315:                private Node.Root root; // null if this is not a page
2316:
2317:                private boolean generatedInBuffer;
2318:
2319:                public Nodes() {
2320:                    list = new Vector();
2321:                }
2322:
2323:                public Nodes(Node.Root root) {
2324:                    this .root = root;
2325:                    list = new Vector();
2326:                    list.add(root);
2327:                }
2328:
2329:                /**
2330:                 * Appends a node to the list
2331:                 * 
2332:                 * @param n
2333:                 *            The node to add
2334:                 */
2335:                public void add(Node n) {
2336:                    list.add(n);
2337:                    root = null;
2338:                }
2339:
2340:                /**
2341:                 * Removes the given node from the list.
2342:                 * 
2343:                 * @param n
2344:                 *            The node to be removed
2345:                 */
2346:                public void remove(Node n) {
2347:                    list.remove(n);
2348:                }
2349:
2350:                /**
2351:                 * Visit the nodes in the list with the supplied visitor
2352:                 * 
2353:                 * @param v
2354:                 *            The visitor used
2355:                 */
2356:                public void visit(Visitor v) throws JasperException {
2357:                    Iterator iter = list.iterator();
2358:                    while (iter.hasNext()) {
2359:                        Node n = (Node) iter.next();
2360:                        n.accept(v);
2361:                    }
2362:                }
2363:
2364:                public int size() {
2365:                    return list.size();
2366:                }
2367:
2368:                public Node getNode(int index) {
2369:                    Node n = null;
2370:                    try {
2371:                        n = (Node) list.get(index);
2372:                    } catch (ArrayIndexOutOfBoundsException e) {
2373:                    }
2374:                    return n;
2375:                }
2376:
2377:                public Node.Root getRoot() {
2378:                    return root;
2379:                }
2380:
2381:                public boolean isGeneratedInBuffer() {
2382:                    return generatedInBuffer;
2383:                }
2384:
2385:                public void setGeneratedInBuffer(boolean g) {
2386:                    generatedInBuffer = g;
2387:                }
2388:            }
2389:
2390:            /**
2391:             * A visitor class for visiting the node. This class also provides the
2392:             * default action (i.e. nop) for each of the child class of the Node. An
2393:             * actual visitor should extend this class and supply the visit method for
2394:             * the nodes that it cares.
2395:             */
2396:            public static class Visitor {
2397:
2398:                /**
2399:                 * This method provides a place to put actions that are common to all
2400:                 * nodes. Override this in the child visitor class if need to.
2401:                 */
2402:                protected void doVisit(Node n) throws JasperException {
2403:                }
2404:
2405:                /**
2406:                 * Visit the body of a node, using the current visitor
2407:                 */
2408:                protected void visitBody(Node n) throws JasperException {
2409:                    if (n.getBody() != null) {
2410:                        n.getBody().visit(this );
2411:                    }
2412:                }
2413:
2414:                public void visit(Root n) throws JasperException {
2415:                    doVisit(n);
2416:                    visitBody(n);
2417:                }
2418:
2419:                public void visit(JspRoot n) throws JasperException {
2420:                    doVisit(n);
2421:                    visitBody(n);
2422:                }
2423:
2424:                public void visit(PageDirective n) throws JasperException {
2425:                    doVisit(n);
2426:                }
2427:
2428:                public void visit(TagDirective n) throws JasperException {
2429:                    doVisit(n);
2430:                }
2431:
2432:                public void visit(IncludeDirective n) throws JasperException {
2433:                    doVisit(n);
2434:                    visitBody(n);
2435:                }
2436:
2437:                public void visit(TaglibDirective n) throws JasperException {
2438:                    doVisit(n);
2439:                }
2440:
2441:                public void visit(AttributeDirective n) throws JasperException {
2442:                    doVisit(n);
2443:                }
2444:
2445:                public void visit(VariableDirective n) throws JasperException {
2446:                    doVisit(n);
2447:                }
2448:
2449:                public void visit(Comment n) throws JasperException {
2450:                    doVisit(n);
2451:                }
2452:
2453:                public void visit(Declaration n) throws JasperException {
2454:                    doVisit(n);
2455:                }
2456:
2457:                public void visit(Expression n) throws JasperException {
2458:                    doVisit(n);
2459:                }
2460:
2461:                public void visit(Scriptlet n) throws JasperException {
2462:                    doVisit(n);
2463:                }
2464:
2465:                public void visit(ELExpression n) throws JasperException {
2466:                    doVisit(n);
2467:                }
2468:
2469:                public void visit(IncludeAction n) throws JasperException {
2470:                    doVisit(n);
2471:                    visitBody(n);
2472:                }
2473:
2474:                public void visit(ForwardAction n) throws JasperException {
2475:                    doVisit(n);
2476:                    visitBody(n);
2477:                }
2478:
2479:                public void visit(GetProperty n) throws JasperException {
2480:                    doVisit(n);
2481:                    visitBody(n);
2482:                }
2483:
2484:                public void visit(SetProperty n) throws JasperException {
2485:                    doVisit(n);
2486:                    visitBody(n);
2487:                }
2488:
2489:                public void visit(ParamAction n) throws JasperException {
2490:                    doVisit(n);
2491:                    visitBody(n);
2492:                }
2493:
2494:                public void visit(ParamsAction n) throws JasperException {
2495:                    doVisit(n);
2496:                    visitBody(n);
2497:                }
2498:
2499:                public void visit(FallBackAction n) throws JasperException {
2500:                    doVisit(n);
2501:                    visitBody(n);
2502:                }
2503:
2504:                public void visit(UseBean n) throws JasperException {
2505:                    doVisit(n);
2506:                    visitBody(n);
2507:                }
2508:
2509:                public void visit(PlugIn n) throws JasperException {
2510:                    doVisit(n);
2511:                    visitBody(n);
2512:                }
2513:
2514:                public void visit(CustomTag n) throws JasperException {
2515:                    doVisit(n);
2516:                    visitBody(n);
2517:                }
2518:
2519:                public void visit(UninterpretedTag n) throws JasperException {
2520:                    doVisit(n);
2521:                    visitBody(n);
2522:                }
2523:
2524:                public void visit(JspElement n) throws JasperException {
2525:                    doVisit(n);
2526:                    visitBody(n);
2527:                }
2528:
2529:                public void visit(JspText n) throws JasperException {
2530:                    doVisit(n);
2531:                    visitBody(n);
2532:                }
2533:
2534:                public void visit(NamedAttribute n) throws JasperException {
2535:                    doVisit(n);
2536:                    visitBody(n);
2537:                }
2538:
2539:                public void visit(JspBody n) throws JasperException {
2540:                    doVisit(n);
2541:                    visitBody(n);
2542:                }
2543:
2544:                public void visit(InvokeAction n) throws JasperException {
2545:                    doVisit(n);
2546:                    visitBody(n);
2547:                }
2548:
2549:                public void visit(DoBodyAction n) throws JasperException {
2550:                    doVisit(n);
2551:                    visitBody(n);
2552:                }
2553:
2554:                public void visit(TemplateText n) throws JasperException {
2555:                    doVisit(n);
2556:                }
2557:
2558:                public void visit(JspOutput n) throws JasperException {
2559:                    doVisit(n);
2560:                }
2561:
2562:                public void visit(AttributeGenerator n) throws JasperException {
2563:                    doVisit(n);
2564:                }
2565:            }
2566:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.