Resource implementations,
pre-implementing typical behavior.
The "exists" method will check whether a File or InputStream can be opened; "isOpen" will always return false; "getURL" and "getFile" throw an exception; and "toString" will return the description.
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public long | contentLength()
Implements org. |
| public Resource | createRelative(String
the relative path (relative to this resource) relativePath)Implements org. |
| private void | |
| public boolean | equals(Object
the reference object with which to compare. other)Overrides java. |
| public boolean | exists()
Implements org. |
| public File | getFile()
Implements org. |
| protected File | Returns: the File to use for timestamp checking (nevernull)Determine the File to use for timestamp checking. |
| public String | getFilename()
Implements org. null,
assuming that this resource type does not have a filename.
|
| public URI | getURI()
Implements org. getURL().
|
| public URL | getURL()
Implements org. |
| public int | hashCode()
Overrides java. |
| public boolean | isFile()
Overrides default org. false.
|
| public boolean | isOpen()
Overrides default org. false.
|
| public boolean | isReadable()
Overrides default org. true for a resource
that exists (revised as of 5.1).
|
| public long | lastModified()
Implements org. |
| public ReadableByteChannel | readableChannel()
Overrides default org. Channels#newChannel(InputStream)
with the result of getInputStream().
|
| public String | toString()
Overrides java. |
| AbstractResource | back to summary |
|---|---|
| public AbstractResource() | |
| contentLength | back to summary |
|---|---|
| public long contentLength() throws IOException Implements org. This method reads the entire InputStream to determine the content length. For a custom subclass of
| |
| createRelative | back to summary |
|---|---|
| public Resource createRelative(String relativePath) throws IOException Implements org. This implementation throws a FileNotFoundException, assuming that relative resources cannot be created for this resource.
| |
| debug | back to summary |
|---|---|
| private void debug(Supplier<String> message, Throwable ex) Lazily access the logger for debug logging in case of an exception. | |
| equals | back to summary |
|---|---|
| public boolean equals(Object other) Overrides java. This implementation compares description strings.
| |
| exists | back to summary |
|---|---|
| public boolean exists() Implements org. This implementation checks whether a File can be opened, falling back to whether an InputStream can be opened. This will cover both directories and content resources.
| |
| getFile | back to summary |
|---|---|
| public File getFile() throws IOException Implements org. This implementation throws a FileNotFoundException, assuming that the resource cannot be resolved to an absolute file path.
| |
| getFileForLastModifiedCheck | back to summary |
|---|---|
| protected File getFileForLastModifiedCheck() throws IOException Determine the File to use for timestamp checking. The default implementation delegates to
| |
| getFilename | back to summary |
|---|---|
| public String getFilename() Implements org. This implementation always returns | |
| getURI | back to summary |
|---|---|
| public URI getURI() throws IOException Implements org. This implementation builds a URI based on the URL returned
by
| |
| getURL | back to summary |
|---|---|
| public URL getURL() throws IOException Implements org. This implementation throws a FileNotFoundException, assuming that the resource cannot be resolved to a URL.
| |
| hashCode | back to summary |
|---|---|
| public int hashCode() Overrides java. This implementation returns the description's hash code.
| |
| isFile | back to summary |
|---|---|
| public boolean isFile() Overrides default org. This implementation always returns
| |
| isOpen | back to summary |
|---|---|
| public boolean isOpen() Overrides default org. This implementation always returns
| |
| isReadable | back to summary |
|---|---|
| public boolean isReadable() Overrides default org. This implementation always returns
| |
| lastModified | back to summary |
|---|---|
| public long lastModified() throws IOException Implements org. This implementation checks the timestamp of the underlying File, if available.
| |
| readableChannel | back to summary |
|---|---|
| public ReadableByteChannel readableChannel() throws IOException Overrides default org. This implementation returns This is the same as in
| |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. This implementation returns the description of this resource.
| |