1 19 20 package org.netbeans.modules.web.jsps.parserapi; 21 22 import java.util.*; 23 import java.io.CharArrayWriter ; 24 import javax.servlet.jsp.tagext.*; 25 import javax.servlet.jsp.JspException ; 26 import org.xml.sax.Attributes ; 27 29 30 41 42 public abstract class Node { 43 44 public static final String JSP_URI = "http://java.sun.com/JSP/Page"; 46 47 public static final String DIRECTIVE_ACTION = "directive."; 48 49 public static final String ROOT_ACTION = "root"; 50 public static final String JSP_ROOT_ACTION = "jsp:root"; 51 52 public static final String PAGE_DIRECTIVE_ACTION = "directive.page"; 53 public static final String JSP_PAGE_DIRECTIVE_ACTION = "jsp:directive.page"; 54 55 public static final String INCLUDE_DIRECTIVE_ACTION = "directive.include"; 56 public static final String JSP_INCLUDE_DIRECTIVE_ACTION = "jsp:directive.include"; 57 58 public static final String DECLARATION_ACTION = "declaration"; 59 public static final String JSP_DECLARATION_ACTION = "jsp:declaration"; 60 61 public static final String SCRIPTLET_ACTION = "scriptlet"; 62 public static final String JSP_SCRIPTLET_ACTION = "jsp:scriptlet"; 63 64 public static final String EXPRESSION_ACTION = "expression"; 65 public static final String JSP_EXPRESSION_ACTION = "jsp:expression"; 66 67 public static final String USE_BEAN_ACTION = "useBean"; 68 public static final String JSP_USE_BEAN_ACTION = "jsp:useBean"; 69 70 public static final String SET_PROPERTY_ACTION = "setProperty"; 71 public static final String JSP_SET_PROPERTY_ACTION = "jsp:setProperty"; 72 73 public static final String GET_PROPERTY_ACTION = "getProperty"; 74 public static final String JSP_GET_PROPERTY_ACTION = "jsp:getProperty"; 75 76 public static final String INCLUDE_ACTION = "include"; 77 public static final String JSP_INCLUDE_ACTION = "jsp:include"; 78 79 public static final String FORWARD_ACTION = "forward"; 80 public static final String JSP_FORWARD_ACTION = "jsp:forward"; 81 82 public static final String PARAM_ACTION = "param"; 83 public static final String JSP_PARAM_ACTION = "jsp:param"; 84 85 public static final String PARAMS_ACTION = "params"; 86 public static final String JSP_PARAMS_ACTION = "jsp:params"; 87 88 public static final String PLUGIN_ACTION = "plugin"; 89 public static final String JSP_PLUGIN_ACTION = "jsp:plugin"; 90 91 public static final String FALLBACK_ACTION = "fallback"; 92 public static final String JSP_FALLBACK_ACTION = "jsp:fallback"; 93 94 public static final String TEXT_ACTION = "text"; 95 public static final String JSP_TEXT_ACTION = "jsp:text"; 96 public static final String JSP_TEXT_ACTION_END = "</jsp:text>"; 97 98 public static final String ATTRIBUTE_ACTION = "attribute"; 99 public static final String JSP_ATTRIBUTE_ACTION = "jsp:attribute"; 100 101 public static final String BODY_ACTION = "body"; 102 public static final String JSP_BODY_ACTION = "jsp:body"; 103 104 public static final String ELEMENT_ACTION = "element"; 105 public static final String JSP_ELEMENT_ACTION = "jsp:element"; 106 107 public static final String OUTPUT_ACTION = "output"; 108 public static final String JSP_OUTPUT_ACTION = "jsp:output"; 109 110 public static final String TAGLIB_DIRECTIVE_ACTION = "taglib"; 111 public static final String JSP_TAGLIB_DIRECTIVE_ACTION = "jsp:taglib"; 112 113 116 public static final String INVOKE_ACTION = "invoke"; 117 public static final String JSP_INVOKE_ACTION = "jsp:invoke"; 118 119 public static final String DOBODY_ACTION = "doBody"; 120 public static final String JSP_DOBODY_ACTION = "jsp:doBody"; 121 122 125 public static final String TAG_DIRECTIVE_ACTION = "directive.tag"; 126 public static final String JSP_TAG_DIRECTIVE_ACTION = "jsp:directive.tag"; 127 128 public static final String ATTRIBUTE_DIRECTIVE_ACTION = "directive.attribute"; 129 public static final String JSP_ATTRIBUTE_DIRECTIVE_ACTION = "jsp:directive.attribute"; 130 131 public static final String VARIABLE_DIRECTIVE_ACTION = "directive.variable"; 132 public static final String JSP_VARIABLE_DIRECTIVE_ACTION = "jsp:directive.variable"; 133 134 137 public static final String URN_JSPTAGDIR = "urn:jsptagdir:"; 138 public static final String URN_JSPTLD = "urn:jsptld:"; 139 141 142 private static final VariableInfo[] ZERO_VARIABLE_INFO = { }; 143 144 protected Attributes attrs; 145 146 protected Attributes taglibAttrs; 148 149 153 protected Attributes nonTaglibXmlnsAttrs; 154 155 protected Nodes body; 156 protected String text; 157 protected Mark startMark; 158 protected int beginJavaLine; 159 protected int endJavaLine; 160 protected Node parent; 161 protected Nodes namedAttributeNodes; protected String qName; 163 protected String localName; 164 165 private boolean isDummy; 166 167 170 public Node() { 171 this.isDummy = true; 172 } 173 174 180 public Node(Mark start, Node parent) { 181 this.startMark = start; 182 this.isDummy = (start == null); 183 addToParent(parent); 184 } 185 186 194 public Node(String qName, String localName, Mark start, Node parent) { 195 this.qName = qName; 196 this.localName = localName; 197 this.startMark = start; 198 this.isDummy = (start == null); 199 addToParent(parent); 200 } 201 202 211 public Node(String qName, String localName, Attributes attrs, Mark start, Node parent) { 212 this.qName = qName; 213 this.localName = localName; 214 this.attrs = attrs; 215 this.startMark = start; 216 this.isDummy = (start == null); 217 addToParent(parent); 218 } 219 220 234 public Node(String qName, String localName, Attributes attrs, Attributes nonTaglibXmlnsAttrs, Attributes taglibAttrs, Mark start, Node parent) { 235 this.qName = qName; 236 this.localName = localName; 237 this.attrs = attrs; 238 this.nonTaglibXmlnsAttrs = nonTaglibXmlnsAttrs; 239 this.taglibAttrs = taglibAttrs; 240 this.startMark = start; 241 this.isDummy = (start == null); 242 addToParent(parent); 243 } 244 245 254 public Node(String qName, String localName, String text, Mark start, Node parent) { 255 this.qName = qName; 256 this.localName = localName; 257 this.text = text; 258 this.startMark = start; 259 this.isDummy = (start == null); 260 addToParent(parent); 261 } 262 263 public String getQName() { 264 return this.qName; 265 } 266 267 public String getLocalName() { 268 return this.localName; 269 } 270 271 280 public Attributes getAttributes() { 281 return this.attrs; 282 } 283 284 288 public Attributes getTaglibAttributes() { 289 return this.taglibAttrs; 290 } 291 292 296 public Attributes getNonTaglibXmlnsAttributes() { 297 return this.nonTaglibXmlnsAttrs; 298 } 299 300 public void setAttributes(Attributes attrs) { 301 this.attrs = attrs; 302 } 303 304 public String getAttributeValue(String name) { 305 return (attrs == null) ? null : attrs.getValue(name); 306 } 307 308 312 public String getTextAttribute(String name) { 313 314 String attr = getAttributeValue(name); 315 if (attr != null) { 316 return attr; 317 } 318 319 NamedAttribute namedAttribute = getNamedAttributeNode(name); 320 if (namedAttribute == null) { 321 return null; 322 } 323 324 return namedAttribute.getText(); 325 } 326 327 335 public NamedAttribute getNamedAttributeNode( String name ) { 336 NamedAttribute result = null; 337 338 Nodes nodes = getNamedAttributeNodes(); 340 int numChildNodes = nodes.size(); 341 for( int i = 0; i < numChildNodes; i++ ) { 342 NamedAttribute na = (NamedAttribute)nodes.getNode( i ); 343 boolean found = false; 344 int index = name.indexOf(':'); 345 if (index != -1) { 346 found = na.getName().equals(name); 348 } else { 349 found = na.getLocalName().equals(name); 350 } 351 if (found) { 352 result = na; 353 break; 354 } 355 } 356 357 return result; 358 } 359 360 367 public Node.Nodes getNamedAttributeNodes() { 368 369 if (namedAttributeNodes != null) { 370 return namedAttributeNodes; 371 } 372 373 Node.Nodes result = new Node.Nodes(); 374 375 Nodes nodes = getBody(); 377 if( nodes != null ) { 378 int numChildNodes = nodes.size(); 379 for( int i = 0; i < numChildNodes; i++ ) { 380 Node n = nodes.getNode( i ); 381 if( n instanceof NamedAttribute ) { 382 result.add( n ); 383 } 384 else { 385 break; 388 } 389 } 390 } 391 392 namedAttributeNodes = result; 393 return result; 394 } 395 396 public Nodes getBody() { 397 return body; 398 } 399 400 public void setBody(Nodes body) { 401 this.body = body; 402 } 403 404 public String getText() { 405 return text; 406 } 407 408 public Mark getStart() { 409 return startMark; 410 } 411 412 public Node getParent() { 413 return parent; 414 } 415 416 public int getBeginJavaLine() { 417 return beginJavaLine; 418 } 419 420 public void setBeginJavaLine(int begin) { 421 beginJavaLine = begin; 422 } 423 424 public int getEndJavaLine() { 425 return endJavaLine; 426 } 427 428 public void setEndJavaLine(int end) { 429 endJavaLine = end; 430 } 431 432 public boolean isDummy() { 433 return isDummy; 434 } 435 436 public Node.Root getRoot() { 437 Node n = this; 438 while (!(n instanceof Node.Root)) { 439 n = n.getParent(); 440 } 441 return (Node.Root) n; 442 } 443 444 449 abstract void accept(Visitor v) throws JspException ; 450 451 452 455 458 private void addToParent(Node parent) { 459 if (parent != null) { 460 this.parent = parent; 461 Nodes parentBody = parent.getBody(); 462 if (parentBody == null) { 463 parentBody = new Nodes(); 464 parent.setBody(parentBody); 465 } 466 parentBody.add(this); 467 } 468 } 469 470 471 474 475 478 public static class Root extends Node { 479 480 private Root parentRoot; 481 private boolean isXmlSyntax; 482 483 private String pageEnc; 485 486 private String jspConfigPageEnc; 488 489 499 private boolean isDefaultPageEncoding; 500 501 507 private boolean isEncodingSpecifiedInProlog; 508 509 512 Root(Mark start, Node parent, boolean isXmlSyntax) { 513 super(start, parent); 514 this.isXmlSyntax = isXmlSyntax; 515 this.qName = JSP_ROOT_ACTION; 516 this.localName = ROOT_ACTION; 517 518 Node r = parent; 520 while ((r != null) && !(r instanceof Node.Root)) 521 r = r.getParent(); 522 parentRoot = (Node.Root) r; 523 } 524 525 public void accept(Visitor v) throws JspException { 526 v.visit(this); 527 } 528 529 public boolean isXmlSyntax() { 530 return isXmlSyntax; 531 } 532 533 537 public void setJspConfigPageEncoding(String enc) { 538 jspConfigPageEnc = enc; 539 } 540 541 545 public String getJspConfigPageEncoding() { 546 return jspConfigPageEnc; 547 } 548 549 public void setPageEncoding(String enc) { 550 pageEnc = enc; 551 } 552 553 public String getPageEncoding() { 554 return pageEnc; 555 } 556 557 public void setIsDefaultPageEncoding(boolean isDefault) { 558 isDefaultPageEncoding = isDefault; 559 } 560 561 public boolean isDefaultPageEncoding() { 562 return isDefaultPageEncoding; 563 } 564 565 public void setIsEncodingSpecifiedInProlog(boolean isSpecified) { 566 isEncodingSpecifiedInProlog = isSpecified; 567 } 568 569 public boolean isEncodingSpecifiedInProlog() { 570 return isEncodingSpecifiedInProlog; 571 } 572 573 577 public Root getParentRoot() { 578 return parentRoot; 579 } 580 } 581 582 585 public static class JspRoot extends Node { 586 587 public JspRoot(String qName, Attributes attrs, 588 Attributes nonTaglibXmlnsAttrs, Attributes taglibAttrs, 589 Mark start, Node parent) { 590 super(qName, ROOT_ACTION, attrs, nonTaglibXmlnsAttrs, taglibAttrs, 591 start, parent); 592 } 593 594 public void accept(Visitor v) throws JspException { 595 v.visit(this); 596 } 597 } 598 599 602 public static class PageDirective extends Node { 603 604 private Vector<String > imports; 605 606 public PageDirective(Attributes attrs, Mark start, Node parent) { 607 this(JSP_PAGE_DIRECTIVE_ACTION, attrs, null, null, start, parent); 608 } 609 610 public PageDirective(String qName, Attributes attrs, 611 Attributes nonTaglibXmlnsAttrs, 612 Attributes taglibAttrs, Mark start, Node parent) { 613 super(qName, PAGE_DIRECTIVE_ACTION, attrs, nonTaglibXmlnsAttrs, 614 taglibAttrs, start, parent); 615 imports = new Vector<String >(); 616 } 617 618 public void accept(Visitor v) throws JspException { 619 v.visit(this); 620 } 621 622 628 public void addImport(String value) { 629 int start = 0; 630 int index; 631 while ((index = value.indexOf(',', start)) != -1) { 632 imports.add(value.substring(start, index).trim()); 633 start = index + 1; 634 } 635 if (start == 0) { 636 imports.add(value.trim()); 638 } else { 639 imports.add(value.substring(start).trim()); 640 } 641 } 642 643 public List<String > getImports() { 644 return imports; 645 } 646 } 647 648 651 public static class IncludeDirective extends Node { 652 653 public IncludeDirective(Attributes attrs, Mark start, Node parent) { 654 this(JSP_INCLUDE_DIRECTIVE_ACTION, attrs, null, null, start, 655 parent); 656 } 657 658 public IncludeDirective(String qName, Attributes attrs, 659 Attributes nonTaglibXmlnsAttrs, 660 Attributes taglibAttrs, Mark start, 661 Node parent) { 662 super(qName, INCLUDE_DIRECTIVE_ACTION, attrs, nonTaglibXmlnsAttrs, 663 taglibAttrs, start, parent); 664 } 665 666 public void accept(Visitor v) throws JspException { 667 v.visit(this); 668 } 669 } 670 671 674 public static class TaglibDirective extends Node { 675 676 public TaglibDirective(Attributes attrs, Mark start, Node parent) { 677 super(JSP_TAGLIB_DIRECTIVE_ACTION, TAGLIB_DIRECTIVE_ACTION, attrs, 678 start, parent); 679 } 680 681 public void accept(Visitor v) throws JspException { 682 v.visit(this); 683 } 684 } 685 686 689 public static class TagDirective extends Node { 690 private Vector<String > imports; 691 692 public TagDirective(Attributes attrs, Mark start, Node parent) { 693 this(JSP_TAG_DIRECTIVE_ACTION, attrs, null, null, start, parent); 694 } 695 696 public TagDirective(String qName, Attributes attrs, 697 Attributes nonTaglibXmlnsAttrs, 698 Attributes taglibAttrs, Mark start, Node parent) { 699 super(qName, TAG_DIRECTIVE_ACTION, attrs, nonTaglibXmlnsAttrs, 700 taglibAttrs, start, parent); 701 imports = new Vector<String >(); 702 } 703 704 public void accept(Visitor v) throws JspException { 705 v.visit(this); 706 } 707 708 714 public void addImport(String value) { 715 int start = 0; 716 int index; 717 while ((index = value.indexOf(',', start)) != -1) { 718 imports.add(value.substring(start, index).trim()); 719 start = index + 1; 720 } 721 if (start == 0) { 722 imports.add(value.trim()); 724 } else { 725 imports.add(value.substring(start).trim()); 726 } 727 } 728 729 public List<String > getImports() { 730 return imports; 731 } 732 } 733 734 737 public static class AttributeDirective extends Node { 738 739 public AttributeDirective(Attributes attrs, Mark start, Node parent) { 740 this(JSP_ATTRIBUTE_DIRECTIVE_ACTION, attrs, null, null, start, 741 parent); 742 } 743 744 public AttributeDirective(String qName, Attributes attrs, 745 Attributes nonTaglibXmlnsAttrs, 746 Attributes taglibAttrs, Mark start, 747 Node parent) { 748 super(qName, ATTRIBUTE_DIRECTIVE_ACTION, attrs, 749 nonTaglibXmlnsAttrs, taglibAttrs, start, parent); 750 } 751 752 public void accept(Visitor v) throws JspException { 753 v.visit(this); 754 } 755 } 756 757 760 public static class VariableDirective extends Node { 761 762 public VariableDirective(Attributes attrs, Mark start, Node parent) { 763 this(JSP_VARIABLE_DIRECTIVE_ACTION, attrs, null, null, start, 764 parent); 765 } 766 767 public VariableDirective(String qName, Attributes attrs, 768 Attributes nonTaglibXmlnsAttrs, 769 Attributes taglibAttrs, 770 Mark start, Node parent) { 771 super(qName, VARIABLE_DIRECTIVE_ACTION, attrs, nonTaglibXmlnsAttrs, 772 taglibAttrs, start, parent); 773 } 774 775 public void accept(Visitor v) throws JspException { 776 v.visit(this); 777 } 778 } 779 780 783 public static class InvokeAction extends Node { 784 785 public InvokeAction(Attributes attrs, Mark start, Node parent) { 786 this(JSP_INVOKE_ACTION, attrs, null, null, start, parent); 787 } 788 789 public InvokeAction(String qName, Attributes attrs, 790 Attributes nonTaglibXmlnsAttrs, 791 Attributes taglibAttrs, Mark start, Node parent) { 792 super(qName, INVOKE_ACTION, attrs, nonTaglibXmlnsAttrs, 793 taglibAttrs, start, parent); 794 } 795 796 public void accept(Visitor v) throws JspException { 797 v.visit(this); 798 } 799 } 800 801 804 public static class DoBodyAction extends Node { 805 806 public DoBodyAction(Attributes attrs, Mark start, Node parent) { 807 this(JSP_DOBODY_ACTION, attrs, null, null, start, parent); 808 } 809 810 public DoBodyAction(String qName, Attributes attrs, 811 Attributes nonTaglibXmlnsAttrs, 812 Attributes taglibAttrs, Mark start, Node parent) { 813 super(qName, DOBODY_ACTION, attrs, nonTaglibXmlnsAttrs, 814 taglibAttrs, start, parent); 815 } 816 817 public void accept(Visitor v) throws JspException { 818 v.visit(this); 819 } 820 } 821 822 826 public static class Comment extends Node { 827 828 public Comment(String text, Mark start, Node parent) { 829 super(null, null, text, start, parent); 830 } 831 832 public void accept(Visitor v) throws JspException { 833 v.visit(this); 834 } 835 } 836 837 840 public static abstract class ScriptingElement extends Node { 841 842 public ScriptingElement(String qName, String localName, String text, 843 Mark start, Node parent) { 844 super(qName, localName, text, start, parent); 845 } 846 847 public ScriptingElement(String qName, String localName, 848 Attributes nonTaglibXmlnsAttrs, 849 Attributes taglibAttrs, Mark start, 850 Node parent) { 851 super(qName, localName, null, nonTaglibXmlnsAttrs, taglibAttrs, 852 start, parent); 853 } 854 855 862 public String getText() { 863 String ret = text; 864 if ((ret == null) && (body != null)) { 865 StringBuffer buf = new StringBuffer (); 866 for (int i=0; i<body.size(); i++) { 867 buf.append(body.getNode(i).getText()); 868 } 869 ret = buf.toString(); 870 } 871 return ret; 872 } 873 } 874 875 878 public static class Declaration extends ScriptingElement { 879 880 public Declaration(String text, Mark start, Node parent) { 881 super(JSP_DECLARATION_ACTION, DECLARATION_ACTION, text, start, 882 parent); 883 } 884 885 public Declaration(String qName, Attributes nonTaglibXmlnsAttrs, 886 Attributes taglibAttrs, Mark start, 887 Node parent) { 888 super(qName, DECLARATION_ACTION, nonTaglibXmlnsAttrs, 889 taglibAttrs, start, parent); 890 } 891 892 public void accept(Visitor v) throws JspException { 893 v.visit(this); 894 } 895 } 896 897 901 public static class Expression extends ScriptingElement { 902 903 public Expression(String text, Mark start, Node parent) { 904 super(JSP_EXPRESSION_ACTION, EXPRESSION_ACTION, text, start, 905 parent); 906 } 907 908 public Expression(String qName, Attributes nonTaglibXmlnsAttrs, 909 Attributes taglibAttrs, Mark start, 910 Node parent) { 911 super(qName, EXPRESSION_ACTION, nonTaglibXmlnsAttrs, taglibAttrs, 912 start, parent); 913 } 914 915 public void accept(Visitor v) throws JspException { 916 v.visit(this); 917 } 918 } 919 920 923 public static class Scriptlet extends ScriptingElement { 924 925 public Scriptlet(String text, Mark start, Node parent) { 926 super(JSP_SCRIPTLET_ACTION, SCRIPTLET_ACTION, text, start, parent); 927 } 928 929 public Scriptlet(String qName, Attributes nonTaglibXmlnsAttrs, 930 Attributes taglibAttrs, Mark start, 931 Node parent) { 932 super(qName, SCRIPTLET_ACTION, nonTaglibXmlnsAttrs, taglibAttrs, 933 start, parent); 934 } 935 936 public void accept(Visitor v) throws JspException { 937 v.visit(this); 938 } 939 } 940 941 945 public static class ELExpression extends Node { 946 947 private ELNode.Nodes el; 948 949 public ELExpression(String text, Mark start, Node parent) { 950 super(null, null, text, start, parent); 951 } 952 953 public void accept(Visitor v) throws JspException { 954 v.visit(this); 955 } 956 957 public void setEL(ELNode.Nodes el) { 958 this.el = el; 959 } 960 961 public ELNode.Nodes getEL() { 962 return el; 963 } 964 } 965 966 969 public static class ParamAction extends Node { 970 971 JspAttribute value; 972 973 public ParamAction(Attributes attrs, Mark start, Node parent) { 974 this(JSP_PARAM_ACTION, attrs, null, null, start, parent); 975 } 976 977 public ParamAction(String qName, Attributes attrs, 978 Attributes nonTaglibXmlnsAttrs, 979 Attributes taglibAttrs, Mark start, Node parent) { 980 super(qName, PARAM_ACTION, attrs, nonTaglibXmlnsAttrs, 981 taglibAttrs, start, parent); 982 } 983 984 public void accept(Visitor v) throws JspException { 985 v.visit(this); 986 } 987 988 public void setValue(JspAttribute value) { 989 this.value = value; 990 } 991 992 public JspAttribute getValue() { 993 return value; 994 } 995 } 996 997 1000 public static class ParamsAction extends Node { 1001 1002 public ParamsAction(Mark start, Node parent) { 1003 this(JSP_PARAMS_ACTION, null, null, start, parent); 1004 } 1005 1006 public ParamsAction(String qName, 1007 Attributes nonTaglibXmlnsAttrs, 1008 Attributes taglibAttrs, 1009 Mark start, Node parent) { 1010 super(qName, PARAMS_ACTION, null, nonTaglibXmlnsAttrs, taglibAttrs, 1011 start, parent); 1012 } 1013 1014 public void accept(Visitor v) throws JspException { 1015 v.visit(this); 1016 } 1017 } 1018 1019 1022 public static class FallBackAction extends Node { 1023 1024 public FallBackAction(Mark start, Node parent) { 1025 this(JSP_FALLBACK_ACTION, null, null, start, parent); 1026 } 1027 1028 public FallBackAction(String qName, 1029 Attributes nonTaglibXmlnsAttrs, 1030 Attributes taglibAttrs, Mark start, 1031 Node parent) { 1032 super(qName, FALLBACK_ACTION, null, nonTaglibXmlnsAttrs, 1033 taglibAttrs, start, parent); 1034 } 1035 1036 public void accept(Visitor v) throws JspException { 1037 v.visit(this); 1038 } 1039 } 1040 1041 1044 public static class IncludeAction extends Node { 1045 1046 private JspAttribute page; 1047 1048 public IncludeAction(Attributes attrs, Mark start, Node parent) { 1049 this(JSP_INCLUDE_ACTION, attrs, null, null, start, parent); 1050 } 1051 1052 public IncludeAction(String qName, Attributes attrs, 1053 Attributes nonTaglibXmlnsAttrs, 1054 Attributes taglibAttrs, Mark start, Node parent) { 1055 super(qName, INCLUDE_ACTION, attrs, nonTaglibXmlnsAttrs, 1056 taglibAttrs, start, parent); 1057 } 1058 1059 public void accept(Visitor v) throws JspException { 1060 v.visit(this); 1061 } 1062 1063 public void setPage(JspAttribute page) { 1064 this.page = page; 1065 } 1066 1067 public JspAttribute getPage() { 1068 return page; 1069 } 1070 } 1071 1072 1075 public static class ForwardAction extends Node { 1076 1077 private JspAttribute page; 1078 1079 public ForwardAction(Attributes attrs, Mark start, Node parent) { 1080 this(JSP_FORWARD_ACTION, attrs, null, null, start, parent); 1081 } 1082 1083 public ForwardAction(String qName, Attributes attrs, 1084 Attributes nonTaglibXmlnsAttrs, 1085 Attributes taglibAttrs, Mark start, Node parent) { 1086 super(qName, FORWARD_ACTION, attrs, nonTaglibXmlnsAttrs, 1087 taglibAttrs, start, parent); 1088 } 1089 1090 public void accept(Visitor v) throws JspException { 1091 v.visit(this); 1092 } 1093 1094 public void setPage(JspAttribute page) { 1095 this.page = page; 1096 } 1097 1098 public JspAttribute getPage() { 1099 return page; 1100 } 1101 } 1102 1103 1106 public static class GetProperty extends Node { 1107 1108 public GetProperty(Attributes attrs, Mark start, Node parent) { 1109 this(JSP_GET_PROPERTY_ACTION, attrs, null, null, start, parent); 1110 } 1111 1112 public GetProperty(String qName, Attributes attrs, 1113 Attributes nonTaglibXmlnsAttrs, 1114 Attributes taglibAttrs, Mark start, Node parent) { 1115 super(qName, GET_PROPERTY_ACTION, attrs, nonTaglibXmlnsAttrs, 1116 taglibAttrs, start, parent); 1117 } 1118 1119 public void accept(Visitor v) throws JspException { 1120 v.visit(this); 1121 } 1122 } 1123 1124 1127 public static class SetProperty extends Node { 1128 1129 private JspAttribute value; 1130 1131 public SetProperty(Attributes attrs, Mark start, Node parent) { 1132 this(JSP_SET_PROPERTY_ACTION, attrs, null, null, start, parent); 1133 } 1134 1135 public SetProperty(String qName, Attributes attrs, 1136 Attributes nonTaglibXmlnsAttrs, 1137 Attributes taglibAttrs, Mark start, Node parent) { 1138 super(qName, SET_PROPERTY_ACTION, attrs, nonTaglibXmlnsAttrs, 1139 taglibAttrs, start, parent); 1140 } 1141 1142 public void accept(Visitor v) throws JspException { 1143 v.visit(this); 1144 } 1145 1146 public void setValue(JspAttribute value) { 1147 this.value = value; 1148 } 1149 1150 public JspAttribute getValue() { 1151 return value; 1152 } 1153 } 1154 1155 1158 public static class UseBean extends Node { 1159 1160 JspAttribute beanName; 1161 1162 public UseBean(Attributes attrs, Mark start, Node parent) { 1163 this(JSP_USE_BEAN_ACTION, attrs, null, null, start, parent); 1164 } 1165 1166 public UseBean(String qName, Attributes attrs, 1167 Attributes nonTaglibXmlnsAttrs, Attributes taglibAttrs, 1168 Mark start, Node parent) { 1169 super(qName, USE_BEAN_ACTION, attrs, nonTaglibXmlnsAttrs, 1170 taglibAttrs, start, parent); 1171 } 1172 1173 public void accept(Visitor v) throws JspException { 1174 v.visit(this); 1175 } 1176 1177 public void setBeanName(JspAttribute beanName) { 1178 this.beanName = beanName; 1179 } 1180 1181 public JspAttribute getBeanName() { 1182 return beanName; 1183 } 1184 } 1185 1186 1189 public static class PlugIn extends Node { 1190 1191 private JspAttribute width; 1192 private JspAttribute height; 1193 1194 public PlugIn(Attributes attrs, Mark start, Node parent) { 1195 this(JSP_PLUGIN_ACTION, attrs, null, null, start, parent); 1196 } 1197 1198 public PlugIn(String qName, Attributes attrs, 1199 Attributes nonTaglibXmlnsAttrs, Attributes taglibAttrs, 1200 Mark start, Node parent) { 1201 super(qName, PLUGIN_ACTION, attrs, nonTaglibXmlnsAttrs, 1202 taglibAttrs, start, parent); 1203 } 1204 1205 public void accept(Visitor v) throws JspException { 1206 v.visit(this); 1207 } 1208 1209 public void setHeight(JspAttribute height) { 1210 this.height = height; 1211 } 1212 1213 public void setWidth(JspAttribute width) { 1214 this.width = width; 1215 } 1216 1217 public JspAttribute getHeight() { 1218 return height; 1219 } 1220 1221 public JspAttribute getWidth() { 1222 return width; 1223 } 1224 } 1225 1226 1229 public static class UninterpretedTag extends Node { 1230 1231 private JspAttribute[] jspAttrs; 1232 1233 public UninterpretedTag(String qName, String localName, 1234 Attributes attrs, 1235 Attributes nonTaglibXmlnsAttrs, 1236 Attributes taglibAttrs, 1237 Mark start, Node parent) { 1238 super(qName, localName, attrs, nonTaglibXmlnsAttrs, taglibAttrs, 1239 start, parent); 1240 } 1241 1242 public void accept(Visitor v) throws JspException { 1243 v.visit(this); 1244 } 1245 1246 public void setJspAttributes(JspAttribute[] jspAttrs) { 1247 this.jspAttrs = jspAttrs; 1248 } 1249 1250 public JspAttribute[] getJspAttributes() { 1251 return jspAttrs; 1252 } 1253 } 1254 1255 1258 public static class JspElement extends Node { 1259 1260 private JspAttribute[] jspAttrs; 1261 private JspAttribute nameAttr; 1262 1263 public JspElement(Attributes attrs, Mark start, Node parent) { 1264 this(JSP_ELEMENT_ACTION, attrs, null, null, start, parent); 1265 } 1266 1267 public JspElement(String qName, Attributes attrs, 1268 Attributes nonTaglibXmlnsAttrs, 1269 Attributes taglibAttrs, Mark start, Node parent) { 1270 super(qName, ELEMENT_ACTION, attrs, nonTaglibXmlnsAttrs, 1271 taglibAttrs, start, parent); 1272 } 1273 1274 public void accept(Visitor v) throws JspException { 1275 v.visit(this); 1276 } 1277 1278 public void setJspAttributes(JspAttribute[] jspAttrs) { 1279 this.jspAttrs = jspAttrs; 1280 } 1281 1282 public JspAttribute[] getJspAttributes() { 1283 return jspAttrs; 1284 } 1285 1286 1289 public void setNameAttribute(JspAttribute nameAttr) { 1290 this.nameAttr = nameAttr; 1291 } 1292 1293 1296 public JspAttribute getNameAttribute() { 1297 return this.nameAttr; 1298 } 1299 } 1300 1301 1304 public static class JspOutput extends Node { 1305 1306 public JspOutput(String qName, Attributes attrs, 1307 Attributes nonTaglibXmlnsAttrs, 1308 Attributes taglibAttrs, 1309 Mark start, Node parent) { 1310 super(qName, OUTPUT_ACTION, attrs, nonTaglibXmlnsAttrs, 1311 taglibAttrs, start, parent); 1312 } 1313 1314 public void accept(Visitor v) throws JspException { 1315 v.visit(this); 1316 } 1317 } 1318 1319 1324 public static class ChildInfo { 1325 private boolean scriptless; private boolean hasUseBean; 1328 private boolean hasIncludeAction; 1329 private boolean hasParamAction; 1330 private boolean hasSetProperty; 1331 private boolean hasScriptingVars; 1332 1333 public void setScriptless(boolean s) { 1334 scriptless = s; 1335 } 1336 1337 public boolean isScriptless() { 1338 return scriptless; 1339 } 1340 1341 public void setHasUseBean(boolean u) { 1342 hasUseBean = u; 1343 } 1344 1345 public boolean hasUseBean() { 1346 return hasUseBean; 1347 } 1348 1349 public void setHasIncludeAction(boolean i) { 1350 hasIncludeAction = i; 1351 } 1352 1353 public boolean hasIncludeAction() { 1354 return hasIncludeAction; 1355 } 1356 1357 public void setHasParamAction(boolean i) { 1358 hasParamAction = i; 1359 } 1360 1361 public boolean hasParamAction() { 1362 return hasParamAction; 1363 } 1364 1365 public void setHasSetProperty(boolean s) { 1366 hasSetProperty = s; 1367 } 1368 1369 public boolean hasSetProperty() { 1370 return hasSetProperty; 1371 } 1372 1373 public void setHasScriptingVars(boolean s) { 1374 hasScriptingVars = s; 1375 } 1376 1377 public boolean hasScriptingVars() { 1378 return hasScriptingVars; 1379 } 1380 } 1381 1382 1385 public static class CustomTag extends Node { 1386 1387 private String uri; 1388 private String prefix; 1389 private JspAttribute[] jspAttrs; 1390 private TagData tagData; 1391 private String tagHandlerPoolName; 1392 private TagInfo tagInfo; 1393 private TagFileInfo tagFileInfo; 1394 private Class tagHandlerClass; 1395 private VariableInfo[] varInfos; 1396 private int customNestingLevel; 1397 private ChildInfo childInfo; 1398 private boolean implementsIterationTag; 1399 private boolean implementsBodyTag; 1400 private boolean implementsTryCatchFinally; 1401 private boolean implementsSimpleTag; 1402 private boolean implementsDynamicAttributes; 1403 private Vector atBeginScriptingVars; 1404 private Vector atEndScriptingVars; 1405 private Vector nestedScriptingVars; 1406 private Node.CustomTag customTagParent; 1407 private Integer numCount; 1408 1411 1418 1421 1424 public CustomTag(String qName, String prefix, String localName, 1425 String uri, Attributes attrs, Mark start, Node parent, 1426 TagInfo tagInfo, Class tagHandlerClass) { 1427 this(qName, prefix, localName, uri, attrs, null, null, start, 1428 parent, tagInfo, tagHandlerClass); 1429 } 1430 1431 1434 public CustomTag(String qName, String prefix, String localName, 1435 String uri, Attributes attrs, 1436 Attributes nonTaglibXmlnsAttrs, 1437 Attributes taglibAttrs, 1438 Mark start, Node parent, TagInfo tagInfo, 1439 Class tagHandlerClass) { 1440 super(qName, localName, attrs, nonTaglibXmlnsAttrs, taglibAttrs, 1441 start, parent); 1442 1443 this.uri = uri; 1444 this.prefix = prefix; 1445 this.tagInfo = tagInfo; 1446 this.tagHandlerClass = tagHandlerClass; 1447 this.customNestingLevel = makeCustomNestingLevel(); 1448 this.childInfo = new ChildInfo(); 1449 1450 this.implementsIterationTag = 1451 IterationTag.class.isAssignableFrom(tagHandlerClass); 1452 this.implementsBodyTag = 1453 BodyTag.class.isAssignableFrom(tagHandlerClass); 1454 this.implementsTryCatchFinally = 1455 TryCatchFinally.class.isAssignableFrom(tagHandlerClass); 1456 this.implementsSimpleTag = 1457 SimpleTag.class.isAssignableFrom(tagHandlerClass); 1458 this.implementsDynamicAttributes = 1459 DynamicAttributes.class.isAssignableFrom(tagHandlerClass); 1460 } 1461 1462 1465 public CustomTag(String qName, String prefix, String localName, 1466 String uri, Attributes attrs, Mark start, Node parent, 1467 TagFileInfo tagFileInfo) { 1468 this(qName, prefix, localName, uri, attrs, null, null, start, 1469 parent, tagFileInfo); 1470 } 1471 1472 1475 public CustomTag(String qName, String prefix, String localName, 1476 String uri, Attributes attrs, 1477 Attributes nonTaglibXmlnsAttrs, 1478 Attributes taglibAttrs, 1479 Mark start, Node parent, TagFileInfo tagFileInfo) { 1480 1481 super(qName, localName, attrs, nonTaglibXmlnsAttrs, taglibAttrs, 1482 start, parent); 1483 1484 this.uri = uri; 1485 this.prefix = prefix; 1486 this.tagFileInfo = tagFileInfo; 1487 this.tagInfo = tagFileInfo.getTagInfo(); 1488 this.customNestingLevel = makeCustomNestingLevel(); 1489 this.childInfo = new ChildInfo(); 1490 1491 this.implementsIterationTag = false; 1492 this.implementsBodyTag = false; 1493 this.implementsTryCatchFinally = false; 1494 this.implementsSimpleTag = true; 1495 this.implementsDynamicAttributes = tagInfo.hasDynamicAttributes(); 1496 } 1497 1498 public void accept(Visitor v) throws JspException { 1499 v.visit(this); 1500 } 1501 1502 1505 public String getURI() { 1506 return this.uri; 1507 } 1508 1509 1512 public String getPrefix() { 1513 return prefix; 1514 } 1515 1516 public void setJspAttributes(JspAttribute[] jspAttrs) { 1517 this.jspAttrs = jspAttrs; 1518 } 1519 1520 public JspAttribute[] getJspAttributes() { 1521 return jspAttrs; 1522 } 1523 1524 public ChildInfo getChildInfo() { 1525 return childInfo; 1526 } 1527 1528 public void setTagData(TagData tagData) { 1529 this.tagData = tagData; 1530 this.varInfos = tagInfo.getVariableInfo(tagData); 1531 if (this.varInfos == null) { 1532 this.varInfos = ZERO_VARIABLE_INFO; 1533 } 1534 } 1535 1536 public TagData getTagData() { 1537 return tagData; 1538 } 1539 1540 public void setTagHandlerPoolName(String s) { 1541 tagHandlerPoolName = s; 1542 } 1543 1544 public String getTagHandlerPoolName() { 1545 return tagHandlerPoolName; 1546 } 1547 1548 public TagInfo getTagInfo() { 1549 return tagInfo; 1550 } 1551 1552 public TagFileInfo getTagFileInfo() { 1553 return tagFileInfo; 1554 } 1555 1556 1560 public boolean isTagFile() { 1561 return tagFileInfo != null; 1562 } 1563 1564 public Class getTagHandlerClass() { 1565 return tagHandlerClass; 1566 } 1567 1568 public void setTagHandlerClass(Class hc) { 1569 tagHandlerClass = hc; 1570 } 1571 1572 public boolean implementsIterationTag() { 1573 return implementsIterationTag; 1574 } 1575 1576 public boolean implementsBodyTag() { 1577 return implementsBodyTag; 1578 } 1579 1580 public boolean implementsTryCatchFinally() { 1581 return implementsTryCatchFinally; 1582 } 1583 1584 public boolean implementsSimpleTag() { 1585 return implementsSimpleTag; 1586 } 1587 1588 public boolean implementsDynamicAttributes() { 1589 return implementsDynamicAttributes; 1590 } 1591 1592 public TagVariableInfo[] getTagVariableInfos() { 1593 return tagInfo.getTagVariableInfos(); 1594 } 1595 1596 public VariableInfo[] getVariableInfos() { 1597 return varInfos; 1598 } 1599 1600 public void setCustomTagParent(Node.CustomTag n) { 1601 this.customTagParent = n; 1602 } 1603 1604 public Node.CustomTag getCustomTagParent() { 1605 return this.customTagParent; 1606 } 1607 1608 public void setNumCount(Integer count) { 1609 this.numCount = count; 1610 } 1611 1612 public Integer getNumCount() { 1613 return this.numCount; 1614 } 1615 1616 public void setScriptingVars(Vector vec, int scope) { 1617 switch (scope) { 1618 case VariableInfo.AT_BEGIN: 1619 this.atBeginScriptingVars = vec; 1620 break; 1621 case VariableInfo.AT_END: 1622 this.atEndScriptingVars = vec; 1623 break; 1624 case VariableInfo.NESTED: 1625 this.nestedScriptingVars = vec; 1626 break; 1627 } 1628 } 1629 1630 1634 public Vector getScriptingVars(int scope) { 1635 Vector vec = null; 1636 1637 switch (scope) { 1638 case VariableInfo.AT_BEGIN: 1639 vec = this.atBeginScriptingVars; 1640 break; 1641 case VariableInfo.AT_END: 1642 vec = this.atEndScriptingVars; 1643 break; 1644 case VariableInfo.NESTED: 1645 vec = this.nestedScriptingVars; 1646 break; 1647 } 1648 1649 return vec; 1650 } 1651 1652 1656 public int getCustomNestingLevel() { 1657 return customNestingLevel; 1658 } 1659 1660 1664 public boolean checkIfAttributeIsJspFragment( String name ) { 1665 boolean result = false; 1666 1667 TagAttributeInfo[] attributes = tagInfo.getAttributes(); 1668 for (int i = 0; i < attributes.length; i++) { 1669 if (attributes[i].getName().equals(name) && 1670 attributes[i].isFragment()) { 1671 result = true; 1672 break; 1673 } 1674 } 1675 1676 return result; 1677 } 1678 1679 1710 1711 1734 private int makeCustomNestingLevel() { 1735 int n = 0; 1736 Node p = parent; 1737 while (p != null) { 1738 if ((p instanceof Node.CustomTag) 1739 && qName.equals(((Node.CustomTag) p).qName)) { 1740 n++; 1741 } 1742 p = p.parent; 1743 } 1744 return n; 1745 } 1746 1747 1757 public boolean hasEmptyBody() { 1758 boolean hasEmptyBody = true; 1759 Nodes nodes = getBody(); 1760 if (nodes != null) { 1761 int numChildNodes = nodes.size(); 1762 for (int i=0; i<numChildNodes; i++) { 1763 Node n = nodes.getNode(i); 1764 if (!(n instanceof NamedAttribute)) { 1765 if (n instanceof JspBody) { 1766 hasEmptyBody = (n.getBody() == null); 1767 } else { 1768 hasEmptyBody = false; 1769 } 1770 break; 1771 } 1772 } 1773 } 1774 1775 return hasEmptyBody; 1776 } 1777 } 1778 1779 1783 public static class AttributeGenerator extends Node { 1784 String name; CustomTag tag; 1787 public AttributeGenerator(Mark start, String name, CustomTag tag) { 1788 super(start, null); 1789 this.name = name; 1790 this.tag = tag; 1791 } 1792 1793 public void accept(Visitor v) throws JspException { 1794 v.visit(this); 1795 } 1796 1797 public String getName() { 1798 return name; 1799 } 1800 1801 public CustomTag getTag() { 1802 return tag; 1803 } 1804 } 1805 1806 1809 public static class JspText extends Node { 1810 1811 public JspText(String qName, Attributes nonTaglibXmlnsAttrs, 1812 Attributes taglibAttrs, Mark start, Node parent) { 1813 super(qName, TEXT_ACTION, null, nonTaglibXmlnsAttrs, taglibAttrs, 1814 start, parent); 1815 } 1816 1817 public void accept(Visitor v) throws JspException { 1818 v.visit(this); 1819 } 1820 } 1821 1822 1825 public static class NamedAttribute extends Node { 1826 1827 1830 private boolean trim = true; 1832 1833 private ChildInfo childInfo; 1834 private String name; 1835 private String localName; 1836 private String prefix; 1837 1838 public NamedAttribute(Attributes attrs, Mark start, Node parent) { 1839 this(JSP_ATTRIBUTE_ACTION, attrs, null, null, start, parent); 1840 } 1841 1842 public NamedAttribute(String qName, Attributes attrs, 1843 Attributes nonTaglibXmlnsAttrs, 1844 Attributes taglibAttrs, 1845 Mark start, Node parent) { 1846 1847 super(qName, ATTRIBUTE_ACTION, attrs, nonTaglibXmlnsAttrs, 1848 taglibAttrs, start, parent); 1849 if( "false".equals( this.getAttributeValue( "trim" ) ) ) { 1851 trim = false; 1853 } 1854 childInfo = new ChildInfo(); 1855 name = this.getAttributeValue("name"); 1856 if (name != null) { 1857 localName = name; 1859 int index = name.indexOf(':'); 1860 if (index != -1) { 1861 prefix = name.substring(0, index); 1862 localName = name.substring(index+1); 1863 } 1864 } 1865 } 1866 1867 public void accept(Visitor v) throws JspException { 1868 v.visit(this); 1869 } 1870 1871 public String getName() { 1872 return this.name; 1873 } 1874 1875 public String getLocalName() { 1876 return this.localName; 1877 } 1878 1879 public String getPrefix() { 1880 return this.prefix; 1881 } 1882 1883 public ChildInfo getChildInfo() { 1884 return this.childInfo; 1885 } 1886 1887 public boolean isTrim() { 1888 return trim; 1889 } 1890 1891 1895 1898 1899 1904 public String getText() { 1905 1906 class AttributeVisitor extends Visitor { 1907 String attrValue = null; 1908 public void visit(TemplateText txt) { 1909 attrValue = new String (txt.getText()); 1910 } 1911 1912 public String getAttrValue() { 1913 return attrValue; 1914 } 1915 } 1916 1917 String text = ""; 1921 if (getBody() != null) { 1922 AttributeVisitor attributeVisitor = new AttributeVisitor(); 1923 try { 1924 getBody().visit(attributeVisitor); 1925 } catch (JspException e) { 1926 } 1927 text = attributeVisitor.getAttrValue(); 1928 } 1929 1930 return text; 1931 } 1932 } 1933 1934 1937 public static class JspBody extends Node { 1938 1939 private ChildInfo childInfo; 1940 1941 public JspBody(Mark start, Node parent) { 1942 this(JSP_BODY_ACTION, null, null, start, parent); 1943 } 1944 1945 public JspBody(String qName, Attributes nonTaglibXmlnsAttrs, 1946 Attributes taglibAttrs, Mark start, Node parent) { 1947 super(qName, BODY_ACTION, null, nonTaglibXmlnsAttrs, taglibAttrs, 1948 start, parent); 1949 this.childInfo = new ChildInfo(); 1950 } 1951 1952 public void accept(Visitor v) throws JspException { 1953 v.visit(this); 1954 } 1955 1956 public ChildInfo getChildInfo() { 1957 return childInfo; 1958 } 1959 } 1960 1961 1964 public static class TemplateText extends Node { 1965 1966 public TemplateText(String text, Mark start, Node parent) { 1967 super(null, null, text, start, parent); 1968 } 1969 1970 public void accept(Visitor v) throws JspException { 1971 v.visit(this); 1972 } 1973 1974 1977 public void ltrim() { 1978 int index = 0; 1979 while ((index < text.length()) && (text.charAt(index) <= ' ')) { 1980 index++; 1981 } 1982 text = text.substring(index); 1983 } 1984 1985 1988 public void rtrim() { 1989 int index = text.length(); 1990 while( (index > 0) && (text.charAt(index-1) <= ' ') ) { 1991 index--; 1992 } 1993 text = text.substring(0, index); 1994 } 1995 1996 1999 public boolean isAllSpace() { 2000 boolean isAllSpace = true; 2001 for (int i=0; i<text.length(); i++) { 2002 if (!Character.isSpace(text.charAt(i))) { 2003 isAllSpace = false; 2004 break; 2005 } 2006 } 2007 return isAllSpace; 2008 } 2009 } 2010 2011 2014 2015 2022 2023 public static class JspAttribute { 2024 2025 private String qName; 2026 private String uri; 2027 private String localName; 2028 private String value; 2029 private boolean expression; 2030 private boolean dynamic; 2031 private ELNode.Nodes el; 2032 2033 private boolean namedAttribute; 2035 private NamedAttribute namedAttributeNode; 2037 2038 JspAttribute(String qName, String uri, String localName, String value, 2039 boolean expr, ELNode.Nodes el, boolean dyn ) { 2040 this.qName = qName; 2041 this.uri = uri; 2042 this.localName = localName; 2043 this.value = value; 2044 this.namedAttributeNode = null; 2045 this.expression = expr; 2046 this.el = el; 2047 this.dynamic = dyn; 2048 this.namedAttribute = false; 2049 } 2050 2051 2056 JspAttribute(NamedAttribute na, boolean dyn) { 2057 this.qName = na.getName(); 2058 this.localName = na.getLocalName(); 2059 this.value = null; 2060 this.namedAttributeNode = na; 2061 this.expression = false; 2062 this.el = null; 2063 this.dynamic = dyn; 2064 this.namedAttribute = true; 2065 } 2066 2067 2070 public String getName() { 2071 return qName; 2072 } 2073 2074 2077 public String getLocalName() { 2078 return localName; 2079 } 2080 2081 2085 public String getURI() { 2086 return uri; 2087 } 2088 2089 2096 public String getValue() { 2097 return value; 2098 } 2099 2100 2105 public NamedAttribute getNamedAttributeNode() { 2106 return namedAttributeNode; 2107 } 2108 2109 2112 public boolean isExpression() { 2113 return expression; 2114 } 2115 2116 2119 public boolean isNamedAttribute() { 2120 return namedAttribute; 2121 } 2122 2123 2129 public boolean isELInterpreterInput() { 2130 return el != null; 2131 } 2132 2133 2137 public boolean isLiteral() { 2138 return !expression && (el != null) && !namedAttribute; 2139 } 2140 2141 2144 public boolean isDynamic() { 2145 return dynamic; 2146 } 2147 2148 public ELNode.Nodes getEL() { 2149 return el; 2150 } 2151 } 2152 2153 2157 public static class Nodes { 2158 2159 private List<Node> list; 2160 private Node.Root root; 2162 public Nodes() { 2163 list = new Vector<Node>(); 2164 } 2165 2166 public Nodes(List<Node> l) { 2167 list = l; 2168 } 2169 2170 public Nodes(Node.Root root) { 2171 this.root = root; 2172 list = new Vector<Node>(); 2173 list.add(root); 2174 } 2175 2176 2180 public void add(Node n) { 2181 list.add(n); 2182 root = null; 2183 } 2184 2185 2189 public void remove(Node n) { 2190 list.remove(n); 2191 } 2192 2193 2197 public void visit(Visitor v) throws JspException { 2198 for (Node n : list) { 2199 n.accept(v); 2200 } 2201 } 2202 2203 public int size() { 2204 return list.size(); 2205 } 2206 2207 public Node getNode(int index) { 2208 Node n = null; 2209 try { 2210 n = list.get(index); 2211 } catch (ArrayIndexOutOfBoundsException e) { 2212 } 2213 return n; 2214 } 2215 2216 public Node.Root getRoot() { 2217 return root; 2218 } 2219 2220 public String toString() { 2221 return DumpVisitor.dump(this); 2222 } 2223 } 2224 2225 2231 public static class Visitor { 2232 2233 2237 protected void doVisit(Node n) throws JspException { 2238 } 2239 2240 2243 protected void visitBody(Node n) throws JspException { 2244 if (n.getBody() != null) { 2245 n.getBody().visit(this); 2246 } 2247 } 2248 2249 public void visit(Root n) throws JspException { 2250 doVisit(n); 2251 visitBody(n); 2252 } 2253 2254 public void visit(JspRoot n) throws JspException { 2255 doVisit(n); 2256 visitBody(n); 2257 } 2258 2259 public void visit(PageDirective n) throws JspException { 2260 doVisit(n); 2261 } 2262 2263 public void visit(TagDirective n) throws JspException { 2264 doVisit(n); 2265 } 2266 2267 public void visit(IncludeDirective n) throws JspException { 2268 doVisit(n); 2269 visitBody(n); 2270 } 2271 2272 public void visit(TaglibDirective n) throws JspException { 2273 doVisit(n); 2274 } 2275 2276 public void visit(AttributeDirective n) throws JspException { 2277 doVisit(n); 2278 } 2279 2280 public void visit(VariableDirective n) throws JspException { 2281 doVisit(n); 2282 } 2283 2284 public void visit(Comment n) throws JspException { 2285 doVisit(n); 2286 } 2287 2288 public void visit(Declaration n) throws JspException { 2289 doVisit(n); 2290 } 2291 2292 public void visit(Expression n) throws JspException { 2293 doVisit(n); 2294 } 2295 2296 public void visit(Scriptlet n) throws JspException { 2297 doVisit(n); 2298 } 2299 2300 public void visit(ELExpression n) throws JspException { 2301 doVisit(n); 2302 } 2303 2304 public void visit(IncludeAction n) throws JspException { 2305 doVisit(n); 2306 visitBody(n); 2307 } 2308 2309 public void visit(ForwardAction n) throws JspException { 2310 doVisit(n); 2311 visitBody(n); 2312 } 2313 2314 public void visit(GetProperty n) throws JspException { 2315 doVisit(n); 2316 visitBody(n); 2317 } 2318 2319 public void visit(SetProperty n) throws JspException { 2320 doVisit(n); 2321 visitBody(n); 2322 } 2323 2324 public void visit(ParamAction n) throws JspException { 2325 doVisit(n); 2326 visitBody(n); 2327 } 2328 2329 public void visit(ParamsAction n) throws JspException { 2330 doVisit(n); 2331 visitBody(n); 2332 } 2333 2334 public void visit(FallBackAction n) throws JspException { 2335 doVisit(n); 2336 visitBody(n); 2337 } 2338 2339 public void visit(UseBean n) throws JspException { 2340 doVisit(n); 2341 visitBody(n); 2342 } 2343 2344 public void visit(PlugIn n) throws JspException { 2345 doVisit(n); 2346 visitBody(n); 2347 } 2348 2349 public void visit(CustomTag n) throws JspException { 2350 doVisit(n); 2351 visitBody(n); 2352 } 2353 2354 public void visit(UninterpretedTag n) throws JspException { 2355 doVisit(n); 2356 visitBody(n); 2357 } 2358 2359 public void visit(JspElement n) throws JspException { 2360 doVisit(n); 2361 visitBody(n); 2362 } 2363 2364 public void visit(JspText n) throws JspException { 2365 doVisit(n); 2366 visitBody(n); 2367 } 2368 2369 public void visit(NamedAttribute n) throws JspException { 2370 doVisit(n); 2371 visitBody(n); 2372 } 2373 2374 public void visit(JspBody n) throws JspException { 2375 doVisit(n); 2376 visitBody(n); 2377 } 2378 2379 public void visit(InvokeAction n) throws JspException { 2380 doVisit(n); 2381 visitBody(n); 2382 } 2383 2384 public void visit(DoBodyAction n) throws JspException { 2385 doVisit(n); 2386 visitBody(n); 2387 } 2388 2389 public void visit(TemplateText n) throws JspException { 2390 doVisit(n); 2391 } 2392 2393 public void visit(JspOutput n) throws JspException { 2394 doVisit(n); 2395 } 2396 2397 public void visit(AttributeGenerator n) throws JspException { 2398 doVisit(n); 2399 } 2400 } 2401} 2402 | Popular Tags |