org.springframework.core.io
Class AbstractResource

Direct Known Subclasses:
ClassPathResource, FileSystemResource, InputStreamResource, UrlResource, ServletContextResource

public abstract class AbstractResource
implements Resource

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; "getFile" throws an exception; and "toString" will return the description.

Author:
Juergen Hoeller
Since: 28.12.2003

Method Summary
 booleanequals(Object obj)
          This implementation compares description strings.
 booleanexists()
          This implementation checks whether a File can be opened, falling back to whether an InputStream can be opened.
 FilegetFile()
          This implementation throws a FileNotFoundException, assuming that the resource cannot be resolved to an absolute file path.
 inthashCode()
          This implementation returns the description's hash code.
 booleanisOpen()
          This implementations always returns false.
 StringtoString()
          This implementation returns the description of this resource.

Method Detail

equals

public boolean equals(Object obj)
This implementation compares description strings.
See Also:
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.

getFile

public File getFile()
throws java.io.IOException
This implementation throws a FileNotFoundException, assuming that the resource cannot be resolved to an absolute file path.

hashCode

public int hashCode()
This implementation returns the description's hash code.
See Also:
Resource.getDescription()

isOpen

public boolean isOpen()
This implementations always returns false.

toString

public String toString()
This implementation returns the description of this resource.
See Also:
Resource.getDescription()