|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.springframework.core.io.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 | |
---|---|
Resource |
createRelative(String relativePath)
This implementation throws a FileNotFoundException, assuming that relative resources cannot be created for this resource. |
boolean |
equals(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. |
abstract String |
getDescription()
This abstract method declaration shadows the method in the Resource interface. |
File |
getFile()
This implementation throws a FileNotFoundException, assuming that the resource cannot be resolved to an absolute file path. |
String |
getFilename()
This implementation always throws IllegalStateException, assuming that the resource does not carry a filename. |
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 . |
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.InputStreamSource |
---|
getInputStream |
Constructor Detail |
---|
public AbstractResource()
Method Detail |
---|
public boolean exists()
public boolean isOpen()
public URL getURL() throws IOException
IOException
- if the resource cannot be resolved as URL,
i.e. if the resource is not available as descriptorpublic File getFile() throws IOException
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(String relativePath) throws IOException
createRelative
in interface Resource
relativePath
- the relative path (relative to this resource)
IOException
- if the relative resource cannot be determinedpublic String getFilename() throws IllegalStateException
getFilename
in interface Resource
IllegalStateException
public abstract String getDescription()
toString
implementation in this
class work on Sun's JDK 1.3 classic VM, which can't find the method when
executing toString
else. Furthermore, getDescription
is also called from equals
and hashCode
getDescription
in interface Resource
Resource.getDescription()
,
toString()
,
equals(Object)
,
hashCode()
public String toString()
getDescription()
public boolean equals(Object obj)
getDescription()
public int hashCode()
getDescription()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |