|
spring-core | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.springframework.core.io.AbstractResource
public abstract class AbstractResource
Convenience base class for Resource
implementations,
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.
Constructor Summary | |
---|---|
AbstractResource()
|
Method Summary | |
---|---|
long |
contentLength()
This implementation reads the entire InputStream to calculate 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 obj)
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.io.File |
getFile()
This implementation throws a FileNotFoundException, assuming that the resource cannot be resolved to an absolute file path. |
protected java.io.File |
getFileForLastModifiedCheck()
Determine the File to use for timestamp checking. |
java.lang.String |
getFilename()
This implementation always returns null ,
assuming that this resource type does not have a filename. |
java.net.URI |
getURI()
This implementation builds a URI based on the URL returned by 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 |
isOpen()
This implementation always returns false . |
boolean |
isReadable()
This implementation always returns true . |
long |
lastModified()
This implementation checks the timestamp of the underlying File, if available. |
java.lang.String |
toString()
This implementation returns the description of this resource. |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Methods inherited from interface org.springframework.core.io.Resource |
---|
getDescription, getInputStream |
Constructor Detail |
---|
public AbstractResource()
Method Detail |
---|
public boolean exists()
exists
in interface Resource
public boolean isReadable()
true
.
isReadable
in interface Resource
Resource.getInputStream()
public boolean isOpen()
false
.
isOpen
in interface Resource
public java.net.URL getURL() throws java.io.IOException
getURL
in interface Resource
java.io.IOException
- if the resource cannot be resolved as URL,
i.e. if the resource is not available as descriptorpublic java.net.URI getURI() throws java.io.IOException
getURL()
.
getURI
in interface Resource
java.io.IOException
- if the resource cannot be resolved as URI,
i.e. if the resource is not available as descriptorpublic java.io.File getFile() throws java.io.IOException
getFile
in interface Resource
java.io.IOException
- if the resource cannot be resolved as absolute
file path, i.e. if the resource is not available in a file systempublic long contentLength() throws java.io.IOException
contentLength
in interface Resource
java.lang.IllegalStateException
- if Resource.getInputStream()
returns null.
java.io.IOException
- if the resource cannot be resolved
(in the file system or as some other known physical resource type)Resource.getInputStream()
public long lastModified() throws java.io.IOException
lastModified
in interface Resource
java.io.IOException
- if the resource cannot be resolved
(in the file system or as some other known physical resource type)getFileForLastModifiedCheck()
protected java.io.File getFileForLastModifiedCheck() throws java.io.IOException
The default implementation delegates to getFile()
.
null
)
java.io.IOException
- if the resource cannot be resolved as absolute
file path, i.e. if the resource is not available in a file systempublic Resource createRelative(java.lang.String relativePath) throws java.io.IOException
createRelative
in interface Resource
relativePath
- the relative path (relative to this resource)
java.io.IOException
- if the relative resource cannot be determinedpublic java.lang.String getFilename() throws java.lang.IllegalStateException
null
,
assuming that this resource type does not have a filename.
getFilename
in interface Resource
java.lang.IllegalStateException
public java.lang.String toString()
toString
in class java.lang.Object
Resource.getDescription()
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
Resource.getDescription()
public int hashCode()
hashCode
in class java.lang.Object
Resource.getDescription()
|
spring-core | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |