类 ResourceDecorator
- 所有已实现的接口:
InputStreamSource,Resource
- 直接已知子类:
WritableResourceDecorator
- 从以下版本开始:
- 4.0 2022/3/2 9:06
- 作者:
- Harry Yang
-
字段概要
字段从接口继承的字段 cn.taketoday.core.io.Resource
EMPTY_ARRAY -
构造器概要
构造器 -
方法概要
修饰符和类型方法说明longDetermine the content length for this resource.createRelative(String relativePath) Create a resource relative to this resource.booleanbooleanexists()Determine whether this resource actually exists in physical form.getFile()Return a File handle for this resource.Return anInputStreamfor the content of an underlying resource.getName()Determine a name for this resource, i.e. typically the last part of the path: for example, "myfile.txt".GetReaderGetReadergetURI()Return a URI handle for this resource.getURL()Return a URL handle for this resource.inthashCode()booleanTests whether the resource denoted by this abstract pathname is a directory.booleanisFile()Determine whether this resource represents a file in a file system.booleanisOpen()Indicate whether this resource represents a handle with an open stream.booleanIndicate whether non-empty contents of this resource can be read viaInputStreamSource.getInputStream().longDetermine the last-modified timestamp for this resource.String[]list()listResourceunder the directoryResource[]list(ResourceFilter filter) listResourceunder the directoryReturn aReadableByteChannel.voidsetDelegate(Resource delegate) toString()Return a description for this resource, to be used for error output when working with the resource.从接口继承的方法 cn.taketoday.core.io.Resource
getContentAsByteArray, getContentAsString
-
字段详细资料
-
delegate
-
-
构造器详细资料
-
ResourceDecorator
protected ResourceDecorator() -
ResourceDecorator
-
-
方法详细资料
-
getInputStream
从接口复制的说明:InputStreamSourceReturn anInputStreamfor 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.- 指定者:
getInputStream在接口中InputStreamSource- 返回:
- the input stream for the underlying resource (must not be
null) - 抛出:
FileNotFoundException- if the underlying resource does not existIOException- if the content stream could not be opened- 另请参阅:
-
getReader
从接口复制的说明:InputStreamSourceGetReader- 指定者:
getReader在接口中InputStreamSource- 抛出:
IOException- If an input exception occurs
-
getReader
从接口复制的说明:InputStreamSourceGetReader- 指定者:
getReader在接口中InputStreamSource- 参数:
encoding- Charset string- 抛出:
IOException- If an input exception occurs
-
readableChannel
从接口复制的说明:InputStreamSourceReturn aReadableByteChannel.It is expected that each call creates a fresh channel.
The default implementation returns
Channels.newChannel(InputStream)with the result ofInputStreamSource.getInputStream().- 指定者:
readableChannel在接口中InputStreamSource- 返回:
- the byte channel for the underlying resource (must not be
null) - 抛出:
FileNotFoundException- if the underlying resource doesn't existIOException- if the content channel could not be opened- 另请参阅:
-
getName
从接口复制的说明:ResourceDetermine a name for this resource, i.e. typically the last part of the path: for example, "myfile.txt".Returns
nullif this type of resource does not have a filename. -
contentLength
从接口复制的说明:ResourceDetermine the content length for this resource.- 指定者:
contentLength在接口中Resource- 抛出:
IOException- if the resource cannot be resolved (in the file system or as some other known physical resource type)
-
lastModified
从接口复制的说明:ResourceDetermine the last-modified timestamp for this resource.- 指定者:
lastModified在接口中Resource- 抛出:
IOException- if the resource cannot be resolved (in the file system or as some other known physical resource type)
-
getURL
从接口复制的说明:ResourceReturn a URL handle for this resource.- 指定者:
getURL在接口中Resource- 抛出:
IOException- if the resource cannot be resolved as URL, i.e. if the resource is not available as a descriptor
-
getURI
从接口复制的说明:ResourceReturn a URI handle for this resource.- 指定者:
getURI在接口中Resource- 抛出:
IOException- if the resource cannot be resolved as URI, i.e. if the resource is not available as a descriptor
-
getFile
从接口复制的说明:ResourceReturn a File handle for this resource.- 指定者:
getFile在接口中Resource- 抛出:
FileNotFoundException- 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 failures- 另请参阅:
-
exists
public boolean exists()从接口复制的说明:ResourceDetermine whether this resource actually exists in physical form.This method performs a definitive existence check, whereas the existence of a
Resourcehandle only guarantees a valid descriptor handle. -
isReadable
public boolean isReadable()从接口复制的说明:ResourceIndicate whether non-empty contents of this resource can be read viaInputStreamSource.getInputStream().Will be
truefor typical resource descriptors that exist since it strictly impliesResource.exists()semantics. Note that actual content reading may still fail when attempted. However, a value offalseis a definitive indication that the resource content cannot be read.- 指定者:
isReadable在接口中Resource- 另请参阅:
-
isOpen
public boolean isOpen()从接口复制的说明:ResourceIndicate whether this resource represents a handle with an open stream. Iftrue, the InputStream cannot be read multiple times, and must be read and closed to avoid resource leaks.Will be
falsefor typical resource descriptors. -
isFile
public boolean isFile()从接口复制的说明:ResourceDetermine whether this resource represents a file in a file system.A value of
truestrongly suggests (but does not guarantee) that aResource.getFile()call will succeed.This is conservatively
falseby default. -
isDirectory
从接口复制的说明:ResourceTests whether the resource denoted by this abstract pathname is a directory.Where it is required to distinguish an I/O exception from the case that the file is not a directory, or where several attributes of the same file are required at the same time, then the
Files.readAttributesmethod may be used.- 指定者:
isDirectory在接口中Resource- 返回:
trueif and only if the file denoted by this abstract pathname exists and is a directory;falseotherwise- 抛出:
IOException- cannot determine resource
-
list
从接口复制的说明:ResourcelistResourceunder the directory- 指定者:
list在接口中Resource- 返回:
Resourcenames- 抛出:
IOException- if the resource is not available
-
list
从接口复制的说明:ResourcelistResourceunder the directory- 指定者:
list在接口中Resource- 参数:
filter- filterResource- 返回:
Resourcenames- 抛出:
IOException- if the resource is not available
-
createRelative
从接口复制的说明:ResourceCreate a resource relative to this resource.- 指定者:
createRelative在接口中Resource- 参数:
relativePath- the relative path (relative to this resource)- 返回:
- the resource handle for the relative resource
- 抛出:
IOException- if the relative resource cannot be determined
-
getDelegate
-
setDelegate
-
equals
-
hashCode
public int hashCode() -
toString
从接口复制的说明:ResourceReturn 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
toStringmethod.
-