Package org.springframework.core.io
Class DescriptiveResource
java.lang.Object
org.springframework.core.io.AbstractResource
org.springframework.core.io.DescriptiveResource
- All Implemented Interfaces:
- InputStreamSource,- Resource
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.
- Since:
- 1.2.6
- Author:
- Juergen Hoeller
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionbooleanThis implementation compares the underlying description String.booleanexists()This implementation checks whether a File can be opened, falling back to whether an InputStream can be opened.Return a description for this resource, to be used for error output when working with the resource.Return anInputStreamfor the content of an underlying resource.inthashCode()This implementation returns the hash code of the underlying description String.booleanThis implementation always returnstruefor a resource thatexists(revised as of 5.1).Methods inherited from class org.springframework.core.io.AbstractResourcecontentLength, createRelative, getFile, getFileForLastModifiedCheck, getFilename, getURI, getURL, isFile, isOpen, lastModified, readableChannel, toStringMethods inherited from class java.lang.Objectclone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.springframework.core.io.ResourcegetContentAsByteArray, getContentAsString
- 
Constructor Details- 
DescriptiveResourceCreate a new DescriptiveResource.- Parameters:
- description- the resource description
 
 
- 
- 
Method Details- 
existspublic boolean exists()Description copied from class:AbstractResourceThis 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. - Specified by:
- existsin interface- Resource
- Overrides:
- existsin class- AbstractResource
 
- 
isReadablepublic boolean isReadable()Description copied from class:AbstractResourceThis implementation always returnstruefor a resource thatexists(revised as of 5.1).- Specified by:
- isReadablein interface- Resource
- Overrides:
- isReadablein class- AbstractResource
- See Also:
 
- 
getInputStreamDescription copied from interface:InputStreamSourceReturn anInputStreamfor the content of an underlying resource.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.- Returns:
- the input stream for the underlying resource (must not be null)
- Throws:
- FileNotFoundException- if the underlying resource does not exist
- IOException- if the content stream could not be opened
- See Also:
 
- 
getDescriptionDescription copied from interface:ResourceReturn a description for this resource, to be used for error output when working with the resource.Implementations are also encouraged to return this value from their toStringmethod.- See Also:
 
- 
equalsThis implementation compares the underlying description String.- Overrides:
- equalsin class- AbstractResource
- See Also:
 
- 
hashCodepublic int hashCode()This implementation returns the hash code of the underlying description String.- Overrides:
- hashCodein class- AbstractResource
- See Also:
 
 
-