1 17 18 package org.apache.jasper.compiler; 19 20 import java.util.Iterator ; 21 import java.util.List ; 22 import java.util.Vector ; 23 import java.util.ArrayList ; 24 25 import javax.el.ELContext; 26 import javax.el.ELException; 27 import javax.el.ExpressionFactory; 28 import javax.el.ValueExpression; 29 import javax.servlet.jsp.tagext.BodyTag ; 30 import javax.servlet.jsp.tagext.DynamicAttributes ; 31 import javax.servlet.jsp.tagext.IterationTag ; 32 import javax.servlet.jsp.tagext.JspIdConsumer ; 33 import javax.servlet.jsp.tagext.SimpleTag ; 34 import javax.servlet.jsp.tagext.TagAttributeInfo ; 35 import javax.servlet.jsp.tagext.TagData ; 36 import javax.servlet.jsp.tagext.TagFileInfo ; 37 import javax.servlet.jsp.tagext.TagInfo ; 38 import javax.servlet.jsp.tagext.TagVariableInfo ; 39 import javax.servlet.jsp.tagext.TryCatchFinally ; 40 import javax.servlet.jsp.tagext.VariableInfo ; 41 42 import org.apache.jasper.JasperException; 43 import org.apache.jasper.compiler.tagplugin.TagPluginContext; 44 import org.xml.sax.Attributes ; 45 46 55 56 abstract class Node implements TagConstants { 57 58 private static final VariableInfo [] ZERO_VARIABLE_INFO = {}; 59 60 protected Attributes attrs; 61 62 protected Attributes taglibAttrs; 64 65 68 protected Attributes nonTaglibXmlnsAttrs; 69 70 protected Nodes body; 71 72 protected String text; 73 74 protected Mark startMark; 75 76 protected int beginJavaLine; 77 78 protected int endJavaLine; 79 80 protected Node parent; 81 82 protected Nodes namedAttributeNodes; 84 protected String qName; 85 86 protected String localName; 87 88 94 protected String innerClassName; 95 96 private boolean isDummy; 97 98 101 public Node() { 102 this.isDummy = true; 103 } 104 105 113 public Node(Mark start, Node parent) { 114 this.startMark = start; 115 this.isDummy = (start == null); 116 addToParent(parent); 117 } 118 119 131 public Node(String qName, String localName, Mark start, Node parent) { 132 this.qName = qName; 133 this.localName = localName; 134 this.startMark = start; 135 this.isDummy = (start == null); 136 addToParent(parent); 137 } 138 139 153 public Node(String qName, String localName, Attributes attrs, Mark start, 154 Node parent) { 155 this.qName = qName; 156 this.localName = localName; 157 this.attrs = attrs; 158 this.startMark = start; 159 this.isDummy = (start == null); 160 addToParent(parent); 161 } 162 163 182 public Node(String qName, String localName, Attributes attrs, 183 Attributes nonTaglibXmlnsAttrs, Attributes taglibAttrs, Mark start, 184 Node parent) { 185 this.qName = qName; 186 this.localName = localName; 187 this.attrs = attrs; 188 this.nonTaglibXmlnsAttrs = nonTaglibXmlnsAttrs; 189 this.taglibAttrs = taglibAttrs; 190 this.startMark = start; 191 this.isDummy = (start == null); 192 addToParent(parent); 193 } 194 195 202 public Node(String qName, String localName, String text, Mark start, 203 Node parent) { 204 this.qName = qName; 205 this.localName = localName; 206 this.text = text; 207 this.startMark = start; 208 this.isDummy = (start == null); 209 addToParent(parent); 210 } 211 212 public String getQName() { 213 return this.qName; 214 } 215 216 public String getLocalName() { 217 return this.localName; 218 } 219 220 229 public Attributes getAttributes() { 230 return this.attrs; 231 } 232 233 237 public Attributes getTaglibAttributes() { 238 return this.taglibAttrs; 239 } 240 241 245 public Attributes getNonTaglibXmlnsAttributes() { 246 return this.nonTaglibXmlnsAttrs; 247 } 248 249 public void setAttributes(Attributes attrs) { 250 this.attrs = attrs; 251 } 252 253 public String getAttributeValue(String name) { 254 return (attrs == null) ? null : attrs.getValue(name); 255 } 256 257 261 public String getTextAttribute(String name) { 262 263 String attr = getAttributeValue(name); 264 if (attr != null) { 265 return attr; 266 } 267 268 NamedAttribute namedAttribute = getNamedAttributeNode(name); 269 if (namedAttribute == null) { 270 return null; 271 } 272 273 return namedAttribute.getText(); 274 } 275 276 284 public NamedAttribute getNamedAttributeNode(String name) { 285 NamedAttribute result = null; 286 287 Nodes nodes = getNamedAttributeNodes(); 289 int numChildNodes = nodes.size(); 290 for (int i = 0; i < numChildNodes; i++) { 291 NamedAttribute na = (NamedAttribute) nodes.getNode(i); 292 boolean found = false; 293 int index = name.indexOf(':'); 294 if (index != -1) { 295 found = na.getName().equals(name); 297 } else { 298 found = na.getLocalName().equals(name); 299 } 300 if (found) { 301 result = na; 302 break; 303 } 304 } 305 306 return result; 307 } 308 309 316 public Node.Nodes getNamedAttributeNodes() { 317 318 if (namedAttributeNodes != null) { 319 return namedAttributeNodes; 320 } 321 322 Node.Nodes result = new Node.Nodes(); 323 324 Nodes nodes = getBody(); 326 if (nodes != null) { 327 int numChildNodes = nodes.size(); 328 for (int i = 0; i < numChildNodes; i++) { 329 Node n = nodes.getNode(i); 330 if (n instanceof NamedAttribute) { 331 result.add(n); 332 } else if (!(n instanceof Comment)) { 333 break; 336 } 337 } 338 } 339 340 namedAttributeNodes = result; 341 return result; 342 } 343 344 public Nodes getBody() { 345 return body; 346 } 347 348 public void setBody(Nodes body) { 349 this.body = body; 350 } 351 352 public String getText() { 353 return text; 354 } 355 356 public Mark getStart() { 357 return startMark; 358 } 359 360 public Node getParent() { 361 return parent; 362 } 363 364 public int getBeginJavaLine() { 365 return beginJavaLine; 366 } 367 368 public void setBeginJavaLine(int begin) { 369 beginJavaLine = begin; 370 } 371 372 public int getEndJavaLine() { 373 return endJavaLine; 374 } 375 376 public void setEndJavaLine(int end) { 377 endJavaLine = end; 378 } 379 380 public boolean isDummy() { 381 return isDummy; 382 } 383 384 public Node.Root getRoot() { 385 Node n = this; 386 while (!(n instanceof Node.Root)) { 387 n = n.getParent(); 388 } 389 return (Node.Root) n; 390 } 391 392 public String getInnerClassName() { 393 return innerClassName; 394 } 395 396 public void setInnerClassName(String icn) { 397 innerClassName = icn; 398 } 399 400 407 abstract void accept(Visitor v) throws JasperException; 408 409 412 415 private void addToParent(Node parent) { 416 if (parent != null) { 417 this.parent = parent; 418 Nodes parentBody = parent.getBody(); 419 if (parentBody == null) { 420 parentBody = new Nodes(); 421 parent.setBody(parentBody); 422 } 423 parentBody.add(this); 424 } 425 } 426 427 430 431 434 public static class Root extends Node { 435 436 private Root parentRoot; 437 438 private boolean isXmlSyntax; 439 440 private String pageEnc; 442 443 private String jspConfigPageEnc; 445 446 456 private boolean isDefaultPageEncoding; 457 458 464 private boolean isEncodingSpecifiedInProlog; 465 466 470 private boolean isBomPresent; 471 472 475 Root(Mark start, Node parent, boolean isXmlSyntax) { 476 super(start, parent); 477 this.isXmlSyntax = isXmlSyntax; 478 this.qName = JSP_ROOT_ACTION; 479 this.localName = ROOT_ACTION; 480 481 Node r = parent; 483 while ((r != null) && !(r instanceof Node.Root)) 484 r = r.getParent(); 485 parentRoot = (Node.Root) r; 486 } 487 488 public void accept(Visitor v) throws JasperException { 489 v.visit(this); 490 } 491 492 public boolean isXmlSyntax() { 493 return isXmlSyntax; 494 } 495 496 500 public void setJspConfigPageEncoding(String enc) { 501 jspConfigPageEnc = enc; 502 } 503 504 508 public String getJspConfigPageEncoding() { 509 return jspConfigPageEnc; 510 } 511 512 public void setPageEncoding(String enc) { 513 pageEnc = enc; 514 } 515 516 public String getPageEncoding() { 517 return pageEnc; 518 } 519 520 public void setIsDefaultPageEncoding(boolean isDefault) { 521 isDefaultPageEncoding = isDefault; 522 } 523 524 public boolean isDefaultPageEncoding() { 525 return isDefaultPageEncoding; 526 } 527 528 public void setIsEncodingSpecifiedInProlog(boolean isSpecified) { 529 isEncodingSpecifiedInProlog = isSpecified; 530 } 531 532 public boolean isEncodingSpecifiedInProlog() { 533 return isEncodingSpecifiedInProlog; 534 } 535 536 public void setIsBomPresent(boolean isBom) { 537 isBomPresent = isBom; 538 } 539 540 public boolean isBomPresent() { 541 return isBomPresent; 542 } 543 544 548 public Root getParentRoot() { 549 return parentRoot; 550 } 551 } 552 553 556 public static class JspRoot extends Node { 557 558 public JspRoot(String qName, Attributes attrs, 559 Attributes nonTaglibXmlnsAttrs, Attributes taglibAttrs, 560 Mark start, Node parent) { 561 super(qName, ROOT_ACTION, attrs, nonTaglibXmlnsAttrs, taglibAttrs, 562 start, parent); 563 } 564 565 public void accept(Visitor v) throws JasperException { 566 v.visit(this); 567 } 568 } 569 570 573 public static class PageDirective extends Node { 574 575 private Vector imports; 576 577 public PageDirective(Attributes attrs, Mark start, Node parent) { 578 this(JSP_PAGE_DIRECTIVE_ACTION, attrs, null, null, start, parent); 579 } 580 581 public PageDirective(String qName, Attributes attrs, 582 Attributes nonTaglibXmlnsAttrs, Attributes taglibAttrs, 583 Mark start, Node parent) { 584 super(qName, PAGE_DIRECTIVE_ACTION, attrs, nonTaglibXmlnsAttrs, 585 taglibAttrs, start, parent); 586 imports = new Vector (); 587 } 588 589 public void accept(Visitor v) throws JasperException { 590 v.visit(this); 591 } 592 593 601 public void addImport(String value) { 602 int start = 0; 603 int index; 604 while ((index = value.indexOf(',', start)) != -1) { 605 imports.add(value.substring(start, index).trim()); 606 start = index + 1; 607 } 608 if (start == 0) { 609 imports.add(value.trim()); 611 } else { 612 imports.add(value.substring(start).trim()); 613 } 614 } 615 616 public List getImports() { 617 return imports; 618 } 619 } 620 621 624 public static class IncludeDirective extends Node { 625 626 public IncludeDirective(Attributes attrs, Mark start, Node parent) { 627 this(JSP_INCLUDE_DIRECTIVE_ACTION, attrs, null, null, start, parent); 628 } 629 630 public IncludeDirective(String qName, Attributes attrs, 631 Attributes nonTaglibXmlnsAttrs, Attributes taglibAttrs, 632 Mark start, Node parent) { 633 super(qName, INCLUDE_DIRECTIVE_ACTION, attrs, nonTaglibXmlnsAttrs, 634 taglibAttrs, start, parent); 635 } 636 637 public void accept(Visitor v) throws JasperException { 638 v.visit(this); 639 } 640 } 641 642 645 public static class TaglibDirective extends Node { 646 647 public TaglibDirective(Attributes attrs, Mark start, Node parent) { 648 super(JSP_TAGLIB_DIRECTIVE_ACTION, TAGLIB_DIRECTIVE_ACTION, attrs, 649 start, parent); 650 } 651 652 public void accept(Visitor v) throws JasperException { 653 v.visit(this); 654 } 655 } 656 657 660 public static class TagDirective extends Node { 661 private Vector imports; 662 663 public TagDirective(Attributes attrs, Mark start, Node parent) { 664 this(JSP_TAG_DIRECTIVE_ACTION, attrs, null, null, start, parent); 665 } 666 667 public TagDirective(String qName, Attributes attrs, 668 Attributes nonTaglibXmlnsAttrs, Attributes taglibAttrs, 669 Mark start, Node parent) { 670 super(qName, TAG_DIRECTIVE_ACTION, attrs, nonTaglibXmlnsAttrs, 671 taglibAttrs, start, parent); 672 imports = new Vector (); 673 } 674 675 public void accept(Visitor v) throws JasperException { 676 v.visit(this); 677 } 678 679 687 public void addImport(String value) { 688 int start = 0; 689 int index; 690 while ((index = value.indexOf(',', start)) != -1) { 691 imports.add(value.substring(start, index).trim()); 692 start = index + 1; 693 } 694 if (start == 0) { 695 imports.add(value.trim()); 697 } else { 698 imports.add(value.substring(start).trim()); 699 } 700 } 701 702 public List getImports() { 703 return imports; 704 } 705 } 706 707 710 public static class AttributeDirective extends Node { 711 712 public AttributeDirective(Attributes attrs, Mark start, Node parent) { 713 this(JSP_ATTRIBUTE_DIRECTIVE_ACTION, attrs, null, null, start, 714 parent); 715 } 716 717 public AttributeDirective(String qName, Attributes attrs, 718 Attributes nonTaglibXmlnsAttrs, Attributes taglibAttrs, 719 Mark start, Node parent) { 720 super(qName, ATTRIBUTE_DIRECTIVE_ACTION, attrs, 721 nonTaglibXmlnsAttrs, taglibAttrs, start, parent); 722 } 723 724 public void accept(Visitor v) throws JasperException { 725 v.visit(this); 726 } 727 } 728 729 732 public static class VariableDirective extends Node { 733 734 public VariableDirective(Attributes attrs, Mark start, Node parent) { 735 this(JSP_VARIABLE_DIRECTIVE_ACTION, attrs, null, null, start, 736 parent); 737 } 738 739 public VariableDirective(String qName, Attributes attrs, 740 Attributes nonTaglibXmlnsAttrs, Attributes taglibAttrs, 741 Mark start, Node parent) { 742 super(qName, VARIABLE_DIRECTIVE_ACTION, attrs, nonTaglibXmlnsAttrs, 743 taglibAttrs, start, parent); 744 } 745 746 public void accept(Visitor v) throws JasperException { 747 v.visit(this); 748 } 749 } 750 751 754 public static class InvokeAction extends Node { 755 756 public InvokeAction(Attributes attrs, Mark start, Node parent) { 757 this(JSP_INVOKE_ACTION, attrs, null, null, start, parent); 758 } 759 760 public InvokeAction(String qName, Attributes attrs, 761 Attributes nonTaglibXmlnsAttrs, Attributes taglibAttrs, 762 Mark start, Node parent) { 763 super(qName, INVOKE_ACTION, attrs, nonTaglibXmlnsAttrs, 764 taglibAttrs, start, parent); 765 } 766 767 public void accept(Visitor v) throws JasperException { 768 v.visit(this); 769 } 770 } 771 772 775 public static class DoBodyAction extends Node { 776 777 public DoBodyAction(Attributes attrs, Mark start, Node parent) { 778 this(JSP_DOBODY_ACTION, attrs, null, null, start, parent); 779 } 780 781 public DoBodyAction(String qName, Attributes attrs, 782 Attributes nonTaglibXmlnsAttrs, Attributes taglibAttrs, 783 Mark start, Node parent) { 784 super(qName, DOBODY_ACTION, attrs, nonTaglibXmlnsAttrs, 785 taglibAttrs, start, parent); 786 } 787 788 public void accept(Visitor v) throws JasperException { 789 v.visit(this); 790 } 791 } 792 793 796 public static class Comment extends Node { 797 798 public Comment(String text, Mark start, Node parent) { 799 super(null, null, text, start, parent); 800 } 801 802 public void accept(Visitor v) throws JasperException { 803 v.visit(this); 804 } 805 } 806 807 810 public static abstract class ScriptingElement extends Node { 811 812 public ScriptingElement(String qName, String localName, String text, 813 Mark start, Node parent) { 814 super(qName, localName, text, start, parent); 815 } 816 817 public ScriptingElement(String qName, String localName, 818 Attributes nonTaglibXmlnsAttrs, Attributes taglibAttrs, 819 Mark start, Node parent) { 820 super(qName, localName, null, nonTaglibXmlnsAttrs, taglibAttrs, 821 start, parent); 822 } 823 824 832 public String getText() { 833 String ret = text; 834 if ((ret == null) && (body != null)) { 835 StringBuffer buf = new StringBuffer (); 836 for (int i = 0; i < body.size(); i++) { 837 buf.append(body.getNode(i).getText()); 838 } 839 ret = buf.toString(); 840 } 841 return ret; 842 } 843 844 848 public Mark getStart() { 849 if (text == null && body != null && body.size() > 0) { 850 return body.getNode(0).getStart(); 851 } else { 852 return super.getStart(); 853 } 854 } 855 } 856 857 860 public static class Declaration extends ScriptingElement { 861 862 public Declaration(String text, Mark start, Node parent) { 863 super(JSP_DECLARATION_ACTION, DECLARATION_ACTION, text, start, 864 parent); 865 } 866 867 public Declaration(String qName, Attributes nonTaglibXmlnsAttrs, 868 Attributes taglibAttrs, Mark start, Node parent) { 869 super(qName, DECLARATION_ACTION, nonTaglibXmlnsAttrs, taglibAttrs, 870 start, parent); 871 } 872 873 public void accept(Visitor v) throws JasperException { 874 v.visit(this); 875 } 876 } 877 878 882 public static class Expression extends ScriptingElement { 883 884 public Expression(String text, Mark start, Node parent) { 885 super(JSP_EXPRESSION_ACTION, EXPRESSION_ACTION, text, start, parent); 886 } 887 888 public Expression(String qName, Attributes nonTaglibXmlnsAttrs, 889 Attributes taglibAttrs, Mark start, Node parent) { 890 super(qName, EXPRESSION_ACTION, nonTaglibXmlnsAttrs, taglibAttrs, 891 start, parent); 892 } 893 894 public void accept(Visitor v) throws JasperException { 895 v.visit(this); 896 } 897 } 898 899 902 public static class Scriptlet extends ScriptingElement { 903 904 public Scriptlet(String text, Mark start, Node parent) { 905 super(JSP_SCRIPTLET_ACTION, SCRIPTLET_ACTION, text, start, parent); 906 } 907 908 public Scriptlet(String qName, Attributes nonTaglibXmlnsAttrs, 909 Attributes taglibAttrs, Mark start, Node parent) { 910 super(qName, SCRIPTLET_ACTION, nonTaglibXmlnsAttrs, taglibAttrs, 911 start, parent); 912 } 913 914 public void accept(Visitor v) throws JasperException { 915 v.visit(this); 916 } 917 } 918 919 923 public static class ELExpression extends Node { 924 925 private ELNode.Nodes el; 926 927 private final char type; 928 929 public ELExpression(char type, String text, Mark start, Node parent) { 930 super(null, null, text, start, parent); 931 this.type = type; 932 } 933 934 public void accept(Visitor v) throws JasperException { 935 v.visit(this); 936 } 937 938 public void setEL(ELNode.Nodes el) { 939 this.el = el; 940 } 941 942 public ELNode.Nodes getEL() { 943 return el; 944 } 945 946 public char getType() { 947 return this.type; 948 } 949 } 950 951 954 public static class ParamAction extends Node { 955 956 JspAttribute value; 957 958 public ParamAction(Attributes attrs, Mark start, Node parent) { 959 this(JSP_PARAM_ACTION, attrs, null, null, start, parent); 960 } 961 962 public ParamAction(String qName, Attributes attrs, 963 Attributes nonTaglibXmlnsAttrs, Attributes taglibAttrs, 964 Mark start, Node parent) { 965 super(qName, PARAM_ACTION, attrs, nonTaglibXmlnsAttrs, taglibAttrs, 966 start, parent); 967 } 968 969 public void accept(Visitor v) throws JasperException { 970 v.visit(this); 971 } 972 973 public void setValue(JspAttribute value) { 974 this.value = value; 975 } 976 977 public JspAttribute getValue() { 978 return value; 979 } 980 } 981 982 985 public static class ParamsAction extends Node { 986 987 public ParamsAction(Mark start, Node parent) { 988 this(JSP_PARAMS_ACTION, null, null, start, parent); 989 } 990 991 public ParamsAction(String qName, Attributes nonTaglibXmlnsAttrs, 992 Attributes taglibAttrs, Mark start, Node parent) { 993 super(qName, PARAMS_ACTION, null, nonTaglibXmlnsAttrs, taglibAttrs, 994 start, parent); 995 } 996 997 public void accept(Visitor v) throws JasperException { 998 v.visit(this); 999 } 1000 } 1001 1002 1005 public static class FallBackAction extends Node { 1006 1007 public FallBackAction(Mark start, Node parent) { 1008 this(JSP_FALLBACK_ACTION, null, null, start, parent); 1009 } 1010 1011 public FallBackAction(String qName, Attributes nonTaglibXmlnsAttrs, 1012 Attributes taglibAttrs, Mark start, Node parent) { 1013 super(qName, FALLBACK_ACTION, null, nonTaglibXmlnsAttrs, 1014 taglibAttrs, start, parent); 1015 } 1016 1017 public void accept(Visitor v) throws JasperException { 1018 v.visit(this); 1019 } 1020 } 1021 1022 1025 public static class IncludeAction extends Node { 1026 1027 private JspAttribute page; 1028 1029 public IncludeAction(Attributes attrs, Mark start, Node parent) { 1030 this(JSP_INCLUDE_ACTION, attrs, null, null, start, parent); 1031 } 1032 1033 public IncludeAction(String qName, Attributes attrs, 1034 Attributes nonTaglibXmlnsAttrs, Attributes taglibAttrs, 1035 Mark start, Node parent) { 1036 super(qName, INCLUDE_ACTION, attrs, nonTaglibXmlnsAttrs, 1037 taglibAttrs, start, parent); 1038 } 1039 1040 public void accept(Visitor v) throws JasperException { 1041 v.visit(this); 1042 } 1043 1044 public void setPage(JspAttribute page) { 1045 this.page = page; 1046 } 1047 1048 public JspAttribute getPage() { 1049 return page; 1050 } 1051 } 1052 1053 1056 public static class ForwardAction extends Node { 1057 1058 private JspAttribute page; 1059 1060 public ForwardAction(Attributes attrs, Mark start, Node parent) { 1061 this(JSP_FORWARD_ACTION, attrs, null, null, start, parent); 1062 } 1063 1064 public ForwardAction(String qName, Attributes attrs, 1065 Attributes nonTaglibXmlnsAttrs, Attributes taglibAttrs, 1066 Mark start, Node parent) { 1067 super(qName, FORWARD_ACTION, attrs, nonTaglibXmlnsAttrs, 1068 taglibAttrs, start, parent); 1069 } 1070 1071 public void accept(Visitor v) throws JasperException { 1072 v.visit(this); 1073 } 1074 1075 public void setPage(JspAttribute page) { 1076 this.page = page; 1077 } 1078 1079 public JspAttribute getPage() { 1080 return page; 1081 } 1082 } 1083 1084 1087 public static class GetProperty extends Node { 1088 1089 public GetProperty(Attributes attrs, Mark start, Node parent) { 1090 this(JSP_GET_PROPERTY_ACTION, attrs, null, null, start, parent); 1091 } 1092 1093 public GetProperty(String qName, Attributes attrs, 1094 Attributes nonTaglibXmlnsAttrs, Attributes taglibAttrs, 1095 Mark start, Node parent) { 1096 super(qName, GET_PROPERTY_ACTION, attrs, nonTaglibXmlnsAttrs, 1097 taglibAttrs, start, parent); 1098 } 1099 1100 public void accept(Visitor v) throws JasperException { 1101 v.visit(this); 1102 } 1103 } 1104 1105 1108 public static class SetProperty extends Node { 1109 1110 private JspAttribute value; 1111 1112 public SetProperty(Attributes attrs, Mark start, Node parent) { 1113 this(JSP_SET_PROPERTY_ACTION, attrs, null, null, start, parent); 1114 } 1115 1116 public SetProperty(String qName, Attributes attrs, 1117 Attributes nonTaglibXmlnsAttrs, Attributes taglibAttrs, 1118 Mark start, Node parent) { 1119 super(qName, SET_PROPERTY_ACTION, attrs, nonTaglibXmlnsAttrs, 1120 taglibAttrs, start, parent); 1121 } 1122 1123 public void accept(Visitor v) throws JasperException { 1124 v.visit(this); 1125 } 1126 1127 public void setValue(JspAttribute value) { 1128 this.value = value; 1129 } 1130 1131 public JspAttribute getValue() { 1132 return value; 1133 } 1134 } 1135 1136 1139 public static class UseBean extends Node { 1140 1141 JspAttribute beanName; 1142 1143 public UseBean(Attributes attrs, Mark start, Node parent) { 1144 this(JSP_USE_BEAN_ACTION, attrs, null, null, start, parent); 1145 } 1146 1147 public UseBean(String qName, Attributes attrs, 1148 Attributes nonTaglibXmlnsAttrs, Attributes taglibAttrs, 1149 Mark start, Node parent) { 1150 super(qName, USE_BEAN_ACTION, attrs, nonTaglibXmlnsAttrs, 1151 taglibAttrs, start, parent); 1152 } 1153 1154 public void accept(Visitor v) throws JasperException { 1155 v.visit(this); 1156 } 1157 1158 public void setBeanName(JspAttribute beanName) { 1159 this.beanName = beanName; 1160 } 1161 1162 public JspAttribute getBeanName() { 1163 return beanName; 1164 } 1165 } 1166 1167 1170 public static class PlugIn extends Node { 1171 1172 private JspAttribute width; 1173 1174 private JspAttribute height; 1175 1176 public PlugIn(Attributes attrs, Mark start, Node parent) { 1177 this(JSP_PLUGIN_ACTION, attrs, null, null, start, parent); 1178 } 1179 1180 public PlugIn(String qName, Attributes attrs, 1181 Attributes nonTaglibXmlnsAttrs, Attributes taglibAttrs, 1182 Mark start, Node parent) { 1183 super(qName, PLUGIN_ACTION, attrs, nonTaglibXmlnsAttrs, 1184 taglibAttrs, start, parent); 1185 } 1186 1187 public void accept(Visitor v) throws JasperException { 1188 v.visit(this); 1189 } 1190 1191 public void setHeight(JspAttribute height) { 1192 this.height = height; 1193 } 1194 1195 public void setWidth(JspAttribute width) { 1196 this.width = width; 1197 } 1198 1199 public JspAttribute getHeight() { 1200 return height; 1201 } 1202 1203 public JspAttribute getWidth() { 1204 return width; 1205 } 1206 } 1207 1208 1211 public static class UninterpretedTag extends Node { 1212 1213 private JspAttribute[] jspAttrs; 1214 1215 public UninterpretedTag(String qName, String localName, 1216 Attributes attrs, Attributes nonTaglibXmlnsAttrs, 1217 Attributes taglibAttrs, Mark start, Node parent) { 1218 super(qName, localName, attrs, nonTaglibXmlnsAttrs, taglibAttrs, 1219 start, parent); 1220 } 1221 1222 public void accept(Visitor v) throws JasperException { 1223 v.visit(this); 1224 } 1225 1226 public void setJspAttributes(JspAttribute[] jspAttrs) { 1227 this.jspAttrs = jspAttrs; 1228 } 1229 1230 public JspAttribute[] getJspAttributes() { 1231 return jspAttrs; 1232 } 1233 } 1234 1235 1238 public static class JspElement extends Node { 1239 1240 private JspAttribute[] jspAttrs; 1241 1242 private JspAttribute nameAttr; 1243 1244 public JspElement(Attributes attrs, Mark start, Node parent) { 1245 this(JSP_ELEMENT_ACTION, attrs, null, null, start, parent); 1246 } 1247 1248 public JspElement(String qName, Attributes attrs, 1249 Attributes nonTaglibXmlnsAttrs, Attributes taglibAttrs, 1250 Mark start, Node parent) { 1251 super(qName, ELEMENT_ACTION, attrs, nonTaglibXmlnsAttrs, 1252 taglibAttrs, start, parent); 1253 } 1254 1255 public void accept(Visitor v) throws JasperException { 1256 v.visit(this); 1257 } 1258 1259 public void setJspAttributes(JspAttribute[] jspAttrs) { 1260 this.jspAttrs = jspAttrs; 1261 } 1262 1263 public JspAttribute[] getJspAttributes() { 1264 return jspAttrs; 1265 } 1266 1267 1270 public void setNameAttribute(JspAttribute nameAttr) { 1271 this.nameAttr = nameAttr; 1272 } 1273 1274 1277 public JspAttribute getNameAttribute() { 1278 return this.nameAttr; 1279 } 1280 } 1281 1282 1285 public static class JspOutput extends Node { 1286 1287 public JspOutput(String qName, Attributes attrs, 1288 Attributes nonTaglibXmlnsAttrs, Attributes taglibAttrs, 1289 Mark start, Node parent) { 1290 super(qName, OUTPUT_ACTION, attrs, nonTaglibXmlnsAttrs, 1291 taglibAttrs, start, parent); 1292 } 1293 1294 public void accept(Visitor v) throws JasperException { 1295 v.visit(this); 1296 } 1297 } 1298 1299 1303 public static class ChildInfo { 1304 private boolean scriptless; 1306 private boolean hasUseBean; 1308 1309 private boolean hasIncludeAction; 1310 1311 private boolean hasParamAction; 1312 1313 private boolean hasSetProperty; 1314 1315 private boolean hasScriptingVars; 1316 1317 public void setScriptless(boolean s) { 1318 scriptless = s; 1319 } 1320 1321 public boolean isScriptless() { 1322 return scriptless; 1323 } 1324 1325 public void setHasUseBean(boolean u) { 1326 hasUseBean = u; 1327 } 1328 1329 public boolean hasUseBean() { 1330 return hasUseBean; 1331 } 1332 1333 public void setHasIncludeAction(boolean i) { 1334 hasIncludeAction = i; 1335 } 1336 1337 public boolean hasIncludeAction() { 1338 return hasIncludeAction; 1339 } 1340 1341 public void setHasParamAction(boolean i) { 1342 hasParamAction = i; 1343 } 1344 1345 public boolean hasParamAction() { 1346 return hasParamAction; 1347 } 1348 1349 public void setHasSetProperty(boolean s) { 1350 hasSetProperty = s; 1351 } 1352 1353 public boolean hasSetProperty() { 1354 return hasSetProperty; 1355 } 1356 1357 public void setHasScriptingVars(boolean s) { 1358 hasScriptingVars = s; 1359 } 1360 1361 public boolean hasScriptingVars() { 1362 return hasScriptingVars; 1363 } 1364 } 1365 1366 1369 public static class CustomTag extends Node { 1370 1371 private String uri; 1372 1373 private String prefix; 1374 1375 private JspAttribute[] jspAttrs; 1376 1377 private TagData tagData; 1378 1379 private String tagHandlerPoolName; 1380 1381 private TagInfo tagInfo; 1382 1383 private TagFileInfo tagFileInfo; 1384 1385 private Class tagHandlerClass; 1386 1387 private VariableInfo [] varInfos; 1388 1389 private int customNestingLevel; 1390 1391 private ChildInfo childInfo; 1392 1393 private boolean implementsIterationTag; 1394 1395 private boolean implementsBodyTag; 1396 1397 private boolean implementsTryCatchFinally; 1398 1399 private boolean implementsJspIdConsumer; 1400 1401 private boolean implementsSimpleTag; 1402 1403 private boolean implementsDynamicAttributes; 1404 1405 private Vector atBeginScriptingVars; 1406 1407 private Vector atEndScriptingVars; 1408 1409 private Vector nestedScriptingVars; 1410 1411 private Node.CustomTag customTagParent; 1412 1413 private Integer numCount; 1414 1415 private boolean useTagPlugin; 1416 1417 private TagPluginContext tagPluginContext; 1418 1419 1425 private Nodes atSTag; 1426 1427 private Nodes atETag; 1428 1429 1432 public CustomTag(String qName, String prefix, String localName, 1433 String uri, Attributes attrs, Mark start, Node parent, 1434 TagInfo tagInfo, Class tagHandlerClass) { 1435 this(qName, prefix, localName, uri, attrs, null, null, start, 1436 parent, tagInfo, tagHandlerClass); 1437 } 1438 1439 1442 public CustomTag(String qName, String prefix, String localName, 1443 String uri, Attributes attrs, Attributes nonTaglibXmlnsAttrs, 1444 Attributes taglibAttrs, Mark start, Node parent, 1445 TagInfo tagInfo, Class tagHandlerClass) { 1446 super(qName, localName, attrs, nonTaglibXmlnsAttrs, taglibAttrs, 1447 start, parent); 1448 1449 this.uri = uri; 1450 this.prefix = prefix; 1451 this.tagInfo = tagInfo; 1452 this.tagHandlerClass = tagHandlerClass; 1453 this.customNestingLevel = makeCustomNestingLevel(); 1454 this.childInfo = new ChildInfo(); 1455 1456 this.implementsIterationTag = IterationTag .class 1457 .isAssignableFrom(tagHandlerClass); 1458 this.implementsBodyTag = BodyTag .class 1459 .isAssignableFrom(tagHandlerClass); 1460 this.implementsTryCatchFinally = TryCatchFinally .class 1461 .isAssignableFrom(tagHandlerClass); 1462 this.implementsSimpleTag = SimpleTag .class 1463 .isAssignableFrom(tagHandlerClass); 1464 this.implementsDynamicAttributes = DynamicAttributes .class 1465 .isAssignableFrom(tagHandlerClass); 1466 this.implementsJspIdConsumer = JspIdConsumer .class 1467 .isAssignableFrom(tagHandlerClass); 1468 } 1469 1470 1473 public CustomTag(String qName, String prefix, String localName, 1474 String uri, Attributes attrs, Mark start, Node parent, 1475 TagFileInfo tagFileInfo) { 1476 this(qName, prefix, localName, uri, attrs, null, null, start, 1477 parent, tagFileInfo); 1478 } 1479 1480 1483 public CustomTag(String qName, String prefix, String localName, 1484 String uri, Attributes attrs, Attributes nonTaglibXmlnsAttrs, 1485 Attributes taglibAttrs, Mark start, Node parent, 1486 TagFileInfo tagFileInfo) { 1487 1488 super(qName, localName, attrs, nonTaglibXmlnsAttrs, taglibAttrs, 1489 start, parent); 1490 1491 this.uri = uri; 1492 this.prefix = prefix; 1493 this.tagFileInfo = tagFileInfo; 1494 this.tagInfo = tagFileInfo.getTagInfo(); 1495 this.customNestingLevel = makeCustomNestingLevel(); 1496 this.childInfo = new ChildInfo(); 1497 1498 this.implementsIterationTag = false; 1499 this.implementsBodyTag = false; 1500 this.implementsTryCatchFinally = false; 1501 this.implementsSimpleTag = true; 1502 this.implementsJspIdConsumer = false; 1503 this.implementsDynamicAttributes = tagInfo.hasDynamicAttributes(); 1504 } 1505 1506 public void accept(Visitor v) throws JasperException { 1507 v.visit(this); 1508 } 1509 1510 1513 public String getURI() { 1514 return this.uri; 1515 } 1516 1517 1520 public String getPrefix() { 1521 return prefix; 1522 } 1523 1524 public void setJspAttributes(JspAttribute[] jspAttrs) { 1525 this.jspAttrs = jspAttrs; 1526 } 1527 1528 public TagAttributeInfo getTagAttributeInfo(String name) { 1529 TagInfo info = this.getTagInfo(); 1530 if (info == null) 1531 return null; 1532 TagAttributeInfo [] tai = info.getAttributes(); 1533 for (int i = 0; i < tai.length; i++) { 1534 if (tai[i].getName().equals(name)) { 1535 return tai[i]; 1536 } 1537 } 1538 return null; 1539 } 1540 1541 public JspAttribute[] getJspAttributes() { 1542 return jspAttrs; 1543 } 1544 1545 public ChildInfo getChildInfo() { 1546 return childInfo; 1547 } 1548 1549 public void setTagData(TagData tagData) { 1550 this.tagData = tagData; 1551 this.varInfos = tagInfo.getVariableInfo(tagData); 1552 if (this.varInfos == null) { 1553 this.varInfos = ZERO_VARIABLE_INFO; 1554 } 1555 } 1556 1557 public TagData getTagData() { 1558 return tagData; 1559 } 1560 1561 public void setTagHandlerPoolName(String s) { 1562 tagHandlerPoolName = s; 1563 } 1564 1565 public String getTagHandlerPoolName() { 1566 return tagHandlerPoolName; 1567 } 1568 1569 public TagInfo getTagInfo() { 1570 return tagInfo; 1571 } 1572 1573 public TagFileInfo getTagFileInfo() { 1574 return tagFileInfo; 1575 } 1576 1577 1581 public boolean isTagFile() { 1582 return tagFileInfo != null; 1583 } 1584 1585 public Class getTagHandlerClass() { 1586 return tagHandlerClass; 1587 } 1588 1589 public void setTagHandlerClass(Class hc) { 1590 tagHandlerClass = hc; 1591 } 1592 1593 public boolean implementsIterationTag() { 1594 return implementsIterationTag; 1595 } 1596 1597 public boolean implementsBodyTag() { 1598 return implementsBodyTag; 1599 } 1600 1601 public boolean implementsTryCatchFinally() { 1602 return implementsTryCatchFinally; 1603 } 1604 1605 public boolean implementsJspIdConsumer() { 1606 return implementsJspIdConsumer; 1607 } 1608 1609 public boolean implementsSimpleTag() { 1610 return implementsSimpleTag; 1611 } 1612 1613 public boolean implementsDynamicAttributes() { 1614 return implementsDynamicAttributes; 1615 } 1616 1617 public TagVariableInfo [] getTagVariableInfos() { 1618 return tagInfo.getTagVariableInfos(); 1619 } 1620 1621 public VariableInfo [] getVariableInfos() { 1622 return varInfos; 1623 } 1624 1625 public void setCustomTagParent(Node.CustomTag n) { 1626 this.customTagParent = n; 1627 } 1628 1629 public Node.CustomTag getCustomTagParent() { 1630 return this.customTagParent; 1631 } 1632 1633 public void setNumCount(Integer count) { 1634 this.numCount = count; 1635 } 1636 1637 public Integer getNumCount() { 1638 return this.numCount; 1639 } 1640 1641 public void setScriptingVars(Vector vec, int scope) { 1642 switch (scope) { 1643 case VariableInfo.AT_BEGIN: 1644 this.atBeginScriptingVars = vec; 1645 break; 1646 case VariableInfo.AT_END: 1647 this.atEndScriptingVars = vec; 1648 break; 1649 case VariableInfo.NESTED: 1650 this.nestedScriptingVars = vec; 1651 break; 1652 } 1653 } 1654 1655 1659 public Vector getScriptingVars(int scope) { 1660 Vector vec = null; 1661 1662 switch (scope) { 1663 case VariableInfo.AT_BEGIN: 1664 vec = this.atBeginScriptingVars; 1665 break; 1666 case VariableInfo.AT_END: 1667 vec = this.atEndScriptingVars; 1668 break; 1669 case VariableInfo.NESTED: 1670 vec = this.nestedScriptingVars; 1671 break; 1672 } 1673 1674 return vec; 1675 } 1676 1677 1681 public int getCustomNestingLevel() { 1682 return customNestingLevel; 1683 } 1684 1685 1689 public boolean checkIfAttributeIsJspFragment(String name) { 1690 boolean result = false; 1691 1692 TagAttributeInfo [] attributes = tagInfo.getAttributes(); 1693 for (int i = 0; i < attributes.length; i++) { 1694 if (attributes[i].getName().equals(name) 1695 && attributes[i].isFragment()) { 1696 result = true; 1697 break; 1698 } 1699 } 1700 1701 return result; 1702 } 1703 1704 public void setUseTagPlugin(boolean use) { 1705 useTagPlugin = use; 1706 } 1707 1708 public boolean useTagPlugin() { 1709 return useTagPlugin; 1710 } 1711 1712 public void setTagPluginContext(TagPluginContext tagPluginContext) { 1713 this.tagPluginContext = tagPluginContext; 1714 } 1715 1716 public TagPluginContext getTagPluginContext() { 1717 return tagPluginContext; 1718 } 1719 1720 public void setAtSTag(Nodes sTag) { 1721 atSTag = sTag; 1722 } 1723 1724 public Nodes getAtSTag() { 1725 return atSTag; 1726 } 1727 1728 public void setAtETag(Nodes eTag) { 1729 atETag = eTag; 1730 } 1731 1732 public Nodes getAtETag() { 1733 return atETag; 1734 } 1735 1736 1748 private int makeCustomNestingLevel() { 1749 int n = 0; 1750 Node p = parent; 1751 while (p != null) { 1752 if ((p instanceof Node.CustomTag) 1753 && qName.equals(((Node.CustomTag) p).qName)) { 1754 n++; 1755 } 1756 p = p.parent; 1757 } 1758 return n; 1759 } 1760 1761 1769 public boolean hasEmptyBody() { 1770 boolean hasEmptyBody = true; 1771 Nodes nodes = getBody(); 1772 if (nodes != null) { 1773 int numChildNodes = nodes.size(); 1774 for (int i = 0; i < numChildNodes; i++) { 1775 Node n = nodes.getNode(i); 1776 if (!(n instanceof NamedAttribute)) { 1777 if (n instanceof JspBody) { 1778 hasEmptyBody = (n.getBody() == null); 1779 } else { 1780 hasEmptyBody = false; 1781 } 1782 break; 1783 } 1784 } 1785 } 1786 1787 return hasEmptyBody; 1788 } 1789 } 1790 1791 1795 public static class AttributeGenerator extends Node { 1796 String name; 1798 CustomTag tag; 1800 public AttributeGenerator(Mark start, String name, CustomTag tag) { 1801 super(start, null); 1802 this.name = name; 1803 this.tag = tag; 1804 } 1805 1806 public void accept(Visitor v) throws JasperException { 1807 v.visit(this); 1808 } 1809 1810 public String getName() { 1811 return name; 1812 } 1813 1814 public CustomTag getTag() { 1815 return tag; 1816 } 1817 } 1818 1819 1822 public static class JspText extends Node { 1823 1824 public JspText(String qName, Attributes nonTaglibXmlnsAttrs, 1825 Attributes taglibAttrs, Mark start, Node parent) { 1826 super(qName, TEXT_ACTION, null, nonTaglibXmlnsAttrs, taglibAttrs, 1827 start, parent); 1828 } 1829 1830 public void accept(Visitor v) throws JasperException { 1831 v.visit(this); 1832 } 1833 } 1834 1835 1838 public static class NamedAttribute extends Node { 1839 1840 private String temporaryVariableName; 1842 1843 private boolean trim = true; 1845 1846 private ChildInfo childInfo; 1847 1848 private String name; 1849 1850 private String localName; 1851 1852 private String prefix; 1853 1854 public NamedAttribute(Attributes attrs, Mark start, Node parent) { 1855 this(JSP_ATTRIBUTE_ACTION, attrs, null, null, start, parent); 1856 } 1857 1858 public NamedAttribute(String qName, Attributes attrs, 1859 Attributes nonTaglibXmlnsAttrs, Attributes taglibAttrs, 1860 Mark start, Node parent) { 1861 1862 super(qName, ATTRIBUTE_ACTION, attrs, nonTaglibXmlnsAttrs, 1863 taglibAttrs, start, parent); 1864 temporaryVariableName = JspUtil.nextTemporaryVariableName(); 1865 if ("false".equals(this.getAttributeValue("trim"))) { 1866 trim = false; 1868 } 1869 childInfo = new ChildInfo(); 1870 name = this.getAttributeValue("name"); 1871 if (name != null) { 1872 localName = name; 1874 int index = name.indexOf(':'); 1875 if (index != -1) { 1876 prefix = name.substring(0, index); 1877 localName = name.substring(index + 1); 1878 } 1879 } 1880 } 1881 1882 public void accept(Visitor v) throws JasperException { 1883 v.visit(this); 1884 } 1885 1886 public String getName() { 1887 return this.name; 1888 } 1889 1890 public String getLocalName() { 1891 return this.localName; 1892 } 1893 1894 public String getPrefix() { 1895 return this.prefix; 1896 } 1897 1898 public ChildInfo getChildInfo() { 1899 return this.childInfo; 1900 } 1901 1902 public boolean isTrim() { 1903 return trim; 1904 } 1905 1906 1910 public String getTemporaryVariableName() { 1911 return temporaryVariableName; 1912 } 1913 1914 1919 public String getText() { 1920 1921 class AttributeVisitor extends Visitor { 1922 String attrValue = null; 1923 1924 public void visit(TemplateText txt) { 1925 attrValue = new String (txt.getText()); 1926 } 1927 1928 public String getAttrValue() { 1929 return attrValue; 1930 } 1931 } 1932 1933 String text = ""; 1937 if (getBody() != null) { 1938 AttributeVisitor attributeVisitor = new AttributeVisitor(); 1939 try { 1940 getBody().visit(attributeVisitor); 1941 } catch (JasperException e) { 1942 } 1943 text = attributeVisitor.getAttrValue(); 1944 } 1945 1946 return text; 1947 } 1948 } 1949 1950 1953 public static class JspBody extends Node { 1954 1955 private ChildInfo childInfo; 1956 1957 public JspBody(Mark start, Node parent) { 1958 this(JSP_BODY_ACTION, null, null, start, parent); 1959 } 1960 1961 public JspBody(String qName, Attributes nonTaglibXmlnsAttrs, 1962 Attributes taglibAttrs, Mark start, Node parent) { 1963 super(qName, BODY_ACTION, null, nonTaglibXmlnsAttrs, taglibAttrs, 1964 start, parent); 1965 this.childInfo = new ChildInfo(); 1966 } 1967 1968 public void accept(Visitor v) throws JasperException { 1969 v.visit(this); 1970 } 1971 1972 public ChildInfo getChildInfo() { 1973 return childInfo; 1974 } 1975 } 1976 1977 1980 public static class TemplateText extends Node { 1981 1982 private ArrayList extraSmap = null; 1983 1984 public TemplateText(String text, Mark start, Node parent) { 1985 super(null, null, text, start, parent); 1986 } 1987 1988 public void accept(Visitor v) throws JasperException { 1989 v.visit(this); 1990 } 1991 1992 1995 public void ltrim() { 1996 int index = 0; 1997 while ((index < text.length()) && (text.charAt(index) <= ' ')) { 1998 index++; 1999 } 2000 text = text.substring(index); 2001 } 2002 2003 public void setText(String text) { 2004 this.text = text; 2005 } 2006 2007 2010 public void rtrim() { 2011 int index = text.length(); 2012 while ((index > 0) && (text.charAt(index - 1) <= ' ')) { 2013 index--; 2014 } 2015 text = text.substring(0, index); 2016 } 2017 2018 2021 public boolean isAllSpace() { 2022 boolean isAllSpace = true; 2023 for (int i = 0; i < text.length(); i++) { 2024 if (!Character.isWhitespace(text.charAt(i))) { 2025 isAllSpace = false; 2026 break; 2027 } 2028 } 2029 return isAllSpace; 2030 } 2031 2032 2040 public void addSmap(int srcLine) { 2041 if (extraSmap == null) { 2042 extraSmap = new ArrayList (); 2043 } 2044 extraSmap.add(new Integer (srcLine)); 2045 } 2046 2047 public ArrayList getExtraSmap() { 2048 return extraSmap; 2049 } 2050 } 2051 2052 2055 2056 2063 2064 public static class JspAttribute { 2065 2066 private String qName; 2067 2068 private String uri; 2069 2070 private String localName; 2071 2072 private String value; 2073 2074 private boolean expression; 2075 2076 private boolean dynamic; 2077 2078 private final ELNode.Nodes el; 2079 2080 private final TagAttributeInfo tai; 2081 2082 private boolean namedAttribute; 2084 2085 private NamedAttribute namedAttributeNode; 2087 2088 JspAttribute(TagAttributeInfo tai, String qName, String uri, 2089 String localName, String value, boolean expr, ELNode.Nodes el, 2090 boolean dyn) { 2091 this.qName = qName; 2092 this.uri = uri; 2093 this.localName = localName; 2094 this.value = value; 2095 this.namedAttributeNode = null; 2096 this.expression = expr; 2097 this.el = el; 2098 this.dynamic = dyn; 2099 this.namedAttribute = false; 2100 this.tai = tai; 2101 } 2102 2103 2110 public void validateEL(ExpressionFactory ef, ELContext ctx) 2111 throws ELException { 2112 if (this.el != null) { 2113 ValueExpression ve = ef.createValueExpression(ctx, this.value, 2115 String .class); 2116 } 2117 } 2118 2119 2124 JspAttribute(NamedAttribute na, TagAttributeInfo tai, boolean dyn) { 2125 this.qName = na.getName(); 2126 this.localName = na.getLocalName(); 2127 this.value = null; 2128 this.namedAttributeNode = na; 2129 this.expression = false; 2130 this.el = null; 2131 this.dynamic = dyn; 2132 this.namedAttribute = true; 2133 this.tai = null; 2134 } 2135 2136 2139 public String getName() { 2140 return qName; 2141 } 2142 2143 2146 public String getLocalName() { 2147 return localName; 2148 } 2149 2150 2154 public String getURI() { 2155 return uri; 2156 } 2157 2158 public TagAttributeInfo getTagAttributeInfo() { 2159 return this.tai; 2160 } 2161 2162 2167 public boolean isDeferredInput() { 2168 return (this.tai != null) ? this.tai.isDeferredValue() : false; 2169 } 2170 2171 2176 public boolean isDeferredMethodInput() { 2177 return (this.tai != null) ? this.tai.isDeferredMethod() : false; 2178 } 2179 2180 public String getExpectedTypeName() { 2181 if (this.tai != null) { 2182 if (this.isDeferredInput()) { 2183 return this.tai.getExpectedTypeName(); 2184 } else if (this.isDeferredMethodInput()) { 2185 String m = this.tai.getMethodSignature(); 2186 if (m != null) { 2187 int rti = m.trim().indexOf(' '); 2188 if (rti > 0) { 2189 return m.substring(0, rti).trim(); 2190 } 2191 } 2192 } 2193 } 2194 return "java.lang.Object"; 2195 } 2196 2197 public String [] getParameterTypeNames() { 2198 if (this.tai != null) { 2199 if (this.isDeferredMethodInput()) { 2200 String m = this.tai.getMethodSignature(); 2201 if (m != null) { 2202 m = m.trim(); 2203 m = m.substring(m.indexOf('(') + 1); 2204 m = m.substring(0, m.length() - 1); 2205 if (m.trim().length() > 0) { 2206 String [] p = m.split(","); 2207 for (int i = 0; i < p.length; i++) { 2208 p[i] = p[i].trim(); 2209 } 2210 return p; 2211 } 2212 } 2213 } 2214 } 2215 return new String [0]; 2216 } 2217 2218 2225 public String getValue() { 2226 return value; 2227 } 2228 2229 2234 public NamedAttribute getNamedAttributeNode() { 2235 return namedAttributeNode; 2236 } 2237 2238 2241 public boolean isExpression() { 2242 return expression; 2243 } 2244 2245 2248 public boolean isNamedAttribute() { 2249 return namedAttribute; 2250 } 2251 2252 2258 public boolean isELInterpreterInput() { 2259 return el != null || this.isDeferredInput() 2260 || this.isDeferredMethodInput(); 2261 } 2262 2263 2267 public boolean isLiteral() { 2268 return !expression && (el != null) && !namedAttribute; 2269 } 2270 2271 2274 public boolean isDynamic() { 2275 return dynamic; 2276 } 2277 2278 public ELNode.Nodes getEL() { 2279 return el; 2280 } 2281 } 2282 2283 2287 public static class Nodes { 2288 2289 private List list; 2290 2291 private Node.Root root; 2293 private boolean generatedInBuffer; 2294 2295 public Nodes() { 2296 list = new Vector (); 2297 } 2298 2299 public Nodes(Node.Root root) { 2300 this.root = root; 2301 list = new Vector (); 2302 list.add(root); 2303 } 2304 2305 2311 public void add(Node n) { 2312 list.add(n); 2313 root = null; 2314 } 2315 2316 2322 public void remove(Node n) { 2323 list.remove(n); 2324 } 2325 2326 2332 public void visit(Visitor v) throws JasperException { 2333 Iterator iter = list.iterator(); 2334 while (iter.hasNext()) { 2335 Node n = (Node) iter.next(); 2336 n.accept(v); 2337 } 2338 } 2339 2340 public int size() { 2341 return list.size(); 2342 } 2343 2344 public Node getNode(int index) { 2345 Node n = null; 2346 try { 2347 n = (Node) list.get(index); 2348 } catch (ArrayIndexOutOfBoundsException e) { 2349 } 2350 return n; 2351 } 2352 2353 public Node.Root getRoot() { 2354 return root; 2355 } 2356 2357 public boolean isGeneratedInBuffer() { 2358 return generatedInBuffer; 2359 } 2360 2361 public void setGeneratedInBuffer(boolean g) { 2362 generatedInBuffer = g; 2363 } 2364 } 2365 2366 2372 public static class Visitor { 2373 2374 2378 protected void doVisit(Node n) throws JasperException { 2379 } 2380 2381 2384 protected void visitBody(Node n) throws JasperException { 2385 if (n.getBody() != null) { 2386 n.getBody().visit(this); 2387 } 2388 } 2389 2390 public void visit(Root n) throws JasperException { 2391 doVisit(n); 2392 visitBody(n); 2393 } 2394 2395 public void visit(JspRoot n) throws JasperException { 2396 doVisit(n); 2397 visitBody(n); 2398 } 2399 2400 public void visit(PageDirective n) throws JasperException { 2401 doVisit(n); 2402 } 2403 2404 public void visit(TagDirective n) throws JasperException { 2405 doVisit(n); 2406 } 2407 2408 public void visit(IncludeDirective n) throws JasperException { 2409 doVisit(n); 2410 visitBody(n); 2411 } 2412 2413 public void visit(TaglibDirective n) throws JasperException { 2414 doVisit(n); 2415 } 2416 2417 public void visit(AttributeDirective n) throws JasperException { 2418 doVisit(n); 2419 } 2420 2421 public void visit(VariableDirective n) throws JasperException { 2422 doVisit(n); 2423 } 2424 2425 public void visit(Comment n) throws JasperException { 2426 doVisit(n); 2427 } 2428 2429 public void visit(Declaration n) throws JasperException { 2430 doVisit(n); 2431 } 2432 2433 public void visit(Expression n) throws JasperException { 2434 doVisit(n); 2435 } 2436 2437 public void visit(Scriptlet n) throws JasperException { 2438 doVisit(n); 2439 } 2440 2441 public void visit(ELExpression n) throws JasperException { 2442 doVisit(n); 2443 } 2444 2445 public void visit(IncludeAction n) throws JasperException { 2446 doVisit(n); 2447 visitBody(n); 2448 } 2449 2450 public void visit(ForwardAction n) throws JasperException { 2451 doVisit(n); 2452 visitBody(n); 2453 } 2454 2455 public void visit(GetProperty n) throws JasperException { 2456 doVisit(n); 2457 visitBody(n); 2458 } 2459 2460 public void visit(SetProperty n) throws JasperException { 2461 doVisit(n); 2462 visitBody(n); 2463 } 2464 2465 public void visit(ParamAction n) throws JasperException { 2466 doVisit(n); 2467 visitBody(n); 2468 } 2469 2470 public void visit(ParamsAction n) throws JasperException { 2471 doVisit(n); 2472 visitBody(n); 2473 } 2474 2475 public void visit(FallBackAction n) throws JasperException { 2476 doVisit(n); 2477 visitBody(n); 2478 } 2479 2480 public void visit(UseBean n) throws JasperException { 2481 doVisit(n); 2482 visitBody(n); 2483 } 2484 2485 public void visit(PlugIn n) throws JasperException { 2486 doVisit(n); 2487 visitBody(n); 2488 } 2489 2490 public void visit(CustomTag n) throws JasperException { 2491 doVisit(n); 2492 visitBody(n); 2493 } 2494 2495 public void visit(UninterpretedTag n) throws JasperException { 2496 doVisit(n); 2497 visitBody(n); 2498 } 2499 2500 public void visit(JspElement n) throws JasperException { 2501 doVisit(n); 2502 visitBody(n); 2503 } 2504 2505 public void visit(JspText n) throws JasperException { 2506 doVisit(n); 2507 visitBody(n); 2508 } 2509 2510 public void visit(NamedAttribute n) throws JasperException { 2511 doVisit(n); 2512 visitBody(n); 2513 } 2514 2515 public void visit(JspBody n) throws JasperException { 2516 doVisit(n); 2517 visitBody(n); 2518 } 2519 2520 public void visit(InvokeAction n) throws JasperException { 2521 doVisit(n); 2522 visitBody(n); 2523 } 2524 2525 public void visit(DoBodyAction n) throws JasperException { 2526 doVisit(n); 2527 visitBody(n); 2528 } 2529 2530 public void visit(TemplateText n) throws JasperException { 2531 doVisit(n); 2532 } 2533 2534 public void visit(JspOutput n) throws JasperException { 2535 doVisit(n); 2536 } 2537 2538 public void visit(AttributeGenerator n) throws JasperException { 2539 doVisit(n); 2540 } 2541 } 2542} 2543 | Popular Tags |