luehe       2003/08/22 12:42:58

  Modified:    jasper2/src/share/org/apache/jasper/compiler Generator.java
  Log:
  Avoid defining multiple getServletInfo() methods (one for each page
  directive with an 'info' attribute)
  
  Revision  Changes    Path
  1.201     +22 -5     
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.200
  retrieving revision 1.201
  diff -u -r1.200 -r1.201
  --- Generator.java    22 Aug 2003 00:07:32 -0000      1.200
  +++ Generator.java    22 Aug 2003 19:42:58 -0000      1.201
  @@ -148,7 +148,24 @@
   
        class DeclarationVisitor extends Node.Visitor {
   
  +            private boolean getServletInfoGenerated = false;
  +
  +            /*
  +             * Generates getServletInfo() method that returns the value of the
  +             * page directive's 'info' attribute, if present.
  +             *
  +             * The Validator has already ensured that if the translation unit
  +             * contains more than one page directive with an 'info' attribute,
  +             * their values match.
  +             */
            public void visit(Node.PageDirective n) throws JasperException {
  +
  +                if (!getServletInfoGenerated) {
  +                    getServletInfoGenerated = true;
  +                } else {
  +                    return;
  +                }
  +
                String info = n.getAttributeValue("info");
                if (info == null)
                    return;
  @@ -156,10 +173,10 @@
                out.printil("public String getServletInfo() {");
                out.pushIndent();
                out.printin("return ");
  -             out.print  (quote(info));
  +             out.print(quote(info));
                out.println(";");
                out.popIndent();
  -             out.print  ('}');
  +             out.printil("}");
                out.println();
            }
   
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to