tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lu...@apache.org
Subject cvs commit: jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler JspDocumentParser.java
Date Tue, 22 Apr 2003 03:00:04 GMT
luehe       2003/04/21 20:00:03

  Modified:    jasper2/src/share/org/apache/jasper/compiler
                        JspDocumentParser.java
  Log:
  Avoid calling Attributes.removeAttribute
  
  Revision  Changes    Path
  1.57      +49 -15    jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/JspDocumentParser.java
  
  Index: JspDocumentParser.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/JspDocumentParser.java,v
  retrieving revision 1.56
  retrieving revision 1.57
  diff -u -r1.56 -r1.57
  --- JspDocumentParser.java	21 Apr 2003 23:26:50 -0000	1.56
  +++ JspDocumentParser.java	22 Apr 2003 03:00:02 -0000	1.57
  @@ -237,12 +237,12 @@
   	// is valid from that point forward.  Redefinitions cause an
   	// error.  This isn't quite consistent with how xmlns: normally
   	// works.
  -	AttributesImpl attrsCopy = null;
  -	Attributes xmlnsAttrs = null;
  +	Attributes taglibAttrs = null;
  +	Attributes nonTaglibAttrs = null;
   	if (attrs != null) {
  -	    attrsCopy = new AttributesImpl(attrs);
   	    try {
  -		xmlnsAttrs = addTagLibraries(attrsCopy);
  +		taglibAttrs = addTagLibraries(attrs);
  +		nonTaglibAttrs = filterTaglibAttributes(attrs, taglibAttrs);
   	    } catch (JasperException je) {
   		    throw new SAXParseException(Localizer.getMessage(
                                       "jsp.error.could.not.add.taglibraries"),
  @@ -253,14 +253,15 @@
   	Node node = null;
   
   	if ("http://java.sun.com/JSP/Page".equals(uri)) {
  -	    node = parseStandardAction(qName, localName, attrsCopy, xmlnsAttrs,
  -				       start, current);
  +	    node = parseStandardAction(qName, localName, nonTaglibAttrs,
  +				       taglibAttrs, start, current);
   	} else {
  -	    node = parseCustomAction(qName, localName, uri, attrsCopy,
  -				     xmlnsAttrs, start, current);
  +	    node = parseCustomAction(qName, localName, uri, nonTaglibAttrs,
  +				     taglibAttrs, start, current);
   	    if (node == null) {
  -		node = new Node.UninterpretedTag(qName, localName, attrsCopy,
  -						 xmlnsAttrs, start, current);
  +		node = new Node.UninterpretedTag(qName, localName,
  +						 nonTaglibAttrs, taglibAttrs,
  +						 start, current);
   	    }
   	}
   
  @@ -635,6 +636,40 @@
       }
   
       /*
  +     * Filters, from the given attrs, all the attributes that are not
  +     * contained in taglibAttrs, and returns them.
  +     *
  +     * @param attrs The total set of attributes
  +     * @param taglibAttrs The set of attributes in attrs that represent a tag
  +     * library
  +     *
  +     * @param The set of attributes in attrs that do not represent a tag
  +     * library
  +     */
  +    private Attributes filterTaglibAttributes(Attributes attrs,
  +					      Attributes taglibAttrs) {
  +	AttributesImpl ret = null;
  +
  +	if (taglibAttrs == null) {
  +	    ret = new AttributesImpl(attrs);
  +	} else {
  +	    for (int i=attrs.getLength()-1; i>=0; i--) {
  +		if (taglibAttrs.getValue(attrs.getURI(i),
  +					 attrs.getLocalName(i)) == null) {
  +		    if (ret == null) {
  +			ret = new AttributesImpl();
  +		    }
  +		    ret.addAttribute(attrs.getURI(i), attrs.getLocalName(i),
  +				     attrs.getQName(i), attrs.getType(i),
  +				     attrs.getValue(i));
  +		}
  +	    }
  +	}
  +
  +	return ret;
  +    }
  +
  +    /*
        * Checks if the XML element with the given tag name is a custom action,
        * and returns the corresponding Node object.
        */
  @@ -703,7 +738,7 @@
        * @return The set of xmlns attributes (extracted from the given attrs)
        * representing standard or custom tag libraries, or null
        */
  -    private Attributes addTagLibraries(AttributesImpl attrs)
  +    private Attributes addTagLibraries(Attributes attrs)
   	    throws JasperException 
       {
   	AttributesImpl result = null;
  @@ -739,7 +774,6 @@
   		    result.addAttribute(attrs.getURI(i), attrs.getLocalName(i),
   					attrs.getQName(i), attrs.getType(i),
   					attrs.getValue(i));
  -		    attrs.removeAttribute(i);
   		}
   	    }
   	}
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org


Mime
View raw message