Methods Summary |
---|
public void | addTaglib(java.lang.String uri, org.apache.jasper.compiler.TagLibraryInfoImpl taglib)Adds the given tag library with the given URI to the context-wide
tag library cache.
taglibs.put(uri, taglib);
|
private static final java.lang.String | canonicalURI(java.lang.String s)
if (s == null) return null;
StringBuffer result = new StringBuffer();
final int len = s.length();
int pos = 0;
while (pos < len) {
char c = s.charAt(pos);
if ( isPathSeparator(c) ) {
/*
* multiple path separators.
* 'foo///bar' -> 'foo/bar'
*/
while (pos+1 < len && isPathSeparator(s.charAt(pos+1))) {
++pos;
}
if (pos+1 < len && s.charAt(pos+1) == '.") {
/*
* a single dot at the end of the path - we are done.
*/
if (pos+2 >= len) break;
switch (s.charAt(pos+2)) {
/*
* self directory in path
* foo/./bar -> foo/bar
*/
case '/":
case '\\":
pos += 2;
continue;
/*
* two dots in a path: go back one hierarchy.
* foo/bar/../baz -> foo/baz
*/
case '.":
// only if we have exactly _two_ dots.
if (pos+3 < len && isPathSeparator(s.charAt(pos+3))) {
pos += 3;
int separatorPos = result.length()-1;
if (separatorPos < 0) {
throw new JasperException(
Localizer.getMessage("jsp.error.badpath",s));
}
while (separatorPos >= 0 &&
! isPathSeparator(result
.charAt(separatorPos))) {
--separatorPos;
}
if (separatorPos >= 0)
result.setLength(separatorPos);
continue;
}
}
}
}
result.append(c);
++pos;
}
return result.toString();
|
public void | clearTagFileJarUrls()Clears the context-wide mappings from JAR packaged tag file paths to
their corresponding URLs.
tagFileJarUrls.clear();
|
public void | clearTaglibs()Clears the context-wide tag library cache.
taglibs.clear();
|
public void | compile()
createCompiler(false);
if (isPackagedTagFile || jspCompiler.isOutDated()) {
try {
jspCompiler.compile(true);
jsw.setReload(true);
jsw.setCompilationException(null);
} catch (JasperException ex) {
// Cache compilation exception
jsw.setCompilationException(ex);
throw ex;
} catch (Exception ex) {
ex.printStackTrace();
JasperException je = new JasperException(
Localizer.getMessage("jsp.error.unable.compile"),
ex);
// Cache compilation exception
jsw.setCompilationException(je);
throw je;
}
}
|
public org.apache.jasper.compiler.Compiler | createCompiler(boolean jspcMode)Create a "Compiler" object.
if (jspCompiler != null ) {
return jspCompiler;
}
jspCompiler = new Compiler(this, jsw, jspcMode);
return jspCompiler;
|
private void | createOutputDir()
String path = null;
if (isTagFile()) {
String tagName = tagInfo.getTagClassName();
path = tagName.replace('.", '/");
path = path.substring(0, path.lastIndexOf('/"));
} else {
path = getServletPackageName().replace('.", '/");
}
try {
// Append servlet or tag handler path to scratch dir
baseUrl = options.getScratchDir().toURL();
File f = new File( options.getScratchDir(), path );
outputDir = f.getPath() + File.separator;
makeOutputDir();
} catch (Exception e) {
throw new IllegalStateException("No output directory: " +
e.getMessage());
}
|
public org.apache.jasper.compiler.Compiler | createParser()Create a compiler object for parsing only.
jspCompiler = new Compiler(this, jsw);
return jspCompiler;
|
public java.lang.String | getClassFileName()
if (classFileName == null) {
classFileName = getOutputDir() + getServletClassName() + ".class";
}
return classFileName;
|
public java.lang.ClassLoader | getClassLoader()What class loader to use for loading classes while compiling
this JSP?
if( loader != null )
return loader;
return rctxt.getParentClassLoader();
|
public java.lang.String | getClassPath()The classpath that is passed off to the Java compiler.
if( classPath != null )
return classPath;
return rctxt.getClassPath();
|
public org.apache.jasper.compiler.Compiler | getCompiler()
return jspCompiler;
|
public java.lang.String | getContentType()Get the content type of this JSP.
Content type includes content type and encoding.
return contentType;
|
private java.lang.String | getDerivedPackageName()
if (derivedPackageName == null) {
int iSep = jspUri.lastIndexOf('/");
derivedPackageName = (iSep > 0) ?
JspUtil.makeJavaPackage(jspUri.substring(1,iSep)) : "";
}
return derivedPackageName;
|
public java.lang.String | getFullClassName()Full class name
if (isTagFile()) {
return tagInfo.getTagClassName();
}
return getServletPackageName() + '." + getServletClassName();
|
public java.lang.String | getJavaPath()Path of the Java file relative to the work directory.
if (javaPath != null) {
return javaPath;
}
javaPath = getFullClassName().replace('.",'/") + ".java";
return javaPath;
|
public java.lang.String | getJspFile()Path of the JSP URI. Note that this is not a file name. This is
the context rooted URI of the JSP file.
return jspUri;
|
public java.lang.ClassLoader | getJspLoader()
return new JasperLoader(new URL[] {baseUrl},
getClassLoader(),
rctxt.getPermissionCollection(),
rctxt.getCodeSource(),
rctxt.getBytecodes());
|
public Options | getOptions()Get hold of the Options object for this context.
return options;
|
public java.lang.String | getOutputDir()The output directory to generate code into. The output directory
is make up of the scratch directory, which is provide in Options,
plus the directory derived from the package name.
if (outputDir == null) {
createOutputDir();
}
return outputDir;
|
public java.lang.String | getRealPath(java.lang.String path)Gets the actual path of a URI relative to the context of
the compilation.
if (context != null) {
return context.getRealPath(path);
}
return path;
|
public java.net.URL | getResource(java.lang.String res)
try {
return context.getResource(canonicalURI(res));
} catch (JasperException ex) {
throw new MalformedURLException(ex.getMessage());
}
|
public java.io.InputStream | getResourceAsStream(java.lang.String res)Gets a resource as a stream, relative to the meanings of this
context's implementation.
return context.getResourceAsStream(canonicalURI(res));
|
public java.util.Set | getResourcePaths(java.lang.String path)
return context.getResourcePaths(canonicalURI(path));
|
public org.apache.jasper.compiler.JspRuntimeContext | getRuntimeContext()
return rctxt;
|
public java.lang.String | getServletClassName()Just the class name (does not include package name) of the
generated class.
if (className != null) {
return className;
}
if (isTagFile) {
className = tagInfo.getTagClassName();
int lastIndex = className.lastIndexOf('.");
if (lastIndex != -1) {
className = className.substring(lastIndex + 1);
}
} else {
int iSep = jspUri.lastIndexOf('/") + 1;
className = JspUtil.makeJavaIdentifier(jspUri.substring(iSep));
}
return className;
|
public javax.servlet.ServletContext | getServletContext()
return context;
|
public java.lang.String | getServletJavaFileName()Full path name of the Java file into which the servlet is being
generated.
if (servletJavaFileName == null) {
servletJavaFileName =
getOutputDir() + getServletClassName() + ".java";
}
return servletJavaFileName;
|
public java.lang.String | getServletPackageName()Package name for the generated class is make up of the base package
name, which is user settable, and the derived package name. The
derived package name directly mirrors the file heirachy of the JSP page.
if (isTagFile()) {
String className = tagInfo.getTagClassName();
int lastIndex = className.lastIndexOf('.");
String pkgName = "";
if (lastIndex != -1) {
pkgName = className.substring(0, lastIndex);
}
return pkgName;
} else {
String dPackageName = getDerivedPackageName();
if (dPackageName.length() == 0) {
return basePackageName;
}
return basePackageName + '." + getDerivedPackageName();
}
|
public java.net.URL | getTagFileJarUrl()Returns the JAR file in which the tag file for which this
JspCompilationContext was created is packaged, or null if this
JspCompilationContext does not correspond to a tag file, or if the
corresponding tag file is not packaged in a JAR.
return this.tagFileJarUrl;
|
public java.util.concurrent.ConcurrentHashMap | getTagFileJarUrls()Gets the context-wide mappings from JAR packaged tag file paths to
their corresponfing URLs.
return this.tagFileJarUrls;
|
public javax.servlet.jsp.tagext.TagInfo | getTagInfo()
return tagInfo;
|
public java.util.concurrent.ConcurrentHashMap | getTaglibs()Gets the context-wide tag library cache.
return taglibs;
|
public java.lang.String[] | getTldLocation(java.lang.String uri)Gets the 'location' of the TLD associated with the given taglib 'uri'.
String[] location =
getOptions().getTldLocationsCache().getLocation(uri);
return location;
|
public org.apache.jasper.compiler.ServletWriter | getWriter()Where is the servlet being generated?
return writer;
|
public void | incrementRemoved()
if (removed > 1) {
jspCompiler.removeGeneratedFiles();
if( rctxt != null )
rctxt.removeWrapper(jspUri);
}
removed++;
|
public boolean | isErrorPage()Are we processing something that has been declared as an
errorpage?
return isErrPage;
|
private static final boolean | isPathSeparator(char c)
return (c == '/" || c == '\\");
|
public boolean | isPrototypeMode()True if we are compiling a tag file in prototype mode.
ie we only generate codes with class for the tag handler with empty
method bodies.
return protoTypeMode;
|
public boolean | isRemoved()
if (removed > 1 ) {
return true;
}
return false;
|
public boolean | isTagFile()
return isTagFile;
|
public boolean | keepGenerated()Are we keeping generated code around?
return getOptions().getKeepGenerated();
|
public java.lang.Class | load()
try {
String name = getFullClassName();
if (options.getUsePrecompiled()) {
servletClass = getClassLoader().loadClass(name);
} else {
servletClass = getJspLoader().loadClass(name);
}
} catch (ClassNotFoundException cex) {
throw new JasperException(
Localizer.getMessage("jsp.error.unable.load"), cex);
} catch (Exception ex) {
throw new JasperException(
Localizer.getMessage("jsp.error.unable.compile"), ex);
}
removed = 0;
return servletClass;
|
public void | makeOutputDir()
synchronized(outputDirLock) {
File outDirFile = new File(outputDir);
outDirFile.mkdirs();
}
|
public java.lang.String | resolveRelativeUri(java.lang.String uri)Get the full value of a URI relative to this compilations context
uses current file as the base.
// sometimes we get uri's massaged from File(String), so check for
// a root directory deperator char
if (uri.startsWith("/") || uri.startsWith(File.separator)) {
return uri;
} else {
return baseURI + uri;
}
|
public void | setClassLoader(java.net.URLClassLoader loader)
this.loader = loader;
|
public void | setClassPath(java.lang.String classPath)The classpath that is passed off to the Java compiler.
this.classPath = classPath;
|
public void | setContentType(java.lang.String contentType)
this.contentType = contentType;
|
public void | setErrorPage(boolean isErrPage)
this.isErrPage = isErrPage;
|
public void | setPrototypeMode(boolean pm)
protoTypeMode = pm;
|
public void | setServletClassName(java.lang.String className)
this.className = className;
|
public void | setServletPackageName(java.lang.String servletPackageName)The package name into which the servlet class is generated.
this.basePackageName = servletPackageName;
|
public void | setTagInfo(javax.servlet.jsp.tagext.TagInfo tagi)
tagInfo = tagi;
|
public void | setWriter(org.apache.jasper.compiler.ServletWriter writer)
this.writer = writer;
|