You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by lu...@apache.org on 2002/08/02 21:30:02 UTC

cvs commit: jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler Generator.java TagFileProcessor.java Validator.java

luehe       2002/08/02 12:30:02

  Modified:    jasper2/src/share/org/apache/jasper/compiler Generator.java
                        TagFileProcessor.java Validator.java
  Log:
  - Validate tag file directives only once (at the time when the
    TagFileProcessor creates a TagInfo from them), and not again when compiling
    the tag file
  
  - Fixed compilation error for tag handler generated from tag file
    supporting dynamic attributes
  
  Revision  Changes    Path
  1.59      +8 -8      jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/Generator.java
  
  Index: Generator.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/Generator.java,v
  retrieving revision 1.58
  retrieving revision 1.59
  diff -u -r1.58 -r1.59
  --- Generator.java	2 Aug 2002 16:30:59 -0000	1.58
  +++ Generator.java	2 Aug 2002 19:30:02 -0000	1.59
  @@ -2823,7 +2823,7 @@
   	        throws JasperException {
   
   	if (tagInfo.hasDynamicAttributes()) {
  -	    out.printil("HashMap dynamicAttrs = new java.util.HashMap();");
  +	    out.printil("java.util.HashMap dynamicAttrs = new java.util.HashMap();");
   	}
   
   	TagAttributeInfo[] attrInfos = tagInfo.getAttributes();
  @@ -2924,7 +2924,7 @@
        * variable can later be created for it.
        */
       public void generateSetDynamicAttribute() {
  -        out.printil("public void setDynamicAttribute(String uri, String localName, Object value) throws AttributeNotSupportedException {");
  +        out.printil("public void setDynamicAttribute(String uri, String localName, Object value) throws javax.servlet.jsp.tagext.AttributeNotSupportedException {");
   	out.pushIndent();
   	out.printil("if (uri != null)");
   	out.pushIndent();
  @@ -2976,10 +2976,10 @@
   
   	// dynamic attributes
   	if (tagInfo.hasDynamicAttributes()) {
  -	    out.printil("for (Iterator i = dynamicAttrs.entrySet().iterator(); i.hasNext(); ) {");
  +	    out.printil("for (java.util.Iterator i = dynamicAttrs.entrySet().iterator(); i.hasNext(); ) {");
   	    out.pushIndent();
  -	    out.printil("Map.Entry e = (Map.Entry) i.next();");
  -	    out.printil("getJspContext().setAttribute(e.getKey(), e.getValue());");
  +	    out.printil("java.util.Map.Entry e = (java.util.Map.Entry) i.next();");
  +	    out.printil("getJspContext().setAttribute((String) e.getKey(), e.getValue());");
   	    out.popIndent();
   	    out.printil("}");
   	}
  
  
  
  1.8       +41 -42    jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/TagFileProcessor.java
  
  Index: TagFileProcessor.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/TagFileProcessor.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- TagFileProcessor.java	1 Aug 2002 22:26:50 -0000	1.7
  +++ TagFileProcessor.java	2 Aug 2002 19:30:02 -0000	1.8
  @@ -86,6 +86,43 @@
        */
       static class TagFileVisitor extends Node.Visitor {
   
  +        private static final JspUtil.ValidAttribute[] tagDirectiveAttrs = {
  +            new JspUtil.ValidAttribute("name"),
  +            new JspUtil.ValidAttribute("display-name"),
  +            new JspUtil.ValidAttribute("body-content"),
  +            new JspUtil.ValidAttribute("dynamic-attributes"),
  +            new JspUtil.ValidAttribute("small-icon"),
  +            new JspUtil.ValidAttribute("large-icon"),
  +            new JspUtil.ValidAttribute("description"),
  +            new JspUtil.ValidAttribute("example"),
  +            new JspUtil.ValidAttribute("pageEncoding") };
  +
  +	private static final JspUtil.ValidAttribute[] attributeDirectiveAttrs = {
  +	    new JspUtil.ValidAttribute("name", true),
  +	    new JspUtil.ValidAttribute("required"),
  +	    new JspUtil.ValidAttribute("fragment"),
  +	    new JspUtil.ValidAttribute("rtexprvalue"),
  +	    new JspUtil.ValidAttribute("type"),
  +	    new JspUtil.ValidAttribute("description")
  +	};
  +
  +	private static final JspUtil.ValidAttribute[] variableDirectiveAttrs = {
  +	    new JspUtil.ValidAttribute("name-given"),
  +	    new JspUtil.ValidAttribute("name-from"),
  +	    new JspUtil.ValidAttribute("variable-class"),
  +	    new JspUtil.ValidAttribute("scope"),
  +	    new JspUtil.ValidAttribute("declare"),
  +	    new JspUtil.ValidAttribute("description")
  +	};
  +
  +	private static final JspUtil.ValidAttribute[] fragmentInputDirectiveAttrs = {
  +	    new JspUtil.ValidAttribute("name", true),
  +	    new JspUtil.ValidAttribute("fragment", true),
  +	    new JspUtil.ValidAttribute("required"),
  +	    new JspUtil.ValidAttribute("type"),
  +	    new JspUtil.ValidAttribute("description")
  +	};
  +
           private ErrorDispatcher err;
   	private TagLibraryInfo tagLibInfo;
   
  @@ -104,44 +141,6 @@
           private Vector fragmentAttributeVector = new Vector();
           private Map fragmentAttributesMap = new Hashtable();
   
  -        private static final JspUtil.ValidAttribute[] tagDirectiveAttrs = {
  -            new JspUtil.ValidAttribute("name"),
  -            new JspUtil.ValidAttribute("display-name"),
  -            new JspUtil.ValidAttribute("body-content"),
  -            new JspUtil.ValidAttribute("dynamic-attributes"),
  -            new JspUtil.ValidAttribute("small-icon"),
  -            new JspUtil.ValidAttribute("large-icon"),
  -            new JspUtil.ValidAttribute("description"),
  -            new JspUtil.ValidAttribute("example"),
  -            new JspUtil.ValidAttribute("pageEncoding") };
  -
  -        private static final JspUtil.ValidAttribute[] attributeDirectiveAttrs =
  -{
  -            new JspUtil.ValidAttribute("name", true),
  -            new JspUtil.ValidAttribute("required"),
  -            new JspUtil.ValidAttribute("fragment"),
  -            new JspUtil.ValidAttribute("rtexprvalue"),
  -            new JspUtil.ValidAttribute("type"),
  -            new JspUtil.ValidAttribute("description")
  -        };
  -
  -        private static final JspUtil.ValidAttribute[] variableDirectiveAttrs = {
  -            new JspUtil.ValidAttribute("name-given"),
  -            new JspUtil.ValidAttribute("name-from"),
  -            new JspUtil.ValidAttribute("variable-class"),
  -            new JspUtil.ValidAttribute("scope"),
  -            new JspUtil.ValidAttribute("declare"),
  -            new JspUtil.ValidAttribute("description")
  -        };
  -
  -        private static final JspUtil.ValidAttribute[] fragmentInputDirectiveAttrs = {
  -            new JspUtil.ValidAttribute("name", true),
  -            new JspUtil.ValidAttribute("fragment", true),
  -            new JspUtil.ValidAttribute("required"),
  -            new JspUtil.ValidAttribute("type"),
  -            new JspUtil.ValidAttribute("description")
  -        };
  -
           public TagFileVisitor(Compiler compiler, TagLibraryInfo tagLibInfo) {
               err = compiler.getErrorDispatcher();
   	    this.tagLibInfo = tagLibInfo;
  @@ -149,8 +148,8 @@
   
           public void visit(Node.TagDirective n) throws JasperException {
   
  -            JspUtil.checkAttributes("Tag directive", n,
  -                                    tagDirectiveAttrs, err);
  +            JspUtil.checkAttributes("Tag directive", n, tagDirectiveAttrs,
  +				    err);
   
   	    String tname = n.getAttributeValue("name");
   	    if (tname != null && name != null && !tname.equals(name)) {
  
  
  
  1.18      +19 -49    jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/Validator.java
  
  Index: Validator.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/Validator.java,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- Validator.java	1 Aug 2002 21:17:58 -0000	1.17
  +++ Validator.java	2 Aug 2002 19:30:02 -0000	1.18
  @@ -111,42 +111,7 @@
   	    new JspUtil.ValidAttribute("isErrorPage"),
   	    new JspUtil.ValidAttribute("contentType"),
   	    new JspUtil.ValidAttribute("pageEncoding"),
  -	    new JspUtil.ValidAttribute("isScriptingEnabled") };
  -
  -	private static final JspUtil.ValidAttribute[] tagDirectiveAttrs = {
  -	    new JspUtil.ValidAttribute("name"),
  -	    new JspUtil.ValidAttribute("dispaly-name"),
  -	    new JspUtil.ValidAttribute("body-content"),
  -	    new JspUtil.ValidAttribute("small-icon"),
  -	    new JspUtil.ValidAttribute("large-icon"),
  -	    new JspUtil.ValidAttribute("description"),
  -	    new JspUtil.ValidAttribute("example"),
  -	    new JspUtil.ValidAttribute("pageEncoding") };
  -
  -	private static final JspUtil.ValidAttribute[] attributeDirectiveAttrs = {
  -	    new JspUtil.ValidAttribute("name", true),
  -	    new JspUtil.ValidAttribute("required"),
  -	    new JspUtil.ValidAttribute("fragment"),
  -	    new JspUtil.ValidAttribute("rtexprvalue"),
  -	    new JspUtil.ValidAttribute("type"),
  -	    new JspUtil.ValidAttribute("description")
  -	};
  -
  -	private static final JspUtil.ValidAttribute[] variableDirectiveAttrs = {
  -	    new JspUtil.ValidAttribute("name-given"),
  -	    new JspUtil.ValidAttribute("name-from"),
  -	    new JspUtil.ValidAttribute("variable-class"),
  -	    new JspUtil.ValidAttribute("scope"),
  -	    new JspUtil.ValidAttribute("declare"),
  -	    new JspUtil.ValidAttribute("description")
  -	};
  -
  -	private static final JspUtil.ValidAttribute[] fragmentInputDirectiveAttrs = {
  -	    new JspUtil.ValidAttribute("name", true),
  -	    new JspUtil.ValidAttribute("fragment", true),
  -	    new JspUtil.ValidAttribute("required"),
  -	    new JspUtil.ValidAttribute("type"),
  -	    new JspUtil.ValidAttribute("description")
  +	    new JspUtil.ValidAttribute("isScriptingEnabled")
   	};
   
   	private boolean languageSeen = false;
  @@ -298,24 +263,29 @@
   	    pageInfo.addImports(n.getImports());
   	}
   
  -	public void visit(Node.TagDirective n) throws JasperException {    
  -            JspUtil.checkAttributes("Tag directive", n,
  -                                    tagDirectiveAttrs, err);
  +	public void visit(Node.TagDirective n) throws JasperException {
  +	    // Do nothing, since this tag directive has already been validated
  +	    // by TagFileProcessor when it created a TagInfo object from the
  +	    // tag file in which the directive appeared
   	}
   
   	public void visit(Node.AttributeDirective n) throws JasperException {
  -            JspUtil.checkAttributes("Attribute directive", n,
  -                                    attributeDirectiveAttrs, err);
  +	    // Do nothing, since this attribute directive has already been
  +	    // validated by TagFileProcessor when it created a TagInfo object
  +	    // from the tag file in which the directive appeared
   	}
   
   	public void visit(Node.VariableDirective n) throws JasperException {
  -            JspUtil.checkAttributes("Variable directive", n,
  -                                    variableDirectiveAttrs, err);
  +	    // Do nothing, since this variable directive has already been
  +	    // validated by TagFileProcessor when it created a TagInfo object
  +	    // from the tag file in which the directive appeared
   	}
   
  -	public void visit(Node.FragmentInputDirective n) throws JasperException{
  -            JspUtil.checkAttributes("Fragment-input directive", n,
  -                                    fragmentInputDirectiveAttrs, err);
  +	public void visit(Node.FragmentInputDirective n)
  +	        throws JasperException {
  +	    // Do nothing, since this fragment-input directive has already been
  +	    // validated by TagFileProcessor when it created a TagInfo object
  +	    // from the tag file in which the directive appeared
   	}
       }
   
  
  
  

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>