Package org.apache.jasper.compiler
Class SmapStratum
- java.lang.Object
-
- org.apache.jasper.compiler.SmapStratum
-
public class SmapStratum extends java.lang.ObjectRepresents the line and file mappings associated with a JSR-045 "stratum".
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classSmapStratum.LineInfoRepresents a single LineSection in an SMAP, associated with a particular stratum.
-
Constructor Summary
Constructors Constructor Description SmapStratum()Creates a new empty SmapStratum.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddFile(java.lang.String filename)Adds record of a new file, by filename.voidaddFile(java.lang.String filename, java.lang.String filePath)Adds record of a new file, by filename and path.voidaddLineData(int inputStartLine, java.lang.String inputFileName, int inputLineCount, int outputStartLine, int outputLineIncrement)Adds complete information about a simple line mapping.voidaddLineInfo(SmapStratum.LineInfo li)Adds a pre-configured LineInfo to this stratum's line data.java.lang.StringgetClassFileName()Returns the name of the output .class file.SmapInputgetInputLineNumber(int outputLineNumber)Maps a generated Java file line number back to the original JSP source file and line number.java.lang.StringgetSmapString()Generates the complete SMAP string representation of this stratum.voidoptimizeLineSection()Combines consecutive LineInfos wherever possiblevoidsetClassFileName(java.lang.String classFileName)Sets the name of the output .class file for the SMAP.voidsetOutputFileName(java.lang.String outputFileName)Sets the name of the output .java file for the SMAP header.java.lang.StringtoString()Returns the SMAP string representation of this stratum.
-
-
-
Method Detail
-
addFile
public void addFile(java.lang.String filename)
Adds record of a new file, by filename.- Parameters:
filename- the filename to add, unqualified by path.
-
addFile
public void addFile(java.lang.String filename, java.lang.String filePath)Adds record of a new file, by filename and path. The path may be relative to a source compilation path.- Parameters:
filename- the filename to add, unqualified by pathfilePath- the path for the filename, potentially relative to a source compilation path
-
optimizeLineSection
public void optimizeLineSection()
Combines consecutive LineInfos wherever possible
-
addLineData
public void addLineData(int inputStartLine, java.lang.String inputFileName, int inputLineCount, int outputStartLine, int outputLineIncrement)Adds complete information about a simple line mapping. Specify all the fields in this method; the back-end machinery takes care of printing only those that are necessary in the final SMAP. (My view is that fields are optional primarily for spatial efficiency, not for programmer convenience. Could always add utility methods later.)- Parameters:
inputStartLine- starting line in the source file (SMAPInputStartLine)inputFileName- the filepath (or name) from which the input comes (yields SMAPLineFileID) Use unqualified names carefully, and only when they uniquely identify a file.inputLineCount- the number of lines in the input to map (SMAPLineFileCount)outputStartLine- starting line in the output file (SMAPOutputStartLine)outputLineIncrement- number of output lines to map to each input line (SMAPOutputLineIncrement). Given the fact that the name starts with "output", I continuously have the subconscious urge to call this fieldOutputLineExcrement.
-
addLineInfo
public void addLineInfo(SmapStratum.LineInfo li)
Adds a pre-configured LineInfo to this stratum's line data.- Parameters:
li- the line info to add
-
setOutputFileName
public void setOutputFileName(java.lang.String outputFileName)
Sets the name of the output .java file for the SMAP header.- Parameters:
outputFileName- the output Java file name
-
setClassFileName
public void setClassFileName(java.lang.String classFileName)
Sets the name of the output .class file for the SMAP.- Parameters:
classFileName- the output class file name
-
getClassFileName
public java.lang.String getClassFileName()
Returns the name of the output .class file.- Returns:
- the class file name
-
toString
public java.lang.String toString()
Returns the SMAP string representation of this stratum.- Overrides:
toStringin classjava.lang.Object- Returns:
- the SMAP string representation
-
getSmapString
public java.lang.String getSmapString()
Generates the complete SMAP string representation of this stratum.- Returns:
- the SMAP string
- Throws:
java.lang.IllegalStateException- if the output file name has not been set
-
getInputLineNumber
public SmapInput getInputLineNumber(int outputLineNumber)
Maps a generated Java file line number back to the original JSP source file and line number.- Parameters:
outputLineNumber- the line number in the generated Java file- Returns:
- the corresponding source file and line number
-
-