FileDocCategorySizeDatePackage
ServletWriter.javaAPI DocApache Tomcat 6.0.144549Fri Jul 20 04:20:36 BST 2007org.apache.jasper.compiler

ServletWriter

public class ServletWriter extends Object
This is what is used to generate servlets.
author
Anil K. Vijendran
author
Kin-man Chung

Fields Summary
public static int
TAB_WIDTH
public static String
SPACES
private int
indent
private int
virtual_indent
PrintWriter
writer
private int
javaLine
Constructors Summary
public ServletWriter(PrintWriter writer)



       
	this.writer = writer;
    
Methods Summary
public voidclose()

	writer.close();
    
public intgetJavaLine()

        return javaLine;
    
public voidpopIndent()

	virtual_indent -= TAB_WIDTH;
	if (virtual_indent >= 0 && virtual_indent <= SPACES.length())
	    indent = virtual_indent;
    
public voidprint(char c)
Prints the given char. Use println() to print a '\n'.

	writer.print(c);
    
public voidprint(int i)
Prints the given int.

	writer.print(i);
    
public voidprint(java.lang.String s)
Prints the given string. The string must not contain any '\n', otherwise the line count will be off.

	writer.print(s);
    
public voidprintComment(Mark start, Mark stop, char[] chars)
Print a standard comment for echo outputed chunk.

param
start The starting position of the JSP chunk being processed.
param
stop The ending position of the JSP chunk being processed.

        if (start != null && stop != null) {
            println("// from="+start);
            println("//   to="+stop);
        }
        
        if (chars != null)
            for(int i = 0; i < chars.length;) {
                printin();
                print("// ");
                while (chars[i] != '\n" && i < chars.length)
                    writer.print(chars[i++]);
            }
    
public voidprintMultiLn(java.lang.String s)
Prints the given string. If the string spans multiple lines, the line count will be adjusted accordingly.

        int index = 0;

        // look for hidden newlines inside strings
        while ((index=s.indexOf('\n",index)) > -1 ) {
            javaLine++;
            index++;
        }

	writer.print(s);
    
public voidprintil(java.lang.String s)
Prints the current indention, and then the string, and a '\n'.

        javaLine++;
	writer.print(SPACES.substring(0, indent));
	writer.println(s);
    
public voidprintin(java.lang.String s)
Prints the current indention, followed by the given string

	writer.print(SPACES.substring(0, indent));
	writer.print(s);
    
public voidprintin()
Prints the current indention

	writer.print(SPACES.substring(0, indent));
    
public voidprintln(java.lang.String s)
Prints the given string followed by '\n'

        javaLine++;
	writer.println(s);
    
public voidprintln()
Prints a '\n'

        javaLine++;
	writer.println("");
    
public voidpushIndent()

	virtual_indent += TAB_WIDTH;
	if (virtual_indent >= 0 && virtual_indent <= SPACES.length())
	    indent = virtual_indent;