Package org.apache.catalina
Interface WebResource
-
- All Known Implementing Classes:
AbstractArchiveResource,AbstractResource,AbstractSingleArchiveResource,CachedResource,EmptyResource,FileResource,JarResource,JarResourceRoot,JarWarResource,VirtualResource,WarResource
public interface WebResourceRepresents a file or directory within a web application. It borrows heavily fromFile.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description booleancanRead()Checks if this resource can be read.booleandelete()Deletes this resource.booleanexists()Checks if this resource exists.java.lang.StringgetCanonicalPath()Returns the canonical path of this resource.java.security.cert.Certificate[]getCertificates()Returns the certificates that were used to sign this resource to verify it.java.net.URLgetCodeBase()byte[]getContent()Returns the binary content of this resource.longgetContentLength()Returns the content length of this resource.longgetCreation()Returns the creation time of this resource.java.lang.StringgetETag()Returns the weak ETag calculated from the content length and last modified.java.io.InputStreamgetInputStream()Obtains an InputStream based on the contents of this resource.longgetLastModified()Returns the last modified time.java.lang.StringgetLastModifiedHttp()Returns the last modified time in HTTP format.java.util.jar.ManifestgetManifest()Returns the manifest associated with this resource.java.lang.StringgetMimeType()Returns the MIME type for this Resource.java.lang.StringgetName()Returns the name of this resource.default java.lang.StringgetStrongETag()Return the strong ETag if available else return the weak ETag calculated from the content length and last modified.java.net.URLgetURL()Returns a URL to access this resource.java.lang.StringgetWebappPath()Returns the webapp path of this resource.WebResourceRootgetWebResourceRoot()Returns a reference to the WebResourceRoot of which this WebResource is a part.booleanisDirectory()Checks if this resource is a directory.booleanisFile()Checks if this resource is a file.booleanisVirtual()Indicates if this resource is required for applications to correctly scan the file structure but that does not exist in either the main or any additionalWebResourceSet.voidsetMimeType(java.lang.String mimeType)Set the MIME type for this Resource.
-
-
-
Method Detail
-
getLastModified
long getLastModified()
Returns the last modified time.- Returns:
File.lastModified().
-
getLastModifiedHttp
java.lang.String getLastModifiedHttp()
Returns the last modified time in HTTP format.- Returns:
- the last modified time of this resource in the correct format for the HTTP Last-Modified header as specified by RFC 2616.
-
exists
boolean exists()
Checks if this resource exists.- Returns:
File.exists().
-
isVirtual
boolean isVirtual()
Indicates if this resource is required for applications to correctly scan the file structure but that does not exist in either the main or any additionalWebResourceSet. For example, if an external directory is mapped to /WEB-INF/lib in an otherwise empty web application, /WEB-INF will be represented as a virtual resource.- Returns:
truefor a virtual resource
-
isDirectory
boolean isDirectory()
Checks if this resource is a directory.- Returns:
File.isDirectory().
-
isFile
boolean isFile()
Checks if this resource is a file.- Returns:
File.isFile().
-
delete
boolean delete()
Deletes this resource.- Returns:
File.delete().
-
getName
java.lang.String getName()
Returns the name of this resource.- Returns:
File.getName().
-
getContentLength
long getContentLength()
Returns the content length of this resource.- Returns:
File.length().
-
getCanonicalPath
java.lang.String getCanonicalPath()
Returns the canonical path of this resource.- Returns:
File.getCanonicalPath().
-
canRead
boolean canRead()
Checks if this resource can be read.- Returns:
File.canRead().
-
getWebappPath
java.lang.String getWebappPath()
Returns the webapp path of this resource.- Returns:
- The path of this resource relative to the web application root. If the resource is a directory, the return value will end in '/'.
-
getETag
java.lang.String getETag()
Returns the weak ETag calculated from the content length and last modified.- Returns:
- The ETag for this resource
-
getStrongETag
default java.lang.String getStrongETag()
Return the strong ETag if available else return the weak ETag calculated from the content length and last modified.- Returns:
- The ETag for this resource
-
setMimeType
void setMimeType(java.lang.String mimeType)
Set the MIME type for this Resource.- Parameters:
mimeType- The mime type that will be associated with the resource
-
getMimeType
java.lang.String getMimeType()
Returns the MIME type for this Resource.- Returns:
- the MIME type for this Resource.
-
getInputStream
java.io.InputStream getInputStream()
Obtains an InputStream based on the contents of this resource.- Returns:
- An InputStream based on the contents of this resource or
nullif the resource does not exist or does not represent a file
-
getContent
byte[] getContent()
Returns the binary content of this resource.- Returns:
- the binary content of this resource or
nullif it is not available in a byte[] because, for example, it is too big.
-
getCreation
long getCreation()
Returns the creation time of this resource.- Returns:
- The time the file was created. If not available, the result of
getLastModified()will be returned.
-
getURL
java.net.URL getURL()
Returns a URL to access this resource.- Returns:
- a URL to access the resource or
nullif no such URL is available or if the resource does not exist.
-
getCodeBase
java.net.URL getCodeBase()
- Returns:
- the code base for this resource that will be used when looking up the assigned permissions for the code base in the security policy file when running under a security manager.
-
getWebResourceRoot
WebResourceRoot getWebResourceRoot()
Returns a reference to the WebResourceRoot of which this WebResource is a part.- Returns:
- a reference to the WebResourceRoot of which this WebResource is a part.
-
getCertificates
java.security.cert.Certificate[] getCertificates()
Returns the certificates that were used to sign this resource to verify it.- Returns:
- the certificates that were used to sign this resource to verify it or @null if none.
- See Also:
JarEntry.getCertificates()
-
getManifest
java.util.jar.Manifest getManifest()
Returns the manifest associated with this resource.- Returns:
- the manifest associated with this resource or @null if none.
- See Also:
JarFile.getManifest()
-
-