Class StaticResourceServlet.LocalResource
- java.lang.Object
-
- de.businesscode.bcdui.web.servlets.StaticResourceServlet.LocalResource
-
- All Implemented Interfaces:
StaticResourceServlet.Resource
- Enclosing class:
- StaticResourceServlet
public static class StaticResourceServlet.LocalResource extends java.lang.Object implements StaticResourceServlet.Resource
This class represents one single resource which is either a file on the file system or a URL from the classpath. Please note that a resource which could not be located results is also represented by a Resource object, but the notFound() method will return true. This is useful, because a not-found resource has also a lookup path so the getPath() method works also in this case.
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
LocalResource(java.lang.String path, java.io.File file, java.net.URL url)
Constructs a resource which is 1) An empty resource if file and url are null, 2) A file resource if file is not null and url is null, 3) A classpath resource if file is null and url is not.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description byte[]
getData()
Completely reads the resource data from the file system or classpath.java.lang.Long
getLastModified()
java.lang.String
getPath()
boolean
notFound()
-
-
-
Constructor Detail
-
LocalResource
protected LocalResource(java.lang.String path, java.io.File file, java.net.URL url)
Constructs a resource which is 1) An empty resource if file and url are null, 2) A file resource if file is not null and url is null, 3) A classpath resource if file is null and url is not. The constructor cannot be invoked directly; instead one of the factory methods fetchResource(...) must be used.- Parameters:
path
- The original path of the resource request. It must not be null.file
- The reference to the file if this is a file resource. This can be null.url
- The URL of the classpath resource. This can be null.
-
-
Method Detail
-
getPath
public java.lang.String getPath()
- Specified by:
getPath
in interfaceStaticResourceServlet.Resource
- Returns:
- The non-null, fully qualified resource request path.
-
notFound
public boolean notFound()
- Specified by:
notFound
in interfaceStaticResourceServlet.Resource
- Returns:
- True, if this resource object points to a non-existent resource.
-
getLastModified
public java.lang.Long getLastModified() throws java.io.IOException
- Specified by:
getLastModified
in interfaceStaticResourceServlet.Resource
- Returns:
- The last modification timestamp of the resource. is NULL if resource does not exist
- Throws:
java.io.IOException
-
getData
public byte[] getData() throws java.io.IOException
Description copied from interface:StaticResourceServlet.Resource
Completely reads the resource data from the file system or classpath.- Specified by:
getData
in interfaceStaticResourceServlet.Resource
- Returns:
- The resource data.
- Throws:
java.io.IOException
-
-