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+.
org.jboss.vfs.VirtualFile| 构造器和说明 |
|---|
VfsResource(Object resource)
Create a new
VfsResource wrapping the given resource handle. |
| 限定符和类型 | 方法和说明 |
|---|---|
long |
contentLength()
This implementation reads the entire InputStream to calculate the
content length.
|
Resource |
createRelative(String relativePath)
This implementation throws a FileNotFoundException, assuming
that relative resources cannot be created for this resource.
|
boolean |
equals(Object other)
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.
|
String |
getDescription()
Return a description for this resource,
to be used for error output when working with the resource.
|
File |
getFile()
This implementation throws a FileNotFoundException, assuming
that the resource cannot be resolved to an absolute file path.
|
String |
getFilename()
This implementation always returns
null,
assuming that this resource type does not have a filename. |
InputStream |
getInputStream()
Return an
InputStream for the content of an underlying resource. |
URI |
getURI()
This implementation builds a URI based on the URL returned
by
AbstractResource.getURL(). |
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 for a resource
that exists (revised as of 5.1). |
long |
lastModified()
This implementation checks the timestamp of the underlying File,
if available.
|
getFileForLastModifiedCheck, isFile, isOpen, readableChannel, toStringpublic VfsResource(Object resource)
VfsResource wrapping the given resource handle.resource - a org.jboss.vfs.VirtualFile instance
(untyped in order to avoid a static dependency on the VFS API)public InputStream getInputStream() throws 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)FileNotFoundException - if the underlying resource doesn't existIOException - if the content stream could not be openedpublic boolean exists()
AbstractResourceexists 在接口中 Resourceexists 在类中 AbstractResourcepublic boolean isReadable()
AbstractResourcetrue for a resource
that exists (revised as of 5.1).isReadable 在接口中 ResourceisReadable 在类中 AbstractResourceInputStreamSource.getInputStream(),
Resource.exists()public URL getURL() throws IOException
AbstractResourcegetURL 在接口中 ResourcegetURL 在类中 AbstractResourceIOException - if the resource cannot be resolved as URL,
i.e. if the resource is not available as descriptorpublic URI getURI() throws IOException
AbstractResourceAbstractResource.getURL().getURI 在接口中 ResourcegetURI 在类中 AbstractResourceIOException - if the resource cannot be resolved as URI,
i.e. if the resource is not available as descriptorpublic File getFile() throws IOException
AbstractResourcegetFile 在接口中 ResourcegetFile 在类中 AbstractResourceFileNotFoundException - if the resource cannot be resolved as
absolute file path, i.e. if the resource is not available in a file systemIOException - in case of general resolution/reading failuresInputStreamSource.getInputStream()public long contentLength()
throws IOException
AbstractResourcecontentLength 在接口中 ResourcecontentLength 在类中 AbstractResourceIOException - if the resource cannot be resolved
(in the file system or as some other known physical resource type)InputStreamSource.getInputStream()public long lastModified()
throws IOException
AbstractResourcelastModified 在接口中 ResourcelastModified 在类中 AbstractResourceIOException - if the resource cannot be resolved
(in the file system or as some other known physical resource type)AbstractResource.getFileForLastModifiedCheck()public Resource createRelative(String relativePath) throws IOException
AbstractResourcecreateRelative 在接口中 ResourcecreateRelative 在类中 AbstractResourcerelativePath - the relative path (relative to this resource)IOException - if the relative resource cannot be determinedpublic String getFilename()
AbstractResourcenull,
assuming that this resource type does not have a filename.getFilename 在接口中 ResourcegetFilename 在类中 AbstractResourcepublic String getDescription()
ResourceImplementations are also encouraged to return this value
from their toString method.
Object.toString()public boolean equals(Object other)
AbstractResourceequals 在类中 AbstractResourceResource.getDescription()public int hashCode()
AbstractResourcehashCode 在类中 AbstractResourceResource.getDescription()Copyright © 2020. All rights reserved.