|
The Spring Framework | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.springframework.core.io.AbstractResource
org.springframework.core.io.DescriptiveResource
public class DescriptiveResource
Simple Resource
implementation that holds a resource description
but does not point to an actually readable resource.
To be used as placeholder if a Resource
argument is
expected by an API but not necessarily used for actual reading.
Constructor Summary | |
---|---|
DescriptiveResource(String description)
Create a new DescriptiveResource. |
Method Summary | |
---|---|
boolean |
equals(Object obj)
This implementation compares the underlying description String. |
boolean |
exists()
This implementation checks whether a File can be opened, falling back to whether an InputStream can be opened. |
String |
getDescription()
Return a description for this resource, to be used for error output when working with the resource. |
InputStream |
getInputStream()
Return an InputStream . |
int |
hashCode()
This implementation returns the hash code of the underlying description String. |
boolean |
isReadable()
This implementation always returns true . |
Methods inherited from class org.springframework.core.io.AbstractResource |
---|
createRelative, getFile, getFileForLastModifiedCheck, getFilename, getURI, getURL, isOpen, lastModified, toString |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public DescriptiveResource(String description)
description
- the resource descriptionMethod Detail |
---|
public boolean exists()
AbstractResource
exists
in interface Resource
exists
in class AbstractResource
public boolean isReadable()
AbstractResource
true
.
isReadable
in interface Resource
isReadable
in class AbstractResource
public InputStream getInputStream() throws IOException
InputStreamSource
InputStream
.
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.
IOException
- if the stream could not be openedMimeMessageHelper.addAttachment(String, InputStreamSource)
public String getDescription()
Resource
Implementations are also encouraged to return this value
from their toString
method.
Object.toString()
public boolean equals(Object obj)
equals
in class AbstractResource
Resource.getDescription()
public int hashCode()
hashCode
in class AbstractResource
Resource.getDescription()
|
The Spring Framework | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |