/** *Constructor. * *@paramjavaFileNameThenameoftheJavafileinwhichthe *compilationerroroccurred *@paramjavaLineNumThecompilationerrorlinenumber *@paramjspFileNameThenameoftheJSPfilefromwhichtheJavasource *filewasgenerated *@paramjspBeginLineNumThestartlinenumberoftheJSPelement *responsibleforthecompilationerror *@paramerrMsgThecompilationerrormessage *@paramctxtThecompilationcontext
*/ public JavacErrorDetail(String javaFileName, int javaLineNum,
String jspFileName, int jspBeginLineNum,
StringBuilder errMsg,
JspCompilationContext ctxt) {
this.javaFileName = javaFileName; this.javaLineNum = javaLineNum; this.errMsg = errMsg; this.jspFileName = jspFileName; // Note: this.jspBeginLineNum is set at the end of this method as it may // be modified (corrected) during the execution of this method
if (jspBeginLineNum > 0 && ctxt != null) {
InputStream is = null; try {
Jar tagJar = ctxt.getTagFileJar(); if (tagJar != null) { // Strip leading '/'
String entryName = jspFileName.substring(1);
is = tagJar.getInputStream(entryName); this.jspFileName = tagJar.getURL(entryName);
} else {
is = ctxt.getResourceAsStream(jspFileName);
} // Read both files in, so we can inspect them
String[] jspLines = readFile(is);
if (jspLines.length < jspBeginLineNum) { // Avoid ArrayIndexOutOfBoundsException // Probably bug 48498 but could be some other cause
jspExtract = Localizer.getMessage("jsp.error.bug48498"); return;
}
// If the line contains the opening of a multi-line scriptlet // block, then the JSP line number we got back is probably // faulty. Scan forward to match the java line... if (jspLines[jspBeginLineNum-1].lastIndexOf("<%") >
jspLines[jspBeginLineNum-1].lastIndexOf("%>")) {
String javaLine = javaLines[javaLineNum-1].trim();
for (int i=jspBeginLineNum-1; i<jspLines.length; i++) { if (jspLines[i].contains(javaLine)) { // Update jsp line number
jspBeginLineNum = i+1; break;
}
}
}
// copy out a fragment of JSP to display to the user
StringBuilder fragment = new StringBuilder(1024); int startIndex = Math.max(0, jspBeginLineNum-1-3); int endIndex = Math.min(
jspLines.length-1, jspBeginLineNum-1+3);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.