tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pier...@locus.apache.org
Subject cvs commit: jakarta-tomcat-4.0/jasper/src/share/org/apache/jasper/compiler TagBeginGenerator.java TagEndGenerator.java TagGeneratorBase.java TagLibraryInfoImpl.java
Date Wed, 01 Nov 2000 20:25:55 GMT
pierred     00/11/01 12:25:52

  Modified:    jasper/src/share/org/apache/jasper/compiler
                        TagBeginGenerator.java TagEndGenerator.java
                        TagGeneratorBase.java TagLibraryInfoImpl.java
  Log:
  Part 2 for the support of the following new JSP 1.2 feature:
  "Added elements to the TLD to avoid having to write TagExtraInfo
  classes in the most common cases"
  
  TagLibraryInfoImpl.java
  - proper handling of <scope> element
  
  TagGeneratorBase.java
  TagBeginGenerator.java
  TagEndGenerator.java
  - Now supports TagVariableInfo as well as VariableInfo
  
  Revision  Changes    Path
  1.6       +9 -5      jakarta-tomcat-4.0/jasper/src/share/org/apache/jasper/compiler/TagBeginGenerator.java
  
  Index: TagBeginGenerator.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/jasper/src/share/org/apache/jasper/compiler/TagBeginGenerator.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- TagBeginGenerator.java	2000/10/17 22:59:01	1.5
  +++ TagBeginGenerator.java	2000/11/01 20:25:07	1.6
  @@ -64,6 +64,7 @@
   import javax.servlet.jsp.tagext.TagInfo;
   import javax.servlet.jsp.tagext.TagAttributeInfo;
   import javax.servlet.jsp.tagext.VariableInfo;
  +import javax.servlet.jsp.tagext.TagVariableInfo;
   import javax.servlet.jsp.tagext.TagData;
   import javax.servlet.jsp.tagext.Tag;
   import javax.servlet.jsp.tagext.BodyTag;
  @@ -318,9 +319,10 @@
           generateSetters(writer, parent);
   
           VariableInfo[] vi = ti.getVariableInfo(tagData);
  +	TagVariableInfo[] tvi = ti.getTagVariableInfos();
   
           // Just declare AT_BEGIN here...
  -        declareVariables(writer, vi, true, false, VariableInfo.AT_BEGIN);
  +        declareVariables(writer, vi, tvi, tagData, true, false, VariableInfo.AT_BEGIN);
   
   	writer.println("try {");
   	writer.pushIndent();
  @@ -330,10 +332,11 @@
           writer.println("int "+evalVar+" = "
                          +thVarName+".doStartTag();");
   
  -        boolean implementsBodyTag = BodyTag.class.isAssignableFrom(tc.getTagHandlerClass());
  +        boolean implementsBodyTag = 
  +	    BodyTag.class.isAssignableFrom(tc.getTagHandlerClass());
   
           // Need to update AT_BEGIN variables here
  -        declareVariables(writer, vi, false, true, VariableInfo.AT_BEGIN);
  +        declareVariables(writer, vi, tvi, tagData, false, true, VariableInfo.AT_BEGIN);
   
           // FIXME: I'm not too sure if this is the right approach. I don't like
           //        throwing English language strings into the generated servlet.
  @@ -376,9 +379,9 @@
   	writer.println("do {");
   	writer.pushIndent();
           // Need to declare and update NESTED variables here
  -        declareVariables(writer, vi, true, true, VariableInfo.NESTED);
  +        declareVariables(writer, vi, tvi, tagData, true, true, VariableInfo.NESTED);
           // Need to update AT_BEGIN variables here
  -        declareVariables(writer, vi, false, true, VariableInfo.AT_BEGIN);
  +        declareVariables(writer, vi, tvi, tagData, false, true, VariableInfo.AT_BEGIN);
       }
   
       public void generate(ServletWriter writer, Class phase)
  @@ -387,3 +390,4 @@
           generateServiceMethodStatements(writer);
       }
   }
  +
  
  
  
  1.5       +7 -4      jakarta-tomcat-4.0/jasper/src/share/org/apache/jasper/compiler/TagEndGenerator.java
  
  Index: TagEndGenerator.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/jasper/src/share/org/apache/jasper/compiler/TagEndGenerator.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- TagEndGenerator.java	2000/11/01 00:53:59	1.4
  +++ TagEndGenerator.java	2000/11/01 20:25:08	1.5
  @@ -61,6 +61,7 @@
   import javax.servlet.jsp.tagext.TagLibraryInfo;
   import javax.servlet.jsp.tagext.TagInfo;
   import javax.servlet.jsp.tagext.VariableInfo;
  +import javax.servlet.jsp.tagext.TagVariableInfo;
   import javax.servlet.jsp.tagext.TagData;
   import javax.servlet.jsp.tagext.Tag;
   import javax.servlet.jsp.tagext.IterationTag;
  @@ -105,8 +106,10 @@
           String thVarName = tvd.tagHandlerInstanceName;
           String evalVarName = tvd.tagEvalVarName;
   
  -        VariableInfo[] vi = ti.getVariableInfo(new TagData(
  -                JspUtil.attrsToHashtable(attrs)));
  +	TagData tagData = 
  +	    new TagData(JspUtil.attrsToHashtable(attrs));
  +        VariableInfo[] vi = ti.getVariableInfo(tagData);
  +	TagVariableInfo[] tvi = ti.getTagVariableInfos();
   
           Class tagHandlerClass =
   	    libraries.getTagCache(prefix, shortTagName).getTagHandlerClass();
  @@ -124,7 +127,7 @@
           else
               writer.println("} while (false);");
   
  -        declareVariables(writer, vi, false, true, VariableInfo.AT_BEGIN);
  +        declareVariables(writer, vi, tvi, tagData, false, true, VariableInfo.AT_BEGIN);
   
           if (implementsBodyTag) {
               writer.popIndent(); // try
  @@ -185,6 +188,6 @@
   	writer.println("}");
   
           // Need to declare and update AT_END variables here.
  -        declareVariables(writer, vi, true, true, VariableInfo.AT_END);
  +        declareVariables(writer, vi, tvi, tagData, true, true, VariableInfo.AT_END);
       }
   }
  
  
  
  1.2       +46 -13    jakarta-tomcat-4.0/jasper/src/share/org/apache/jasper/compiler/TagGeneratorBase.java
  
  Index: TagGeneratorBase.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/jasper/src/share/org/apache/jasper/compiler/TagGeneratorBase.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- TagGeneratorBase.java	2000/08/12 00:52:08	1.1
  +++ TagGeneratorBase.java	2000/11/01 20:25:08	1.2
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat-4.0/jasper/src/share/org/apache/jasper/compiler/TagGeneratorBase.java,v
1.1 2000/08/12 00:52:08 pierred Exp $
  - * $Revision: 1.1 $
  - * $Date: 2000/08/12 00:52:08 $
  + * $Header: /home/cvs/jakarta-tomcat-4.0/jasper/src/share/org/apache/jasper/compiler/TagGeneratorBase.java,v
1.2 2000/11/01 20:25:08 pierred Exp $
  + * $Revision: 1.2 $
  + * $Date: 2000/11/01 20:25:08 $
    *
    * ====================================================================
    *
  @@ -64,7 +64,9 @@
   import java.util.Stack;
   import java.util.Hashtable;
   
  +import javax.servlet.jsp.tagext.TagData;
   import javax.servlet.jsp.tagext.VariableInfo;
  +import javax.servlet.jsp.tagext.TagVariableInfo;
   
   /**
    * Common stuff for use with TagBegin and TagEndGenerators.
  @@ -134,18 +136,49 @@
   	}
       }
   
  -    protected void declareVariables(ServletWriter writer, VariableInfo[] vi,
  -                                           boolean declare, boolean update, int scope)
  +    protected void declareVariables(ServletWriter writer, 
  +				    VariableInfo[] vi,
  +				    TagVariableInfo[] tvi,
  +				    TagData tagData,
  +				    boolean declare, boolean update, int scope)
       {
  -        if (vi != null)
  -            for(int i = 0; i < vi.length; i++)
  +        if (vi != null) {
  +            for(int i = 0; i < vi.length; i++) {
                   if (vi[i].getScope() == scope) {
  -                    if (vi[i].getDeclare() == true && declare == true)
  -                        writer.println(vi[i].getClassName()+" "+vi[i].getVarName()+" =
null;");
  -                    if (update == true)
  -                        writer.println(vi[i].getVarName()+" = ("+
  -                                       vi[i].getClassName()+") pageContext.findAttribute("
  -                                       +writer.quoteString(vi[i].getVarName())+");");
  +                    if (vi[i].getDeclare() && declare) {
  +                        writer.println(vi[i].getClassName() +
  +				       " " + vi[i].getVarName() +
  +				       " = null;");
  +		    }
  +                    if (update) {
  +                        writer.println(vi[i].getVarName() + " = (" +
  +                                       vi[i].getClassName() +
  +				       ") pageContext.findAttribute(" +
  +                                       writer.quoteString(vi[i].getVarName())+");");
  +		    }
                   }
  +	    }
  +	} else if (tvi != null) {
  +            for(int i = 0; i < tvi.length; i++) {
  +		String name;
  +		if (tvi[i].getNameGiven() != null) {
  +		    name = tvi[i].getNameGiven();
  +		} else {
  +		    name = tagData.getAttributeString(tvi[i].getNameFromAttribute());
  +		}
  +                if (tvi[i].getScope() == scope) {
  +                    if (tvi[i].getDeclare() && declare) {
  +                        writer.println(tvi[i].getClassName() + 
  +				       " " + name + " = null;");
  +		    }
  +                    if (update) {
  +                        writer.println(name + " = (" +
  +                                       tvi[i].getClassName() +
  +				       ") pageContext.findAttribute(" +
  +                                       writer.quoteString(name) + ");");
  +		    }
  +                }
  +	    }
  +	}
       }
   }
  
  
  
  1.11      +14 -4     jakarta-tomcat-4.0/jasper/src/share/org/apache/jasper/compiler/TagLibraryInfoImpl.java
  
  Index: TagLibraryInfoImpl.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/jasper/src/share/org/apache/jasper/compiler/TagLibraryInfoImpl.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- TagLibraryInfoImpl.java	2000/10/31 23:51:16	1.10
  +++ TagLibraryInfoImpl.java	2000/11/01 20:25:09	1.11
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat-4.0/jasper/src/share/org/apache/jasper/compiler/TagLibraryInfoImpl.java,v
1.10 2000/10/31 23:51:16 pierred Exp $
  - * $Revision: 1.10 $
  - * $Date: 2000/10/31 23:51:16 $
  + * $Header: /home/cvs/jakarta-tomcat-4.0/jasper/src/share/org/apache/jasper/compiler/TagLibraryInfoImpl.java,v
1.11 2000/11/01 20:25:09 pierred Exp $
  + * $Revision: 1.11 $
  + * $Date: 2000/11/01 20:25:09 $
    *
    * The Apache Software License, Version 1.1
    *
  @@ -373,6 +373,8 @@
                       largeIcon = t.getData();
   	    } else if (tname.equals("variable")) {
   		if (teiclass != null) {
  +		    // teiclass comes first in the tag element
  +		    // only need to make the check here
   		    throw new JasperException(
   			Constants.getString("tld.error.variableNotAllowed"));
   		}
  @@ -394,6 +396,7 @@
               = new TagVariableInfo[variableVector.size()];
   	variableVector.copyInto(tagVariableInfos);
   
  +
           TagExtraInfo tei = null;
   
           if (teiclass != null && !teiclass.equals(""))
  @@ -515,7 +518,14 @@
               } else if (tname.equals("scope")) {
                   Text t = (Text) e.getFirstChild();
                   if (t != null) {
  -                    scope = Integer.valueOf(t.getData()).intValue();
  +		    String s = t.getData();
  +		    if ("NESTED".equals(s)) {
  +			scope = VariableInfo.NESTED;
  +		    } else if ("AT_BEGIN".equals(s)) {
  +			scope = VariableInfo.AT_BEGIN;
  +		    } else if ("AT_END".equals(s)) {
  +			scope = VariableInfo.AT_END;
  +		    }
   		}
               } else 
                   Constants.message("jsp.warning.unknown.element.in.variable",
  
  
  

Mime
View raw message