Package org.zkoss.web.util.resource
Class ServletContextLocator
- java.lang.Object
-
- org.zkoss.web.util.resource.ServletContextLocator
-
- All Implemented Interfaces:
org.zkoss.util.resource.Locator
public class ServletContextLocator extends java.lang.Object implements org.zkoss.util.resource.LocatorLocator based on ServletContext.- Author:
- tomyeh
-
-
Constructor Summary
Constructors Constructor Description ServletContextLocator(javax.servlet.ServletContext ctx)Constructor.ServletContextLocator(javax.servlet.ServletContext ctx, boolean acceptURL)Constructor.ServletContextLocator(javax.servlet.ServletContext ctx, java.lang.String dir)Constructor.ServletContextLocator(javax.servlet.ServletContext ctx, java.lang.String dir, java.lang.String prefix)Constructor.ServletContextLocator(javax.servlet.ServletContext ctx, java.lang.String dir, java.lang.String prefix, boolean acceptURL)Constructor.ServletContextLocator(javax.servlet.ServletContext ctx, java.lang.String dir, java.lang.String prefix, boolean acceptURL, java.lang.String externalPrefix)Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(java.lang.Object o)java.lang.StringgetDirectory()java.net.URLgetResource(java.lang.String name)java.io.InputStreamgetResourceAsStream(java.lang.String name)javax.servlet.ServletContextgetServletContext()Returns the servlet context.inthashCode()
-
-
-
Constructor Detail
-
ServletContextLocator
public ServletContextLocator(javax.servlet.ServletContext ctx)
Constructor. A short cut of ServletContextLocator(ctx, null, null, false)
-
ServletContextLocator
public ServletContextLocator(javax.servlet.ServletContext ctx, boolean acceptURL)Constructor.- Parameters:
acceptURL- whether to URL (such as file:/, http:// and ftp://) are accepted. In other words,Servlets.getResource(javax.servlet.ServletContext, java.lang.String)will be used.- Since:
- 5.0.7
- See Also:
Servlets.getResource(javax.servlet.ServletContext, java.lang.String)
-
ServletContextLocator
public ServletContextLocator(javax.servlet.ServletContext ctx, java.lang.String dir)Constructor. A short of ServletContextLocator(ctx, dir, null, false, null).- Parameters:
dir- the directory used when relative path is specified (forgetResource(java.lang.String)andgetResourceAsStream(java.lang.String)). It must be null, empty, or starts with /.
-
ServletContextLocator
public ServletContextLocator(javax.servlet.ServletContext ctx, java.lang.String dir, java.lang.String prefix)Constructor. A short cut of ServletContextLocator(ctx, dir, prefix, false, null).
-
ServletContextLocator
public ServletContextLocator(javax.servlet.ServletContext ctx, java.lang.String dir, java.lang.String prefix, boolean acceptURL)Constructor. A short cut of ServletContextLocator(ctx, dir, prefix, acceptURL, null).
-
ServletContextLocator
public ServletContextLocator(javax.servlet.ServletContext ctx, java.lang.String dir, java.lang.String prefix, boolean acceptURL, java.lang.String externalPrefix)Constructor. For example, if prefix is "/WEB-INF/cwr", then getResource("/abc") will look for "/WEB-INF/cwr/abc" first, and then "/abc".Another example, if prefix is "/WEB-INF/cwr" and dir is "/subdir", then getResource("abc") will look for "/WEB-INF/cwr/subdir/abc".
- Parameters:
dir- the directory used when relative path is specified (forgetResource(java.lang.String)andgetResourceAsStream(java.lang.String)). It must be null, empty, or starts with /.prefix- the directory to prefix each directory specified (forgetResource(java.lang.String)andgetResourceAsStream(java.lang.String)). It must be null, empty, or starts with /.acceptURL- whether to URL (such as file:/, http:// and ftp://) are accepted. In other words,Servlets.getResource(javax.servlet.ServletContext, java.lang.String)will be used.
-
-
Method Detail
-
getServletContext
public javax.servlet.ServletContext getServletContext()
Returns the servlet context.
-
getDirectory
public java.lang.String getDirectory()
- Specified by:
getDirectoryin interfaceorg.zkoss.util.resource.Locator
-
getResource
public java.net.URL getResource(java.lang.String name)
- Specified by:
getResourcein interfaceorg.zkoss.util.resource.Locator
-
getResourceAsStream
public java.io.InputStream getResourceAsStream(java.lang.String name)
- Specified by:
getResourceAsStreamin interfaceorg.zkoss.util.resource.Locator
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equalsin classjava.lang.Object
-
-