public JspCompilationContext getJspCompilationContext () { return ctxt;
}
public Compiler getCompiler () { return compiler;
}
/** *ParsesaJSPpageortagfile.Thisisinvokedbythecompiler. * *@paraminFileNameThepathtotheJSPpageortagfiletobeparsed. * *@returnTheparsednodes * *@throwsJasperExceptionIfanerroroccursduringparsing *@throwsIOExceptionIfanI/Oerroroccurssuchasthefilenotbeing *found
*/ public Node.Nodes parse(String inFileName) throws JasperException, IOException { // If we're parsing a packaged tag file or a resource included by it // (using an include directive), ctxt.getTagFileJar() returns the // JAR file from which to read the tag file or included resource, // respectively.
isTagFile = ctxt.isTagFile();
directiveOnly = false; return doParse(inFileName, null, ctxt.getTagFileJar());
}
/** *ParsesthedirectivesofaJSPpageortagfile.Thisisinvokedbythe *compiler. * *@paraminFileNameThepathtotheJSPpageortagfiletobeparsed. * *@returnTheparseddirectivenodes * *@throwsJasperExceptionIfanerroroccursduringparsing *@throwsIOExceptionIfanI/Oerroroccurssuchasthefilenotbeing *found
*/ public Node.Nodes parseDirectives(String inFileName) throws JasperException, IOException { // If we're parsing a packaged tag file or a resource included by it // (using an include directive), ctxt.getTagFileJar() returns the // JAR file from which to read the tag file or included resource, // respectively.
isTagFile = ctxt.isTagFile();
directiveOnly = true; return doParse(inFileName, null, ctxt.getTagFileJar());
}
/** *Processesanincludedirectivewiththegivenpath. * *@paraminFileNameThepathtotheresourcetobeincluded. *@paramparentTheparentnodeoftheincludedirective. *@paramjarTheJARfilefromwhichtoreadtheincludedresource, *ornulloftheincludedresourceistobereadfromthefilesystem * *@returnTheparsednodes * *@throwsJasperExceptionIfanerroroccursduringparsing *@throwsIOExceptionIfanI/Oerroroccurssuchasthefilenotbeing *found
*/ public Node.Nodes parse(String inFileName, Node parent, Jar jar) throws JasperException, IOException { // For files that are statically included, isTagfile and directiveOnly // remain unchanged. return doParse(inFileName, parent, jar);
}
JspConfig jspConfig = ctxt.getOptions().getJspConfig();
JspConfig.JspProperty jspProperty = jspConfig.findJspProperty(
absFileName); if (jspProperty.isXml() != null) { // If <is-xml> is specified in a <jsp-property-group>, it is used.
isXml = JspUtil.booleanValue(jspProperty.isXml());
isExternal = true;
} elseif (absFileName.endsWith(".jspx")
|| absFileName.endsWith(".tagx")) {
isXml = true;
isExternal = true;
}
if (isExternal && !isXml) { // JSP (standard) syntax. Use encoding specified in jsp-config // if provided.
sourceEnc = jspConfigPageEnc; if (sourceEnc != null) { return;
} // We don't know the encoding, so use BOM to determine it
sourceEnc = "ISO-8859-1";
} else { // XML syntax or unknown, (auto)detect encoding ...
EncodingDetector encodingDetector; try (BufferedInputStream bis = JspUtil.getInputStream(absFileName, jar, ctxt)) {
encodingDetector = new EncodingDetector(bis);
}
if (isXml) { // (This implies 'isExternal' is TRUE.) // We know we're dealing with a JSP document (via JSP config or // ".jspx" suffix), so we're done. return;
}
/* *Determinepageencodingfromdirectiveoftheform<%@page%>, *<%@tag%>,<jsp:directive.page>or<jsp:directive.tag>.
*/ while (true) { if (jspReader.skipUntil("<") == null) { break;
} // If this is a comment, skip until its end if (jspReader.matches("%--")) { if (jspReader.skipUntil("--%>") == null) { // error will be caught in Parser break;
} continue;
} boolean isDirective = jspReader.matches("%@"); if (isDirective) {
jspReader.skipSpaces();
} else {
isDirective = jspReader.matches("jsp:directive.");
} if (!isDirective) { continue;
}
// Want to match tag and page but not taglib if (jspReader.matches("tag") && !jspReader.matches("lib") || jspReader.matches("page")) {
// <prefix>:root must be the first element
Mark start = null; while ((start = reader.skipUntil("<")) != null) { int c = reader.nextChar(); if (c != '!' && c != '?') { break;
}
} if (start == null) { returnfalse;
}
Mark stop = reader.skipUntil(":root"); if (stop == null) { returnfalse;
} // call substring to get rid of leading '<'
String prefix = reader.getText(start, stop).substring(1);
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.