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 Collector.java Generator.java Node.java Parser.java ScriptingVariabler.java TagFileProcessor.java TagLibraryInfoImpl.java Validator.java
Date Wed, 30 Oct 2002 17:41:23 GMT
luehe       2002/10/30 09:41:23

  Modified:    jasper2/src/share/org/apache/jasper/compiler Collector.java
                        Generator.java Node.java Parser.java
                        ScriptingVariabler.java TagFileProcessor.java
                        TagLibraryInfoImpl.java Validator.java
  Log:
  Adapted implementation to API clarifications:
  
  - TagInfo.getAttributes() must return zero-length array if no attributes.
  
  - TagInfo.getTagVariableInfos() must return zero-length array
    if no variables have been delcared.
  
  - TagInfo.getVariableInfo() may return null or zero-length array if
    associated TagExtraInfo defines no variables
  
  Revision  Changes    Path
  1.7       +4 -8      jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/Collector.java
  
  Index: Collector.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/Collector.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- Collector.java	17 Oct 2002 20:43:06 -0000	1.6
  +++ Collector.java	30 Oct 2002 17:41:22 -0000	1.7
  @@ -188,12 +188,8 @@
   
               if( (n instanceof Node.CustomTag) && !hasScriptingVars) {
                   Node.CustomTag ct = (Node.CustomTag)n;
  -		// For some reason, varInfos is null when var is not defined
  -		// in TEI, but tagVarInfos is empty array when var is not
  -		// defined in tld.
  -		hasScriptingVars = ct.getVariableInfos() != null || 
  -			(ct.getTagVariableInfos() != null
  -			 && ct.getTagVariableInfos().length > 0);
  +		hasScriptingVars = ct.getVariableInfos().length > 0
  +		    || ct.getTagVariableInfos().length > 0;
   	    }
   
   	    // Record if the tag element and its body contains any scriptlet.
  
  
  
  1.113     +51 -66    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.112
  retrieving revision 1.113
  diff -u -r1.112 -r1.113
  --- Generator.java	28 Oct 2002 18:16:19 -0000	1.112
  +++ Generator.java	30 Oct 2002 17:41:22 -0000	1.113
  @@ -268,7 +268,7 @@
   		    TagVariableInfo[] tagVarInfos = n.getTagVariableInfos();
   		    VariableInfo[] varInfos = n.getVariableInfos();
   
  -		    if (varInfos != null) {
  +		    if (varInfos.length > 0) {
   			for (int i=0; i<varInfos.length; i++) {
   			    String varName = varInfos[i].getVarName();
   			    String tmpVarName = "_jspx_" + varName + "_"
  @@ -283,7 +283,7 @@
   				out.println(";");
   			    }
   			}
  -		    } else if (tagVarInfos != null) {
  +		    } else {
   			for (int i=0; i<tagVarInfos.length; i++) {
   			    String varName = tagVarInfos[i].getNameGiven();
   			    if (varName == null) {
  @@ -1788,38 +1788,27 @@
                       out.printil( "java.util.HashMap " + var + 
                           " = new java.util.HashMap();" );
                       
  -                    if( varInfos != null ) {
  -                        for( int i = 0; i < varInfos.length; i++ ) {
  -                            if( (varInfos[i].getScope() == 
  -                                    VariableInfo.AT_BEGIN) ||
  -                                (varInfos[i].getScope() == 
  -                                    VariableInfo.NESTED) ) 
  -                            {
  -                                out.printil( var + ".put( \"" + 
  -                                    varInfos[i].getVarName() + "\", " +
  -                                    varInfos[i].getVarName() + " );" );
  -                            }
  -                        }
  -                    }
  +		    for (int i = 0; i < varInfos.length; i++) {
  +			if ((varInfos[i].getScope() == VariableInfo.AT_BEGIN)
  +			        || (varInfos[i].getScope() == VariableInfo.NESTED)) {
  +			    out.printil( var + ".put( \"" + 
  +					 varInfos[i].getVarName() + "\", " +
  +					 varInfos[i].getVarName() + " );" );
  +			}
  +		    }
   
  -                    if( tagVarInfos != null ) {
  -                        for( int i = 0; i < tagVarInfos.length; i++ ) {
  -                            if( (tagVarInfos[i].getScope() == 
  -                                    VariableInfo.AT_BEGIN) || 
  -                                (tagVarInfos[i].getScope() ==
  -                                    VariableInfo.NESTED) )
  -                            {
  -                                out.printin( var + ".put( \"" );
  -                                String name = tagVarInfos[i].getNameGiven();
  -                                if( name == null ) {
  -                                    name = customTag.getTagData().
  -                                        getAttributeString(
  +		    for (int i = 0; i < tagVarInfos.length; i++) {
  +			if ((tagVarInfos[i].getScope() == VariableInfo.AT_BEGIN)
  +			        || (tagVarInfos[i].getScope() == VariableInfo.NESTED)) {
  +			    out.printin( var + ".put( \"" );
  +			    String name = tagVarInfos[i].getNameGiven();
  +			    if( name == null ) {
  +				name = customTag.getTagData().getAttributeString(
                                           tagVarInfos[i].getNameFromAttribute());
  -                                }
  -                                out.println( name + "\", " + name + " );" );
  -                            }
  -                        }
  -                    }
  +			    }
  +			    out.println( name + "\", " + name + " );" );
  +			}
  +		    }
                       
                       out.printil("(" + 
                           attributeValue(value, false, JspFragment.class,
  @@ -2208,11 +2197,11 @@
   
   	    TagVariableInfo[] tagVarInfos = n.getTagVariableInfos();
   	    VariableInfo[] varInfos = n.getVariableInfos();
  -	    if ((varInfos == null) && (tagVarInfos == null)) {
  +	    if ((varInfos.length == 0) && (tagVarInfos.length == 0)) {
   		return;
   	    }
   
  -	    if (varInfos != null) {
  +	    if (varInfos.length > 0) {
   		for (int i=0; i<varInfos.length; i++) {
   		    if (varInfos[i].getScope() != scope)
   			continue;
  @@ -2257,11 +2246,11 @@
   
   	    TagVariableInfo[] tagVarInfos = n.getTagVariableInfos();
   	    VariableInfo[] varInfos = n.getVariableInfos();
  -	    if ((varInfos == null) && (tagVarInfos == null)) {
  +	    if ((varInfos.length == 0) && (tagVarInfos.length == 0)) {
   		return;
   	    }
   
  -	    if (varInfos != null) {
  +	    if (varInfos.length > 0) {
   		for (int i=0; i<varInfos.length; i++) {
   		    if (varInfos[i].getScope() != scope)
   			continue;
  @@ -2300,11 +2289,11 @@
   	    TagVariableInfo[] tagVarInfos = n.getTagVariableInfos();
   	    VariableInfo[] varInfos = n.getVariableInfos();
   
  -	    if ((varInfos == null) && (tagVarInfos == null)) {
  +	    if ((varInfos.length == 0) && (tagVarInfos.length == 0)) {
   		return;
   	    }
   
  -	    if (varInfos != null) {
  +	    if (varInfos.length > 0) {
   		for (int i=0; i<varInfos.length; i++) {
   		    if (varInfos[i].getScope() == scope) {
   			out.printin(varInfos[i].getVarName());
  @@ -2995,20 +2984,18 @@
   	TagAttributeInfo[] attrInfos = tagInfo.getAttributes();
   
   	// Declare attributes
  -	if (attrInfos != null) {
  -	    for (int i=0; i<attrInfos.length; i++) {
  -		out.printin("private ");
  -		if (attrInfos[i].isFragment()) {
  -		    out.print("javax.servlet.jsp.tagext.JspFragment ");
  -		} else {
  -		    out.print(attrInfos[i].getTypeName());
  -		    out.print(" ");
  -		}
  -		out.print(attrInfos[i].getName());
  -		out.println(";");
  +	for (int i=0; i<attrInfos.length; i++) {
  +	    out.printin("private ");
  +	    if (attrInfos[i].isFragment()) {
  +		out.print("javax.servlet.jsp.tagext.JspFragment ");
  +	    } else {
  +		out.print(attrInfos[i].getTypeName());
  +		out.print(" ");
   	    }
  -	    out.println();
  +	    out.print(attrInfos[i].getName());
  +	    out.println(";");
   	}
  +	out.println();
   
   	// Define attribute getter and setter methods
   	if (attrInfos != null) {
  @@ -3070,7 +3057,7 @@
   	out.printil("java.util.Vector _jspx_at_begin = new java.util.Vector();");
   	out.printil("java.util.Vector _jspx_at_end = new java.util.Vector();");
   	TagVariableInfo[] tagVars = tagInfo.getTagVariableInfos();
  -	for (int i=0; tagVars != null && i<tagVars.length; i++) {
  +	for (int i=0; i<tagVars.length; i++) {
   		String name = tagVars[i].getNameGiven();
   		/* XXX
   		if (name == null) {
  @@ -3135,18 +3122,16 @@
   
   	// "normal" attributes
   	TagAttributeInfo[] attrInfos = tagInfo.getAttributes();
  -	if (attrInfos != null) {
  -	    for (int i=0; i<attrInfos.length; i++) {
  -		String attrName = attrInfos[i].getName();
  -                out.printil("if( " + toGetterMethod(attrName) + " != null ) " );
  -		out.pushIndent();
  -                out.printin("pageContext.setAttribute(");
  -		out.print(quote(attrName));
  -		out.print(", ");
  -		out.print(toGetterMethod(attrName));
  -		out.println(");");
  -		out.popIndent();
  -	    }
  +	for (int i=0; i<attrInfos.length; i++) {
  +	    String attrName = attrInfos[i].getName();
  +	    out.printil("if( " + toGetterMethod(attrName) + " != null ) " );
  +	    out.pushIndent();
  +	    out.printin("pageContext.setAttribute(");
  +	    out.print(quote(attrName));
  +	    out.print(", ");
  +	    out.print(toGetterMethod(attrName));
  +	    out.println(");");
  +	    out.popIndent();
   	}
   
   	// dynamic attributes
  
  
  
  1.37      +9 -4      jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/Node.java
  
  Index: Node.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/Node.java,v
  retrieving revision 1.36
  retrieving revision 1.37
  diff -u -r1.36 -r1.37
  --- Node.java	22 Oct 2002 03:00:20 -0000	1.36
  +++ Node.java	30 Oct 2002 17:41:22 -0000	1.37
  @@ -77,6 +77,8 @@
    */
   
   abstract class Node {
  +
  +    private static final VariableInfo[] ZERO_VARIABLE_INFO = { };
       
       protected Attributes attrs;
       protected Nodes body;
  @@ -1058,6 +1060,9 @@
   	public void setTagData(TagData tagData) {
   	    this.tagData = tagData;
   	    this.varInfos = tagInfo.getVariableInfo(tagData);
  +	    if (this.varInfos == null) {
  +		this.varInfos = ZERO_VARIABLE_INFO;
  +	    }
   	}
   
   	public TagData getTagData() {
  @@ -1184,7 +1189,7 @@
               boolean result = false;
   
   	    TagAttributeInfo[] attributes = tagInfo.getAttributes();
  -	    for (int i = 0; attributes != null && i < attributes.length; i++) {
  +	    for (int i = 0; i < attributes.length; i++) {
   		if (attributes[i].getName().equals(name) &&
   		            attributes[i].isFragment()) {
   		    result = true;
  
  
  
  1.37      +4 -4      jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/Parser.java
  
  Index: Parser.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/Parser.java,v
  retrieving revision 1.36
  retrieving revision 1.37
  diff -u -r1.36 -r1.37
  --- Parser.java	28 Oct 2002 18:16:20 -0000	1.36
  +++ Parser.java	30 Oct 2002 17:41:22 -0000	1.37
  @@ -1718,7 +1718,7 @@
   	if (n instanceof Node.CustomTag) {
   	    TagInfo tagInfo = ((Node.CustomTag)n).getTagInfo();
   	    TagAttributeInfo[] tldAttrs = tagInfo.getAttributes();
  -	    for (int i=0; tldAttrs != null && i<tldAttrs.length; i++) {
  +	    for (int i=0; i<tldAttrs.length; i++) {
   		if (name.equals(tldAttrs[i].getName())) {
   		    if (tldAttrs[i].isFragment()) {
   		        return TagInfo.BODY_CONTENT_SCRIPTLESS;
  
  
  
  1.8       +5 -5      jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/ScriptingVariabler.java
  
  Index: ScriptingVariabler.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/ScriptingVariabler.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- ScriptingVariabler.java	28 Oct 2002 18:16:20 -0000	1.7
  +++ ScriptingVariabler.java	30 Oct 2002 17:41:22 -0000	1.8
  @@ -120,7 +120,7 @@
   
   	    TagVariableInfo[] tagVarInfos = n.getTagVariableInfos();
   	    VariableInfo[] varInfos = n.getVariableInfos();
  -	    if (tagVarInfos == null && varInfos == null) {
  +	    if (tagVarInfos.length == 0 && varInfos.length == 0) {
   		return;
   	    }
   
  @@ -139,7 +139,7 @@
   		ownRange = n.getNumCount();
   	    }
   
  -	    if (varInfos != null) {
  +	    if (varInfos.length > 0) {
   		for (int i=0; i<varInfos.length; i++) {
   		    if (varInfos[i].getScope() != scope
   			    || !varInfos[i].getDeclare()) {
  
  
  
  1.34      +9 -13     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.33
  retrieving revision 1.34
  diff -u -r1.33 -r1.34
  --- TagFileProcessor.java	28 Oct 2002 23:34:14 -0000	1.33
  +++ TagFileProcessor.java	30 Oct 2002 17:41:22 -0000	1.34
  @@ -245,17 +245,13 @@
   
               tagclass = Constants.TAG_FILE_PACKAGE_NAME + "." + name;
   
  -            TagVariableInfo[] tagVariableInfos = null;
  -            if (variableVector.size() > 0) {
  -                tagVariableInfos = new TagVariableInfo[variableVector.size()];
  -                variableVector.copyInto(tagVariableInfos);
  -            }
  +            TagVariableInfo[] tagVariableInfos
  +		= new TagVariableInfo[variableVector.size()];
  +	    variableVector.copyInto(tagVariableInfos);
   
  -            TagAttributeInfo[] tagAttributeInfo = null;
  -            if (attributeVector.size() > 0) {
  -                tagAttributeInfo = new TagAttributeInfo[attributeVector.size()];
  -                attributeVector.copyInto(tagAttributeInfo);
  -            }
  +            TagAttributeInfo[] tagAttributeInfo
  +		= new TagAttributeInfo[attributeVector.size()];
  +	    attributeVector.copyInto(tagAttributeInfo);
   
               return new TagInfo(name,
   			       tagclass,
  
  
  
  1.23      +10 -14    jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/TagLibraryInfoImpl.java
  
  Index: TagLibraryInfoImpl.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/TagLibraryInfoImpl.java,v
  retrieving revision 1.22
  retrieving revision 1.23
  diff -u -r1.22 -r1.23
  --- TagLibraryInfoImpl.java	28 Oct 2002 22:01:34 -0000	1.22
  +++ TagLibraryInfoImpl.java	30 Oct 2002 17:41:22 -0000	1.23
  @@ -373,17 +373,13 @@
   	    }
   	}
   
  -	TagAttributeInfo[] tagAttributeInfo = null;
  -	if (attributeVector.size() > 0) {
  -            tagAttributeInfo = new TagAttributeInfo[attributeVector.size()];
  -	    attributeVector.copyInto(tagAttributeInfo);
  -	}
  +	TagAttributeInfo[] tagAttributeInfo
  +	    = new TagAttributeInfo[attributeVector.size()];
  +	attributeVector.copyInto(tagAttributeInfo);
   
  -	TagVariableInfo[] tagVariableInfos = null;
  -	if (variableVector.size() > 0) {
  -            tagVariableInfos = new TagVariableInfo[variableVector.size()];
  -	    variableVector.copyInto(tagVariableInfos);
  -	}
  +	TagVariableInfo[] tagVariableInfos
  +	    = new TagVariableInfo[variableVector.size()];
  +	variableVector.copyInto(tagVariableInfos);
   
           TagExtraInfo tei = null;
           if (teiclass != null && !teiclass.equals("")) {
  
  
  
  1.49      +4 -5      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.48
  retrieving revision 1.49
  diff -u -r1.48 -r1.49
  --- Validator.java	28 Oct 2002 18:16:20 -0000	1.48
  +++ Validator.java	30 Oct 2002 17:41:22 -0000	1.49
  @@ -651,7 +651,7 @@
   	     */
   	    TagAttributeInfo[] tldAttrs = tagInfo.getAttributes();
   	    Attributes attrs = n.getAttributes();
  -	    for (int i=0; tldAttrs != null && i<tldAttrs.length; i++) {
  +	    for (int i=0; i<tldAttrs.length; i++) {
   		String attr = attrs.getValue(tldAttrs[i].getName());
   		Node.NamedAttribute jspAttr =
   			n.getNamedAttributeNode(tldAttrs[i].getName());
  @@ -788,7 +788,6 @@
   	    if (tei != null
   		    && tei.getVariableInfo(tagData) != null
   		    && tei.getVariableInfo(tagData).length > 0
  -		    && tagInfo.getTagVariableInfos() != null
   		    && tagInfo.getTagVariableInfos().length > 0) {
   		err.jspError("jsp.error.non_null_tei_and_var_subelems",
   			     n.getName());
  
  
  

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


Mime
View raw message