Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * Licensed to the Apache Software Foundation (ASF) under one or more
   * contributor license agreements.  See the NOTICE file distributed with
   * this work for additional information regarding copyright ownership.
   * The ASF licenses this file to You under the Apache License, Version 2.0
   * (the "License"); you may not use this file except in compliance with
   * the License.  You may obtain a copy of the License at
   * 
   *      http://www.apache.org/licenses/LICENSE-2.0
  * 
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
 package org.apache.jasper.compiler;
 
 import java.net.URL;
Mark represents a point in the JSP input.

Author(s):
Anil K. Vijendran
 
 final class Mark {
 
     // position within current stream
     int cursorlinecol;
 
     // directory of file for current stream
     String baseDir;
 
     // current stream
     char[] stream = null;
 
     // fileid of current stream
     private int fileId;
 
     // name of the current file
     private String fileName;
 
     /*
      * stack of stream and stream state of streams that have included
      * current stream
      */
     private Stack includeStack = null;
 
     // encoding of current file
     private String encoding = null;
 
     // reader that owns this mark (so we can look up fileid's)
     private JspReader reader;
 
     private JspCompilationContext ctxt;

    
Constructor

Parameters:
reader JspReader this mark belongs to
inStream current stream for this mark
fileId id of requested jsp file
name JSP file name
inBaseDir base directory of requested jsp file
inEncoding encoding of current file
 
     Mark(JspReader readerchar[] inStreamint fileIdString name,
          String inBaseDirString inEncoding) {
 
         this. = reader;
         this. = reader.getJspCompilationContext();
         this. = inStream;
         this. = 0;
         this. = 1;
         this. = 1;
         this. = fileId;
         this. = name;
         this. = inBaseDir;
         this. = inEncoding;
         this. = new Stack();
     }


    
Constructor
 
     Mark(Mark other) {
 
         this. = other.reader;
         this. = other.reader.getJspCompilationContext();
         this. = other.stream;
         this. = other.fileId;
         this. = other.fileName;
         this. = other.cursor;
         this. = other.line;
         this. = other.col;
        this. = other.baseDir;
        this. = other.encoding;
        // clone includeStack without cloning contents
         = new Stack();
        for ( int i=0; i < other.includeStack.size(); i++ ) {
            .addElementother.includeStack.elementAt(i) );
        }
    }


    
Constructor
    
    Mark(JspCompilationContext ctxtString filenameint lineint col) {
        this. = null;
        this. = ctxt;
        this. = null;
        this. = 0;
        this. = line;
        this. = col;
        this. = -1;
        this. = filename;
        this. = "le-basedir";
        this. = "le-endocing";
        this. = null;
    }


    
Sets this mark's state to a new stream. It will store the current stream in it's includeStack.

Parameters:
inStream new stream for mark
inFileId id of new file from which stream comes from
inBaseDir directory of file
inEncoding encoding of new file
    public void pushStream(char[] inStreamint inFileIdString name,
                           String inBaseDirString inEncoding
    {
        // store current state in stack
        .push(new IncludeState(,
                                           
					   ) );
        // set new variables
         = 0;
         = 1;
         = 1;
         = inFileId;
         = name;
         = inBaseDir;
         = inEncoding;
         = inStream;
    }


    
Restores this mark's state to a previously stored stream.

Returns:
The previous Mark instance when the stream was pushed, or null if there is no previous stream
    public Mark popStream() {
        // make sure we have something to pop
        if ( .size() <= 0 ) {
            return null;
        }
        // get previous state in stack
        IncludeState state = (IncludeState.pop( );
        // set new variables
         = state.cursor;
         = state.line;
         = state.col;
         = state.fileId;
         = state.fileName;
         = state.baseDir;
         = state.stream;
        return this;
    }
    // -------------------- Locator interface --------------------
    public int getLineNumber() {
        return ;
    }
    public int getColumnNumber() {
        return ;
    }
    public String getSystemId() {
        return getFile();
    }
    public String getPublicId() {
        return null;
    }
    public String toString() {
	return getFile()+"("++","++")";
    }
    public String getFile() {
        return this.;
    }

    
Gets the URL of the resource with which this Mark is associated

Returns:
URL of the resource with which this Mark is associated
Throws:
java.net.MalformedURLException if the resource pathname is incorrect
    public URL getURL() throws MalformedURLException {
        return .getResource(getFile());
    }
    public String toShortString() {
        return "("++","++")";
    }
    public boolean equals(Object other) {
	if (other instanceof Mark) {
	    Mark m = (Markother;
	    return this. == m.reader && this. == m.fileId 
		&& this. == m.cursor && this. == m.line 
		&& this. == m.col;
	return false;
    }

    

Returns:
true if this Mark is greather than the other Mark, false otherwise.
    public boolean isGreater(Mark other) {
        boolean greater = false;
        if (this. > other.line) {
            greater = true;
        } else if (this. == other.line && this. > other.col) {
            greater = true;
        }
        return greater;
    }

    
Keep track of parser before parsing an included file. This class keeps track of the parser before we switch to parsing an included file. In other words, it's the parser's continuation to be reinstalled after the included file parsing is done.
    class IncludeState {
        int cursorlinecol;
        int fileId;
        String fileName;
        String baseDir;
        String encoding;
        char[] stream = null;
        IncludeState(int inCursorint inLineint inColint inFileId
                     String nameString inBaseDirString inEncoding,
                     char[] inStream) {
             = inCursor;
             = inLine;
             = inCol;
             = inFileId;
             = name;
             = inBaseDir;
             = inEncoding;
             = inStream;
        }
    }
New to GrepCode? Check out our FAQ X