public class VfsResource extends AbstractResource
Resource implementation.
As of Spring 4.0, this class supports VFS 3.x on JBoss AS 6+ (package
org.jboss.vfs) and is in particular compatible with JBoss AS 7 and
WildFly 8.
VirtualFile| Constructor and Description |
|---|
VfsResource(java.lang.Object resource) |
| Modifier and Type | Method and Description |
|---|---|
long |
contentLength()
This implementation reads the entire InputStream to calculate the
content length.
|
Resource |
createRelative(java.lang.String relativePath)
This implementation throws a FileNotFoundException, assuming
that relative resources cannot be created for this resource.
|
boolean |
equals(java.lang.Object obj)
This implementation compares description strings.
|
boolean |
exists()
This implementation checks whether a File can be opened,
falling back to whether an InputStream can be opened.
|
java.lang.String |
getDescription()
Return a description for this resource,
to be used for error output when working with the resource.
|
java.io.File |
getFile()
This implementation throws a FileNotFoundException, assuming
that the resource cannot be resolved to an absolute file path.
|
java.lang.String |
getFilename()
This implementation always returns
null,
assuming that this resource type does not have a filename. |
java.io.InputStream |
getInputStream()
Return an
InputStream for the content of an underlying resource. |
java.net.URI |
getURI()
This implementation builds a URI based on the URL returned
by
AbstractResource.getURL(). |
java.net.URL |
getURL()
This implementation throws a FileNotFoundException, assuming
that the resource cannot be resolved to a URL.
|
int |
hashCode()
This implementation returns the description's hash code.
|
boolean |
isReadable()
This implementation always returns
true. |
long |
lastModified()
This implementation checks the timestamp of the underlying File,
if available.
|
getFileForLastModifiedCheck, isOpen, toStringpublic java.io.InputStream getInputStream()
throws java.io.IOException
InputStreamSourceInputStream for the content of an underlying resource.
It is expected that each call creates a fresh stream.
This requirement is particularly important when you consider an API such
as JavaMail, which needs to be able to read the stream multiple times when
creating mail attachments. For such a use case, it is required
that each getInputStream() call returns a fresh stream.
null)java.io.FileNotFoundException - if the underlying resource doesn't existjava.io.IOException - if the content stream could not be openedpublic boolean exists()
AbstractResourceexists in interface Resourceexists in class AbstractResourcepublic boolean isReadable()
AbstractResourcetrue.isReadable in interface ResourceisReadable in class AbstractResourceInputStreamSource.getInputStream()public java.net.URL getURL()
throws java.io.IOException
AbstractResourcegetURL in interface ResourcegetURL in class AbstractResourcejava.io.IOException - if the resource cannot be resolved as URL,
i.e. if the resource is not available as descriptorpublic java.net.URI getURI()
throws java.io.IOException
AbstractResourceAbstractResource.getURL().getURI in interface ResourcegetURI in class AbstractResourcejava.io.IOException - if the resource cannot be resolved as URI,
i.e. if the resource is not available as descriptorpublic java.io.File getFile()
throws java.io.IOException
AbstractResourcegetFile in interface ResourcegetFile in class AbstractResourcejava.io.FileNotFoundException - if the resource cannot be resolved as
absolute file path, i.e. if the resource is not available in a file systemjava.io.IOException - in case of general resolution/reading failuresInputStreamSource.getInputStream()public long contentLength()
throws java.io.IOException
AbstractResourcecontentLength in interface ResourcecontentLength in class AbstractResourcejava.io.IOException - if the resource cannot be resolved
(in the file system or as some other known physical resource type)InputStreamSource.getInputStream()public long lastModified()
throws java.io.IOException
AbstractResourcelastModified in interface ResourcelastModified in class AbstractResourcejava.io.IOException - if the resource cannot be resolved
(in the file system or as some other known physical resource type)AbstractResource.getFileForLastModifiedCheck()public Resource createRelative(java.lang.String relativePath) throws java.io.IOException
AbstractResourcecreateRelative in interface ResourcecreateRelative in class AbstractResourcerelativePath - the relative path (relative to this resource)java.io.IOException - if the relative resource cannot be determinedpublic java.lang.String getFilename()
AbstractResourcenull,
assuming that this resource type does not have a filename.getFilename in interface ResourcegetFilename in class AbstractResourcepublic java.lang.String getDescription()
ResourceImplementations are also encouraged to return this value
from their toString method.
Object.toString()public boolean equals(java.lang.Object obj)
AbstractResourceequals in class AbstractResourceResource.getDescription()public int hashCode()
AbstractResourcehashCode in class AbstractResourceResource.getDescription()