FileDocCategorySizeDatePackage
Mark.javaAPI DocApache Tomcat 6.0.148088Fri Jul 20 04:20:34 BST 2007org.apache.jasper.compiler

Mark

public final class Mark extends Object
Mark represents a point in the JSP input.
author
Anil K. Vijendran

Fields Summary
int
cursor
int
line
int
col
String
baseDir
char[]
stream
private int
fileId
private String
fileName
private Stack
includeStack
private String
encoding
private JspReader
reader
private org.apache.jasper.JspCompilationContext
ctxt
Constructors Summary
Mark(JspReader reader, char[] inStream, int fileId, String name, String inBaseDir, String inEncoding)
Constructor

param
reader JspReader this mark belongs to
param
inStream current stream for this mark
param
fileId id of requested jsp file
param
name JSP file name
param
inBaseDir base directory of requested jsp file
param
inEncoding encoding of current file


                                                  
           
             

        this.reader = reader;
        this.ctxt = reader.getJspCompilationContext();
        this.stream = inStream;
        this.cursor = 0;
        this.line = 1;
        this.col = 1;
        this.fileId = fileId;
        this.fileName = name;
        this.baseDir = inBaseDir;
        this.encoding = inEncoding;
        this.includeStack = new Stack();
    
Mark(Mark other)
Constructor


        this.reader = other.reader;
        this.ctxt = other.reader.getJspCompilationContext();
        this.stream = other.stream;
        this.fileId = other.fileId;
        this.fileName = other.fileName;
        this.cursor = other.cursor;
        this.line = other.line;
        this.col = other.col;
        this.baseDir = other.baseDir;
        this.encoding = other.encoding;

        // clone includeStack without cloning contents
        includeStack = new Stack();
        for ( int i=0; i < other.includeStack.size(); i++ ) {
            includeStack.addElement( other.includeStack.elementAt(i) );
        }
    
Mark(org.apache.jasper.JspCompilationContext ctxt, String filename, int line, int col)
Constructor


        this.reader = null;
        this.ctxt = ctxt;
        this.stream = null;
        this.cursor = 0;
        this.line = line;
        this.col = col;
        this.fileId = -1;
        this.fileName = filename;
        this.baseDir = "le-basedir";
        this.encoding = "le-endocing";
        this.includeStack = null;
    
Methods Summary
public booleanequals(java.lang.Object other)

	if (other instanceof Mark) {
	    Mark m = (Mark) other;
	    return this.reader == m.reader && this.fileId == m.fileId 
		&& this.cursor == m.cursor && this.line == m.line 
		&& this.col == m.col;
	} 
	return false;
    
public intgetColumnNumber()

        return col;
    
public java.lang.StringgetFile()

        return this.fileName;
    
public intgetLineNumber()

        return line;
    
public java.lang.StringgetPublicId()

        return null;
    
public java.lang.StringgetSystemId()

        return getFile();
    
public java.net.URLgetURL()
Gets the URL of the resource with which this Mark is associated

return
URL of the resource with which this Mark is associated
exception
MalformedURLException if the resource pathname is incorrect

        return ctxt.getResource(getFile());
    
public booleanisGreater(org.apache.jasper.compiler.Mark other)

return
true if this Mark is greather than the other Mark, false otherwise.


        boolean greater = false;

        if (this.line > other.line) {
            greater = true;
        } else if (this.line == other.line && this.col > other.col) {
            greater = true;
        }

        return greater;
    
public org.apache.jasper.compiler.MarkpopStream()
Restores this mark's state to a previously stored stream.

return
The previous Mark instance when the stream was pushed, or null if there is no previous stream

        // make sure we have something to pop
        if ( includeStack.size() <= 0 ) {
            return null;
        }

        // get previous state in stack
        IncludeState state = (IncludeState) includeStack.pop( );

        // set new variables
        cursor = state.cursor;
        line = state.line;
        col = state.col;
        fileId = state.fileId;
        fileName = state.fileName;
        baseDir = state.baseDir;
        stream = state.stream;
        return this;
    
public voidpushStream(char[] inStream, int inFileId, java.lang.String name, java.lang.String inBaseDir, java.lang.String inEncoding)
Sets this mark's state to a new stream. It will store the current stream in it's includeStack.

param
inStream new stream for mark
param
inFileId id of new file from which stream comes from
param
inBaseDir directory of file
param
inEncoding encoding of new file

        // store current state in stack
        includeStack.push(new IncludeState(cursor, line, col, fileId,
                                           fileName, baseDir, 
					   encoding, stream) );

        // set new variables
        cursor = 0;
        line = 1;
        col = 1;
        fileId = inFileId;
        fileName = name;
        baseDir = inBaseDir;
        encoding = inEncoding;
        stream = inStream;
    
public java.lang.StringtoShortString()

        return "("+line+","+col+")";
    
public java.lang.StringtoString()

	return getFile()+"("+line+","+col+")";