类 VfsResource

  • 所有已实现的接口:
    InputStreamSource, Resource

    public class VfsResource
    extends AbstractResource
    Copy from https://github.com/spring-projects/spring-framework.git, with less modifications JBoss VFS based 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+.

    从以下版本开始:
    3.0
    作者:
    Ales Justin, Juergen Hoeller, Costin Leau, Sam Brannen
    另请参阅:
    org.jboss.vfs.VirtualFile
    • 字段概要

      字段 
      修饰符和类型 字段 说明
      private java.lang.Object resource  
    • 构造器概要

      构造器 
      构造器 说明
      VfsResource​(java.lang.Object resource)
      Create a new VfsResource wrapping the given resource handle.
    • 方法概要

      所有方法 实例方法 具体方法 
      修饰符和类型 方法 说明
      long contentLength()
      This method reads the entire InputStream to determine 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 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.
      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 for a resource that exists (revised as of 5.1).
      long lastModified()
      This implementation checks the timestamp of the underlying File, if available.
      • 从类继承的方法 java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • 字段详细资料

      • resource

        private final java.lang.Object resource
    • 构造器详细资料

      • VfsResource

        public VfsResource​(java.lang.Object resource)
        Create a new 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)
    • 方法详细资料

      • getInputStream

        public java.io.InputStream getInputStream()
                                           throws java.io.IOException
        从接口复制的说明: InputStreamSource
        Return an InputStream 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.

        返回:
        the input stream for the underlying resource (must not be null)
        抛出:
        java.io.FileNotFoundException - if the underlying resource does not exist
        java.io.IOException - if the content stream could not be opened
        另请参阅:
        Resource.isReadable()
      • exists

        public boolean exists()
        从类复制的说明: AbstractResource
        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.
        指定者:
        exists 在接口中 Resource
        覆盖:
        exists 在类中 AbstractResource
      • getUrl

        public java.net.URL getUrl()
                            throws java.io.IOException
        从类复制的说明: AbstractResource
        This implementation throws a FileNotFoundException, assuming that the resource cannot be resolved to a URL.
        指定者:
        getUrl 在接口中 Resource
        覆盖:
        getUrl 在类中 AbstractResource
        抛出:
        java.io.IOException - if the resource cannot be resolved as URL, i.e. if the resource is not available as descriptor
      • getUri

        public java.net.URI getUri()
                            throws java.io.IOException
        从类复制的说明: AbstractResource
        This implementation builds a URI based on the URL returned by AbstractResource.getUrl().
        指定者:
        getUri 在接口中 Resource
        覆盖:
        getUri 在类中 AbstractResource
        抛出:
        java.io.IOException - if the resource cannot be resolved as URI, i.e. if the resource is not available as descriptor
      • getFile

        public java.io.File getFile()
                             throws java.io.IOException
        从类复制的说明: AbstractResource
        This implementation throws a FileNotFoundException, assuming that the resource cannot be resolved to an absolute file path.
        指定者:
        getFile 在接口中 Resource
        覆盖:
        getFile 在类中 AbstractResource
        抛出:
        java.io.FileNotFoundException - if the resource cannot be resolved as absolute file path, i.e. if the resource is not available in a file system
        java.io.IOException - in case of general resolution/reading failures
        另请参阅:
        InputStreamSource.getInputStream()
      • contentLength

        public long contentLength()
                           throws java.io.IOException
        从类复制的说明: AbstractResource
        This method reads the entire InputStream to determine the content length. For a custom sub-class of InputStreamResource, we strongly recommend overriding this method with a more optimal implementation, e.g. checking File length, or possibly simply returning -1 if the stream can only be read once.
        指定者:
        contentLength 在接口中 Resource
        覆盖:
        contentLength 在类中 AbstractResource
        抛出:
        java.io.IOException - if the resource cannot be resolved (in the file system or as some other known physical resource type)
        另请参阅:
        InputStreamSource.getInputStream()
      • createRelative

        public Resource createRelative​(java.lang.String relativePath)
                                throws java.io.IOException
        从类复制的说明: AbstractResource
        This implementation throws a FileNotFoundException, assuming that relative resources cannot be created for this resource.
        指定者:
        createRelative 在接口中 Resource
        覆盖:
        createRelative 在类中 AbstractResource
        参数:
        relativePath - the relative path (relative to this resource)
        返回:
        the resource handle for the relative resource
        抛出:
        java.io.IOException - if the relative resource cannot be determined
      • getDescription

        public java.lang.String getDescription()
        从接口复制的说明: Resource
        Return a description for this resource, to be used for error output when working with the resource.

        Implementations are also encouraged to return this value from their toString method.

        另请参阅:
        Object.toString()