类 AbstractResource
- java.lang.Object
-
- com.alibaba.nacos.common.packagescan.resource.AbstractResource
-
- 所有已实现的接口:
InputStreamSource,Resource
- 直接已知子类:
AbstractFileResolvingResource,ByteArrayResource,FileSystemResource,InputStreamResource,PathResource,VfsResource
public abstract class AbstractResource extends java.lang.Object implements Resource
Copy from https://github.com/spring-projects/spring-framework.git, with less modifications Convenience base class forResourceimplementations, pre-implementing typical behavior.The "exists" method will check whether a File or InputStream can be opened; "isOpen" will always return false; "getURL" and "getFile" throw an exception; and "toString" will return the description.
- 从以下版本开始:
- 28.12.2003
- 作者:
- Juergen Hoeller, Sam Brannen
-
-
构造器概要
构造器 构造器 说明 AbstractResource()
-
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 longcontentLength()This method reads the entire InputStream to determine the content length.ResourcecreateRelative(java.lang.String relativePath)This implementation throws a FileNotFoundException, assuming that relative resources cannot be created for this resource.booleanequals(java.lang.Object other)This implementation compares description strings.booleanexists()This implementation checks whether a File can be opened, falling back to whether an InputStream can be opened.java.io.FilegetFile()This implementation throws a FileNotFoundException, assuming that the resource cannot be resolved to an absolute file path.protected java.io.FilegetFileForLastModifiedCheck()Determine the File to use for timestamp checking.java.lang.StringgetFilename()This implementation always returnsnull, assuming that this resource type does not have a filename.java.net.URIgetUri()This implementation builds a URI based on the URL returned bygetUrl().java.net.URLgetUrl()This implementation throws a FileNotFoundException, assuming that the resource cannot be resolved to a URL.inthashCode()This implementation returns the description's hash code.booleanisFile()This implementation always returnsfalse.booleanisOpen()This implementation always returnsfalse.booleanisReadable()This implementation always returnstruefor a resource thatexists(revised as of 5.1).longlastModified()This implementation checks the timestamp of the underlying File, if available.java.nio.channels.ReadableByteChannelreadableChannel()This implementation returnsChannels.newChannel(InputStream)with the result ofInputStreamSource.getInputStream().java.lang.StringtoString()This implementation returns the description of this resource.-
从接口继承的方法 com.alibaba.nacos.common.packagescan.resource.InputStreamSource
getInputStream
-
从接口继承的方法 com.alibaba.nacos.common.packagescan.resource.Resource
getDescription
-
-
-
-
方法详细资料
-
exists
public boolean exists()
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.
-
isReadable
public boolean isReadable()
This implementation always returnstruefor a resource thatexists(revised as of 5.1).- 指定者:
isReadable在接口中Resource- 另请参阅:
InputStreamSource.getInputStream(),Resource.exists()
-
isFile
public boolean isFile()
This implementation always returnsfalse.- 指定者:
isFile在接口中Resource- 另请参阅:
Resource.getFile()
-
getUrl
public java.net.URL getUrl() throws java.io.IOExceptionThis implementation throws a FileNotFoundException, assuming that the resource cannot be resolved to a URL.
-
getUri
public java.net.URI getUri() throws java.io.IOExceptionThis implementation builds a URI based on the URL returned bygetUrl().
-
getFile
public java.io.File getFile() throws java.io.IOExceptionThis implementation throws a FileNotFoundException, assuming that the resource cannot be resolved to an absolute file path.- 指定者:
getFile在接口中Resource- 抛出:
java.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 failures- 另请参阅:
InputStreamSource.getInputStream()
-
readableChannel
public java.nio.channels.ReadableByteChannel readableChannel() throws java.io.IOExceptionThis implementation returnsChannels.newChannel(InputStream)with the result ofInputStreamSource.getInputStream(). This is the same as inResource's corresponding default method but mirrored here for efficient JVM-level dispatching in a class hierarchy.- 指定者:
readableChannel在接口中Resource- 返回:
- the byte channel for the underlying resource (must not be
null) - 抛出:
java.io.FileNotFoundException- if the underlying resource doesn't existjava.io.IOException- if the content channel could not be opened- 另请参阅:
InputStreamSource.getInputStream()
-
contentLength
public long contentLength() throws java.io.IOExceptionThis method reads the entire InputStream to determine the content length. For a custom sub-class ofInputStreamResource, 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- 抛出:
java.io.IOException- if the resource cannot be resolved (in the file system or as some other known physical resource type)- 另请参阅:
InputStreamSource.getInputStream()
-
lastModified
public long lastModified() throws java.io.IOExceptionThis implementation checks the timestamp of the underlying File, if available.- 指定者:
lastModified在接口中Resource- 抛出:
java.io.IOException- if the resource cannot be resolved (in the file system or as some other known physical resource type)- 另请参阅:
getFileForLastModifiedCheck()
-
getFileForLastModifiedCheck
protected java.io.File getFileForLastModifiedCheck() throws java.io.IOExceptionDetermine the File to use for timestamp checking. The default implementation delegates togetFile().- 返回:
- the File to use for timestamp checking (never
null) - 抛出:
java.io.FileNotFoundException- if the resource cannot be resolved as an absolute file path, i.e. is not available in a file systemjava.io.IOException- in case of general resolution/reading failures
-
createRelative
public Resource createRelative(java.lang.String relativePath) throws java.io.IOException
This implementation throws a FileNotFoundException, assuming that relative resources cannot be created for this resource.- 指定者:
createRelative在接口中Resource- 参数:
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
-
getFilename
public java.lang.String getFilename()
This implementation always returnsnull, assuming that this resource type does not have a filename.- 指定者:
getFilename在接口中Resource
-
equals
public boolean equals(java.lang.Object other)
This implementation compares description strings.- 覆盖:
equals在类中java.lang.Object- 另请参阅:
Resource.getDescription()
-
hashCode
public int hashCode()
This implementation returns the description's hash code.- 覆盖:
hashCode在类中java.lang.Object- 另请参阅:
Resource.getDescription()
-
toString
public java.lang.String toString()
This implementation returns the description of this resource.- 覆盖:
toString在类中java.lang.Object- 另请参阅:
Resource.getDescription()
-
-