horwat      01/07/12 14:41:36

  Modified:    jasper/src/share/org/apache/jasper/compiler
                        ServletWriter.java JakartaCommentGenerator.java
                        Compiler.java Mark.java
                        UninterpretedTagEndGenerator.java
                        UninterpretedTagBeginGenerator.java
                        MappedCharDataGenerator.java CharDataGenerator.java
               jasper/src/share/org/apache/jasper/resources
                        messages.properties
  Added:       jasper/src/share/org/apache/jasper/compiler
                        JspLineMapItem.java JspLineMap.java
  Log:
  Enhanced compile time jsp error reporting.
  
  A line map is created that maps the generated servlet lines to the original jsp 
file. The map is then used when a compile time error occurs to find the corresponding 
line in the original jsp file. That information is then added to the error report.
  
  Revision  Changes    Path
  1.2       +37 -5     
jakarta-tomcat-4.0/jasper/src/share/org/apache/jasper/compiler/ServletWriter.java
  
  Index: ServletWriter.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat-4.0/jasper/src/share/org/apache/jasper/compiler/ServletWriter.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ServletWriter.java        2000/08/12 00:52:08     1.1
  +++ ServletWriter.java        2001/07/12 21:40:51     1.2
  @@ -1,7 +1,7 @@
   /*
  - * $Header: 
/home/cvs/jakarta-tomcat-4.0/jasper/src/share/org/apache/jasper/compiler/ServletWriter.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/ServletWriter.java,v
 1.2 2001/07/12 21:40:51 horwat Exp $
  + * $Revision: 1.2 $
  + * $Date: 2001/07/12 21:40:51 $
    *
    * ====================================================================
    * 
  @@ -76,10 +76,15 @@
   
       // Current indent level:
       int indent = 0;
  -    
  +
       // The sink writer:
       PrintWriter writer;
       
  +    // servlet line numbers start from 1, but we pre-increment
  +    private int javaLine = 0;
  +    private JspLineMap lineMap = new JspLineMap();
  +
  +
       public ServletWriter(PrintWriter writer) {
        this.writer = writer;
       }
  @@ -88,6 +93,22 @@
        writer.close();
       }
       
  +    // -------------------- Access informations --------------------
  +
  +    public int getJavaLine() {
  +        return javaLine;
  +    }
  +
  +    public void setLineMap(JspLineMap map) {
  +        this.lineMap = map;
  +    }
  +
  +    public JspLineMap getLineMap() {
  +        return lineMap;
  +    }
  +
  +    // -------------------- Formatting --------------------
  +
       public void pushIndent() {
        if ((indent += TAB_WIDTH) > SPACES.length())
            indent = SPACES.length();
  @@ -157,10 +178,12 @@
       }
   
       public void println(String line) {
  +        javaLine++;
        writer.println(SPACES.substring(0, indent)+line);
       }
   
       public void println() {
  +        javaLine++;
        writer.println("");
       }
   
  @@ -170,6 +193,14 @@
       
   
       public void print(String s) {
  +        int index = 0;
  +
  +        // look for hidden newlines inside strings
  +        while ((index=s.indexOf('\n',index)) > -1 ) {
  +            javaLine++;
  +            index++;
  +        }
  +
        writer.print(s);
       }
   
  @@ -178,9 +209,10 @@
        BufferedReader reader = 
               new BufferedReader(new StringReader(multiline));
        try {
  -         for (String line = null ; (line = reader.readLine()) != null ; ) 
  +         for (String line = null ; (line = reader.readLine()) != null ; ) {
                //              println(SPACES.substring(0, indent)+line);
                println(line);
  +            }
        } catch (IOException ex) {
            // Unlikely to happen, since we're acting on strings
        }
  
  
  
  1.2       +40 -1     
jakarta-tomcat-4.0/jasper/src/share/org/apache/jasper/compiler/JakartaCommentGenerator.java
  
  Index: JakartaCommentGenerator.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat-4.0/jasper/src/share/org/apache/jasper/compiler/JakartaCommentGenerator.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- JakartaCommentGenerator.java      2000/08/12 00:52:08     1.1
  +++ JakartaCommentGenerator.java      2001/07/12 21:40:54     1.2
  @@ -84,6 +84,13 @@
    */
   public class JakartaCommentGenerator implements CommentGenerator {
       
  +    // -------------------- Generate comments --------------------
  +    // The code generator also maintains line number info.
  +
  +    // JakartaCommentGenerator can generate the line numbers
  +    // ( the way it generates the comments )
  +    JspLineMapItem lineMapItem;
  +
       /**
        * Generates "start-of the JSP-embedded code block" comment
        *
  @@ -97,6 +104,7 @@
           throws JasperException 
       {
        String html = "";
  +
           if (generator instanceof CharDataGenerator) {
           html = "// HTML ";
        }
  @@ -110,8 +118,12 @@
        } else {
            out.println(html + "// begin");
           }
  +
  +        // add the jsp to servlet line mappings
  +        lineMapItem = new JspLineMapItem();
  +        lineMapItem.setBeginServletLnr(out.getJavaLine());
   
  -      out.pushIndent();
  +        out.pushIndent();
       }
   
      /**
  @@ -123,9 +135,36 @@
        * @exception JasperException
        */
       public void generateEndComment(Generator generator, ServletWriter out, Mark 
start, Mark stop) throws JasperException {
  +
        out.popIndent();
           out.println("// end");
  +
  +        JspLineMap myLineMap = out.getLineMap();
  +
  +        // add the jsp to servlet line mappings
  +        lineMapItem.setEndServletLnr(out.getJavaLine());
  +        lineMapItem.setStartJspFileNr(myLineMap.addFileName(start.getSystemId()));
  +        lineMapItem.setBeginJspLnr(start.getLineNumber() + 1);
  +        lineMapItem.setBeginJspColNr(start.getColumnNumber() + 1);
  +        lineMapItem.setStopJspFileNr(myLineMap.addFileName(stop.getSystemId()));
  +        lineMapItem.setEndJspLnr(stop.getLineNumber() + 1);
  +        lineMapItem.setEndJspColNr(stop.getColumnNumber() + 1);
  +
  +        myLineMap.add(lineMapItem);
       }
  +
  +
  +    // The format may change
  +    private String toShortString( Mark mark ) {
  +        return "("+mark.getLineNumber() + ","+mark.getColumnNumber() +")";
  +    }
  +
  +    //
  +    private String toString( Mark mark ) {
  +        return 
mark.getSystemId()+"("+mark.getLineNumber()+","+mark.getColumnNumber() +")";
  +    }
  +
  +
   }
   //        String fileName = "null";
   //         if(start != null) {
  
  
  
  1.10      +100 -3    
jakarta-tomcat-4.0/jasper/src/share/org/apache/jasper/compiler/Compiler.java
  
  Index: Compiler.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat-4.0/jasper/src/share/org/apache/jasper/compiler/Compiler.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- Compiler.java     2001/02/08 13:37:45     1.9
  +++ Compiler.java     2001/07/12 21:40:56     1.10
  @@ -1,7 +1,7 @@
   /*
  - * $Header: 
/home/cvs/jakarta-tomcat-4.0/jasper/src/share/org/apache/jasper/compiler/Compiler.java,v
 1.9 2001/02/08 13:37:45 glenn Exp $
  - * $Revision: 1.9 $
  - * $Date: 2001/02/08 13:37:45 $
  + * $Header: 
/home/cvs/jakarta-tomcat-4.0/jasper/src/share/org/apache/jasper/compiler/Compiler.java,v
 1.10 2001/07/12 21:40:56 horwat Exp $
  + * $Revision: 1.10 $
  + * $Date: 2001/07/12 21:40:56 $
    *
    * ====================================================================
    * 
  @@ -67,6 +67,9 @@
   import java.io.ByteArrayOutputStream;
   import java.io.FileOutputStream;
   import java.io.OutputStreamWriter;
  +import java.io.BufferedReader;
  +import java.io.StringReader;
  +import java.io.IOException;
   
   import org.apache.jasper.JspCompilationContext;
   import org.apache.jasper.Constants;
  @@ -274,11 +277,105 @@
       
           if (status == false) {
               String msg = out.toString ();
  +            msg = getJspLineErrors(msg, writer.getLineMap());
  +
  +            //FIXME!!
  +            //Using an exception as flow control is not a good idea. Refactor me!
               throw new 
JasperException(Constants.getString("jsp.error.unable.compile")
                                         + msg);
           }
   
           return true;
  +    }
  +
  +    /**
  +     * Parse compiler error message. Get line number. Use JspLineMap object to
  +     * find the corresponding line in the jsp file. Create new error message with
  +     * jsp line information.
  +     */
  +    private String getJspLineErrors(String msg, JspLineMap map) throws IOException {
  +
  +        if (map == null) return msg;
  +
  +        //System.out.println(map.toString());
  +
  +        StringBuffer errorMsg = new StringBuffer();
  +        BufferedReader br = new BufferedReader(new StringReader(msg));
  +        String line;
  +
  +        while (true) {
  +            line=br.readLine();
  +            if (line==null) break;
  +
  +            // line number is between a set of colons
  +            int beginColon=line.indexOf(':');
  +            int endColon=line.indexOf(':', beginColon+1);
  +
  +            if (beginColon<0 || endColon<0) {
  +                errorMsg.append(line);
  +                errorMsg.append('\n');
  +                continue;
  +            }
  +
  +            String nr = line.substring(beginColon+1, endColon);
  +            int lineNr = Integer.parseInt( nr );
  +
  +            //System.out.println("lineNr: " + lineNr);
  +
  +            // Now do the mapping
  +            errorMsg.append(findMapping(map, lineNr));
  +            errorMsg.append(line);
  +            errorMsg.append('\n');
  +        }
  +        br.close();
  +        map.clear();
  +
  +        return errorMsg.toString();
  +    }
  +
  +    /**
  +     * Find map item that corresponds to the specified line number
  +     */
  +    private String findMapping(JspLineMap map, int lineNr) {
  +
  +        for (int i=map.size() - 1; i >= 0; i--) {
  +            JspLineMapItem mapItem = (JspLineMapItem) map.get(i);
  +
  +            if (mapItem == null) continue;
  +
  +            if (mapItem.getBeginServletLnr() <= lineNr &&
  +                mapItem.getEndServletLnr() >= lineNr) {
  +                return createErrorMsg(map, mapItem);
  +            }
  +        }
  +        return null;
  +    }
  +
  +    /**
  +     * Create error message including the jsp line numbers and file name
  +     */
  +    private String createErrorMsg(JspLineMap map, JspLineMapItem mapping) {
  +        StringBuffer msg = new StringBuffer();
  +
  +        if (mapping.getBeginJspLnr() == mapping.getEndJspLnr()) {
  +            msg.append(Constants.getString("jsp.error.single.line.number",
  +                       new Object[] {
  +                           new Integer(mapping.getBeginJspLnr()), 
  +                           map.getFileName(mapping.getStartJspFileNr())
  +                       }));
  +        }
  +        else {
  +            msg.append(Constants.getString("jsp.error.multiple.line.number",
  +                       new Object[] { 
  +                           new Integer(mapping.getBeginJspLnr()), 
  +                           new Integer(mapping.getEndJspLnr()), 
  +                           map.getFileName(mapping.getStartJspFileNr())
  +                       }));
  +        }
  +
  +        msg.append(Constants.getString("jsp.error.corresponding.servlet"));
  +
  +        return msg.toString();
       }
   
       /**
  
  
  
  1.3       +19 -3     
jakarta-tomcat-4.0/jasper/src/share/org/apache/jasper/compiler/Mark.java
  
  Index: Mark.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat-4.0/jasper/src/share/org/apache/jasper/compiler/Mark.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- Mark.java 2000/09/19 19:27:51     1.2
  +++ Mark.java 2001/07/12 21:40:59     1.3
  @@ -1,7 +1,7 @@
   /*
  - * $Header: 
/home/cvs/jakarta-tomcat-4.0/jasper/src/share/org/apache/jasper/compiler/Mark.java,v 
1.2 2000/09/19 19:27:51 pierred Exp $
  - * $Revision: 1.2 $
  - * $Date: 2000/09/19 19:27:51 $
  + * $Header: 
/home/cvs/jakarta-tomcat-4.0/jasper/src/share/org/apache/jasper/compiler/Mark.java,v 
1.3 2001/07/12 21:40:59 horwat Exp $
  + * $Revision: 1.3 $
  + * $Date: 2001/07/12 21:40:59 $
    *
    * ====================================================================
    * 
  @@ -211,7 +211,23 @@
        return true;
       }
   
  +    // -------------------- Locator interface --------------------
   
  +    public int getLineNumber() {
  +        return line;
  +    }
  +
  +    public int getColumnNumber() {
  +        return col;
  +    }
  +
  +    public String getSystemId() {
  +        return getFile();
  +    }
  +
  +    public String getPublicId() {
  +        return null;
  +    }
   
       public String toString() {
        return getFile()+"("+line+","+col+")";
  
  
  
  1.2       +3 -3      
jakarta-tomcat-4.0/jasper/src/share/org/apache/jasper/compiler/UninterpretedTagEndGenerator.java
  
  Index: UninterpretedTagEndGenerator.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat-4.0/jasper/src/share/org/apache/jasper/compiler/UninterpretedTagEndGenerator.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- UninterpretedTagEndGenerator.java 2000/10/04 20:01:06     1.1
  +++ UninterpretedTagEndGenerator.java 2001/07/12 21:41:02     1.2
  @@ -1,7 +1,7 @@
   /*
  - * $Header: 
/home/cvs/jakarta-tomcat-4.0/jasper/src/share/org/apache/jasper/compiler/UninterpretedTagEndGenerator.java,v
 1.1 2000/10/04 20:01:06 pierred Exp $
  - * $Revision: 1.1 $
  - * $Date: 2000/10/04 20:01:06 $
  + * $Header: 
/home/cvs/jakarta-tomcat-4.0/jasper/src/share/org/apache/jasper/compiler/UninterpretedTagEndGenerator.java,v
 1.2 2001/07/12 21:41:02 horwat Exp $
  + * $Revision: 1.2 $
  + * $Date: 2001/07/12 21:41:02 $
    *
    * ====================================================================
    * 
  @@ -82,6 +82,6 @@
        writer.print("out.write(\"");
           sb.append("</").append(tag).append(">");
        writer.print(sb.toString());
  -     writer.print("\");\n");
  +     writer.println("\");");
       }
   }
  
  
  
  1.3       +4 -4      
jakarta-tomcat-4.0/jasper/src/share/org/apache/jasper/compiler/UninterpretedTagBeginGenerator.java
  
  Index: UninterpretedTagBeginGenerator.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat-4.0/jasper/src/share/org/apache/jasper/compiler/UninterpretedTagBeginGenerator.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- UninterpretedTagBeginGenerator.java       2000/10/11 19:35:18     1.2
  +++ UninterpretedTagBeginGenerator.java       2001/07/12 21:41:04     1.3
  @@ -1,7 +1,7 @@
   /*
  - * $Header: 
/home/cvs/jakarta-tomcat-4.0/jasper/src/share/org/apache/jasper/compiler/UninterpretedTagBeginGenerator.java,v
 1.2 2000/10/11 19:35:18 shemnon Exp $
  - * $Revision: 1.2 $
  - * $Date: 2000/10/11 19:35:18 $
  + * $Header: 
/home/cvs/jakarta-tomcat-4.0/jasper/src/share/org/apache/jasper/compiler/UninterpretedTagBeginGenerator.java,v
 1.3 2001/07/12 21:41:04 horwat Exp $
  + * $Revision: 1.3 $
  + * $Date: 2001/07/12 21:41:04 $
    *
    * ====================================================================
    * 
  @@ -109,6 +109,6 @@
               sb.append(">");
           }
        writer.print(sb.toString());
  -     writer.print("\");\n");
  +     writer.println("\");");
       }
   }
  
  
  
  1.2       +4 -4      
jakarta-tomcat-4.0/jasper/src/share/org/apache/jasper/compiler/MappedCharDataGenerator.java
  
  Index: MappedCharDataGenerator.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat-4.0/jasper/src/share/org/apache/jasper/compiler/MappedCharDataGenerator.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- MappedCharDataGenerator.java      2000/08/12 00:52:08     1.1
  +++ MappedCharDataGenerator.java      2001/07/12 21:41:06     1.2
  @@ -1,7 +1,7 @@
   /*
  - * $Header: 
/home/cvs/jakarta-tomcat-4.0/jasper/src/share/org/apache/jasper/compiler/MappedCharDataGenerator.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/MappedCharDataGenerator.java,v
 1.2 2001/07/12 21:41:06 horwat Exp $
  + * $Revision: 1.2 $
  + * $Date: 2001/07/12 21:41:06 $
    *
    * ====================================================================
    * 
  @@ -116,6 +116,6 @@
            }
        }
        writer.print(sb.toString());
  -     writer.print("\");\n");
  +     writer.println("\");");
       }
   }
  
  
  
  1.2       +4 -4      
jakarta-tomcat-4.0/jasper/src/share/org/apache/jasper/compiler/CharDataGenerator.java
  
  Index: CharDataGenerator.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat-4.0/jasper/src/share/org/apache/jasper/compiler/CharDataGenerator.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- CharDataGenerator.java    2000/08/12 00:52:07     1.1
  +++ CharDataGenerator.java    2001/07/12 21:41:08     1.2
  @@ -1,7 +1,7 @@
   /*
  - * $Header: 
/home/cvs/jakarta-tomcat-4.0/jasper/src/share/org/apache/jasper/compiler/CharDataGenerator.java,v
 1.1 2000/08/12 00:52:07 pierred Exp $
  - * $Revision: 1.1 $
  - * $Date: 2000/08/12 00:52:07 $
  + * $Header: 
/home/cvs/jakarta-tomcat-4.0/jasper/src/share/org/apache/jasper/compiler/CharDataGenerator.java,v
 1.2 2001/07/12 21:41:08 horwat Exp $
  + * $Revision: 1.2 $
  + * $Date: 2001/07/12 21:41:08 $
    *
    * ====================================================================
    * 
  @@ -126,7 +126,7 @@
            }
        }
        writer.print(sb.toString());
  -     writer.print("\");\n");
  +     writer.println("\");");
       }
   
   
  
  
  
  1.1                  
jakarta-tomcat-4.0/jasper/src/share/org/apache/jasper/compiler/JspLineMapItem.java
  
  Index: JspLineMapItem.java
  ===================================================================
  /*
   * $Header: 
/home/cvs/jakarta-tomcat-4.0/jasper/src/share/org/apache/jasper/compiler/JspLineMapItem.java,v
 1.1 2001/07/12 21:41:10 horwat Exp $
   * $Revision: 1.1 $
   * $Date: 2001/07/12 21:41:10 $
   *
   * ====================================================================
   * 
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999 The Apache Software Foundation.  All rights 
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer. 
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:  
   *       "This product includes software developed by the 
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written 
   *    permission, please contact [EMAIL PROTECTED]
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   */ 
  package org.apache.jasper.compiler;
  
  /**
   * Data structure used for each individual line map item.
   * This data structure has a set of numbers representing the 
   * beginning and ending jsp line numbers and the associated 
   * generated servlet lines.
   *
   * @author Justyna Horwat
   */
  public class JspLineMapItem {
  
      private int[] itemArray;
  
      public JspLineMapItem() {
          itemArray = new int[8];
      }
  
      /**
       * Set the beginning servlet line number
       */
      public void setBeginServletLnr(int item) {
          itemArray[0] = item;
      }
  
      /**
       * Get the beginning servlet line number
       */
      public int getBeginServletLnr() {
          return itemArray[0];
      }
  
      /**
       * Set the ending servlet line number
       */
      public void setEndServletLnr(int item) {
          itemArray[1] = item;
      }
  
      /**
       * Get the ending servlet line number
       */
      public int getEndServletLnr() {
          return itemArray[1];
      }
  
      /**
       * Set the index of the starting jsp file
       */
      public void setStartJspFileNr(int item) {
          itemArray[2] = item;
      }
  
      /**
       * Get the index of the starting jsp file
       */
      public int getStartJspFileNr() {
          return itemArray[2];
      }
  
      /**
       * Set the beginning jsp line number
       */
      public void setBeginJspLnr(int item) {
          itemArray[3] = item;
      }
  
      /**
       * Get the beginning jsp line number
       */
      public int getBeginJspLnr() {
          return itemArray[3];
      }
  
      /**
       * Set the beginning jsp column number
       */
      public void setBeginJspColNr(int item) {
          itemArray[4] = item;
      }
  
      /**
       * Get the beginning jsp column number
       */
      public int getBeginJspColNr() {
          return itemArray[4];
      }
  
      /**
       * Set the index of the stopping jsp file
       */
      public void setStopJspFileNr(int item) {
          itemArray[5] = item;
      }
  
      /**
       * Get the index of the stopping jsp file
       */
      public int getStopJspFileNr() {
          return itemArray[5];
      }
  
      /**
       * Set the ending jsp line number
       */
      public void setEndJspLnr(int item) {
          itemArray[6] = item;
      }
  
      /**
       * Get the ending jsp line number
       */
      public int getEndJspLnr() {
          return itemArray[6];
      }
  
      /**
       * Set the ending jsp column number
       */
      public void setEndJspColNr(int item) {
          itemArray[7] = item;
      }
  
      /**
       * Get the ending jsp column number
       */
      public int getEndJspColNr() {
          return itemArray[7];
      }
  
      /**
       * Convert data structure to a string
       */
      public String toString() {
          StringBuffer out = new StringBuffer();
  
          for (int j=0; j < itemArray.length; j++) {
              out.append("["+j+"] " + itemArray[j]+" ");
          }
          out.append("\n");
  
          return out.toString();
      }
  }
  
  
  
  1.1                  
jakarta-tomcat-4.0/jasper/src/share/org/apache/jasper/compiler/JspLineMap.java
  
  Index: JspLineMap.java
  ===================================================================
  /*
   * $Header: 
/home/cvs/jakarta-tomcat-4.0/jasper/src/share/org/apache/jasper/compiler/JspLineMap.java,v
 1.1 2001/07/12 21:41:10 horwat Exp $
   * $Revision: 1.1 $
   * $Date: 2001/07/12 21:41:10 $
   *
   * ====================================================================
   * 
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999 The Apache Software Foundation.  All rights 
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer. 
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:  
   *       "This product includes software developed by the 
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written 
   *    permission, please contact [EMAIL PROTECTED]
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   */ 
  package org.apache.jasper.compiler;
  
  import java.util.ArrayList;
  
  /**
   * Data structure to store the line and file map information.
   * The line map has a mapping of which jsp lines correspond to
   * the generated servlet. The file map has all of jsp files
   * that are included in the servlet.
   *
   * @author Justyna Horwat
   */
  public class JspLineMap {
  
      private ArrayList lineMap;
      private ArrayList fileMap;
  
      public JspLineMap() {
          lineMap = new ArrayList();
          fileMap = new ArrayList();
      }
  
      /**
       * Add an item to the line map data structure
       */
      public void add(JspLineMapItem lineMapItem) {
          lineMap.add(lineMapItem);
      }
  
      /**
       * Get an item to the line map data structure
       */
      public JspLineMapItem get(int index) {
          return (JspLineMapItem) lineMap.get(index);
      }
  
      /**
       * Get line map data structure size
       */
      public int size() {
          return lineMap.size();
      }
  
      public void clear() {
          lineMap.clear();
          fileMap.clear();
      }
  
      /**
       * Add a file to the file map data structure. The index is
       * stored in the line map to associate a file with the line
       * of code.
       */
      public int addFileName(String fileName) {
          int idx = fileMap.indexOf(fileName);
  
          if (idx>=0) return idx;
  
          fileName = fileName.replace( '\\', '/' );
          fileMap.add(fileName);
          idx = fileMap.size() - 1 ; // added item
  
          return idx;
      }
  
      /**
       * Get a file from the file map data structure. Use the index
       * to grab the right file name.
       */
      public String getFileName(int index) {
          return (String) fileMap.get(index);
      }
  
      /**
       * Convert data structures to a string
       */
      public String toString() {
          int i;
          JspLineMapItem lineMapItem;
          StringBuffer out = new StringBuffer();
  
          out.append("JspLineMap Debugging:\n");
          out.append("lineMap: \n");
          for (i=0; i < lineMap.size(); i++) {
              lineMapItem = (JspLineMapItem) lineMap.get(i);
              out.append("#" + i + ": ");
              out.append(lineMapItem.toString());
          }
  
          out.append("fileMap: \n");
  
          for (i=0; i < fileMap.size(); i++) {
              out.append("#" + i + ": " + fileMap.get(i) + "\n");
          }
  
          return out.toString();
      }
  
  }
  
  
  
  1.18      +5 -1      
jakarta-tomcat-4.0/jasper/src/share/org/apache/jasper/resources/messages.properties
  
  Index: messages.properties
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat-4.0/jasper/src/share/org/apache/jasper/resources/messages.properties,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- messages.properties       2001/04/27 18:09:36     1.17
  +++ messages.properties       2001/07/12 21:41:31     1.18
  @@ -1,4 +1,4 @@
  -# $Id: messages.properties,v 1.17 2001/04/27 18:09:36 craigmcc Exp $
  +# $Id: messages.properties,v 1.18 2001/07/12 21:41:31 horwat Exp $
   #
   # Default localized string information
   # Localized this the Default Locale as is en_US
  @@ -237,3 +237,7 @@
   jsp.error.taglib.jarFileException=
   jsp.error.invalid.javaEncoding=Invalid java encodings. Tried {0} and then {1}. Both 
failed.
   jsp.error.needAlternateJavaEncoding=Default java encoding {0} is invalid on your 
java platform. An alternate can be specified via the 'javaEncoding' parameter of 
JspServlet.
  +#Error when compiling, used for jsp line number error messages
  +jsp.error.single.line.number=\n\nAn error occurred at line: {0} in the jsp file: 
{1}\n\n
  +jsp.error.multiple.line.number=\n\nAn error occured between lines: {0} and {1} in 
the jsp file: {2}\n\n
  +jsp.error.corresponding.servlet=Generated servlet error:\n
  
  
  

Reply via email to