Class InputStreamResource
- java.lang.Object
-
- org.hotswap.agent.util.spring.io.resource.AbstractResource
-
- org.hotswap.agent.util.spring.io.resource.InputStreamResource
-
- All Implemented Interfaces:
InputStreamSource,Resource
public class InputStreamResource extends AbstractResource
Resourceimplementation for a givenInputStream.Should only be used if no other specific
Resourceimplementation is applicable. In particular, preferByteArrayResourceor any of the file-basedResourceimplementations where possible.In contrast to other
Resourceimplementations, this is a descriptor for an already opened resource - therefore returningtruefromisOpen(). Do not use anInputStreamResourceif you need to keep the resource descriptor somewhere, or if you need to read from a stream multiple times.- Since:
- 28.12.2003
- Author:
- Juergen Hoeller, Sam Brannen
- See Also:
ByteArrayResource,ClassPathResource,FileSystemResource,UrlResource
-
-
Constructor Summary
Constructors Constructor Description InputStreamResource(InputStream inputStream)Create a new InputStreamResource.InputStreamResource(InputStream inputStream, String description)Create a new InputStreamResource.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(Object obj)This implementation compares the underlying InputStream.booleanexists()This implementation always returnstrue.StringgetDescription()This implementation returns a description that includes the passed-in description, if any.InputStreamgetInputStream()This implementation throws IllegalStateException if attempting to read the underlying stream multiple times.inthashCode()This implementation returns the hash code of the underlying InputStream.booleanisOpen()This implementation always returnstrue.-
Methods inherited from class org.hotswap.agent.util.spring.io.resource.AbstractResource
contentLength, createRelative, getFile, getFileForLastModifiedCheck, getFilename, getURI, getURL, isReadable, lastModified, toString
-
-
-
-
Constructor Detail
-
InputStreamResource
public InputStreamResource(InputStream inputStream)
Create a new InputStreamResource.- Parameters:
inputStream- the InputStream to use
-
InputStreamResource
public InputStreamResource(InputStream inputStream, String description)
Create a new InputStreamResource.- Parameters:
inputStream- the InputStream to usedescription- where the InputStream comes from
-
-
Method Detail
-
exists
public boolean exists()
This implementation always returnstrue.- Specified by:
existsin interfaceResource- Overrides:
existsin classAbstractResource
-
isOpen
public boolean isOpen()
This implementation always returnstrue.- Specified by:
isOpenin interfaceResource- Overrides:
isOpenin classAbstractResource
-
getInputStream
public InputStream getInputStream() throws IOException, IllegalStateException
This implementation throws IllegalStateException if attempting to read the underlying stream multiple times.- Returns:
- the input stream for the underlying resource (must not be
null) - Throws:
IOException- if the stream could not be openedIllegalStateException- See Also:
org.springframework.mail.javamail.MimeMessageHelper#addAttachment(String, InputStreamSource)
-
getDescription
public String getDescription()
This implementation returns a description that includes the passed-in description, if any.- See Also:
Object.toString()
-
equals
public boolean equals(Object obj)
This implementation compares the underlying InputStream.- Overrides:
equalsin classAbstractResource- See Also:
Resource.getDescription()
-
hashCode
public int hashCode()
This implementation returns the hash code of the underlying InputStream.- Overrides:
hashCodein classAbstractResource- See Also:
Resource.getDescription()
-
-