类 DescriptiveResource

java.lang.Object
cn.taketoday.core.io.AbstractResource
cn.taketoday.core.io.DescriptiveResource
所有已实现的接口:
InputStreamSource, Resource

public class DescriptiveResource extends AbstractResource
Simple Resource implementation that holds a resource description but does not point to an actually readable resource.

To be used as placeholder if a Resource argument is expected by an API but not necessarily used for actual reading.

从以下版本开始:
3.0
作者:
Juergen Hoeller, TODAY 2021/3/9 20:12
  • 字段详细资料

    • description

      private final String description
  • 构造器详细资料

    • DescriptiveResource

      public DescriptiveResource(String description)
      Create a new DescriptiveResource.
      参数:
      description - the resource description
  • 方法详细资料

    • 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
    • getInputStream

      public InputStream getInputStream() throws 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)
      抛出:
      FileNotFoundException - if the underlying resource does not exist
      IOException - if the content stream could not be opened
      另请参阅:
    • toString

      public String toString()
      从接口复制的说明: 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.

      指定者:
      toString 在接口中 Resource
      覆盖:
      toString 在类中 AbstractResource
      另请参阅:
    • equals

      public boolean equals(Object other)
      This implementation compares the underlying description String.
      覆盖:
      equals 在类中 AbstractResource
    • hashCode

      public int hashCode()
      This implementation returns the hash code of the underlying description String.
      覆盖:
      hashCode 在类中 AbstractResource