org.springframework.core.io
Class DescriptiveResource

java.lang.Object
  extended by org.springframework.core.io.AbstractResource
      extended by org.springframework.core.io.DescriptiveResource
All Implemented Interfaces:
InputStreamSource, Resource

public class DescriptiveResource
extends AbstractResource

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 demanded but not necessarily used for reading.

Since:
1.2.6
Author:
Juergen Hoeller

Constructor Summary
DescriptiveResource(String description)
          Create a new DescriptiveResource.
 
Method Summary
 boolean equals(Object obj)
          This implementation compares the underlying description String.
 String getDescription()
          This abstract method declaration shadows the method in the Resource interface.
 InputStream getInputStream()
          Return an InputStream.
 int hashCode()
          This implementation returns the hash code of the underlying description String.
 
Methods inherited from class org.springframework.core.io.AbstractResource
createRelative, exists, getFile, getFilename, getURL, isOpen, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DescriptiveResource

public DescriptiveResource(String description)
Create a new DescriptiveResource.

Parameters:
description - the resource description
Method Detail

getInputStream

public InputStream getInputStream()
                           throws IOException
Description copied from interface: InputStreamSource
Return an InputStream. It is expected that each call creates a fresh stream.

For creating mail attachments, note that JavaMail needs to be able to read the stream multiple times. For such a use case, it is required that each getInputStream() call returns a fresh stream.

Throws:
IOException - if the stream could not be opened
See Also:
MimeMessageHelper.addAttachment(String, InputStreamSource)

getDescription

public String getDescription()
Description copied from class: AbstractResource
This abstract method declaration shadows the method in the Resource interface. This is necessary to make the 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

Specified by:
getDescription in interface Resource
Specified by:
getDescription in class AbstractResource
See Also:
Resource.getDescription(), AbstractResource.toString(), AbstractResource.equals(Object), AbstractResource.hashCode()

equals

public boolean equals(Object obj)
This implementation compares the underlying description String.

Overrides:
equals in class AbstractResource
See Also:
AbstractResource.getDescription()

hashCode

public int hashCode()
This implementation returns the hash code of the underlying description String.

Overrides:
hashCode in class AbstractResource
See Also:
AbstractResource.getDescription()


Copyright (c) 2002-2007 The Spring Framework Project.