private static final class GzipResourceResolver.GzippedResource extends AbstractResource implements EncodedResource
Modifier and Type | Field and Description |
---|---|
private Resource |
gzipped |
private Resource |
original |
Constructor and Description |
---|
GzippedResource(Resource original) |
Modifier and Type | Method and Description |
---|---|
long |
contentLength()
This implementation reads the entire InputStream to calculate the
content length.
|
Resource |
createRelative(java.lang.String relativePath)
This implementation throws a FileNotFoundException, assuming
that relative resources cannot be created for this resource.
|
boolean |
exists()
This implementation checks whether a File can be opened,
falling back to whether an InputStream can be opened.
|
java.lang.String |
getContentEncoding()
The content coding value, as defined in the IANA registry
|
java.lang.String |
getDescription()
Return a description for this resource,
to be used for error output when working with the resource.
|
java.io.File |
getFile()
This implementation throws a FileNotFoundException, assuming
that the resource cannot be resolved to an absolute file path.
|
java.lang.String |
getFilename()
This implementation always returns
null ,
assuming that this resource type does not have a filename. |
java.io.InputStream |
getInputStream()
Return an
InputStream . |
java.net.URI |
getURI()
This implementation builds a URI based on the URL returned
by
AbstractResource.getURL() . |
java.net.URL |
getURL()
This implementation throws a FileNotFoundException, assuming
that the resource cannot be resolved to a URL.
|
boolean |
isOpen()
This implementation always returns
false . |
boolean |
isReadable()
This implementation always returns
true . |
long |
lastModified()
This implementation checks the timestamp of the underlying File,
if available.
|
equals, getFileForLastModifiedCheck, hashCode, toString
public GzippedResource(Resource original) throws java.io.IOException
java.io.IOException
public java.io.InputStream getInputStream() throws java.io.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.
getInputStream
in interface InputStreamSource
null
)java.io.IOException
- if the stream could not be openedMimeMessageHelper.addAttachment(String, InputStreamSource)
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
InputStreamSource.getInputStream()
public boolean isOpen()
AbstractResource
false
.isOpen
in interface Resource
isOpen
in class AbstractResource
public java.net.URL getURL() throws java.io.IOException
AbstractResource
getURL
in interface Resource
getURL
in class AbstractResource
java.io.IOException
- if the resource cannot be resolved as URL,
i.e. if the resource is not available as descriptorpublic java.net.URI getURI() throws java.io.IOException
AbstractResource
AbstractResource.getURL()
.getURI
in interface Resource
getURI
in class AbstractResource
java.io.IOException
- if the resource cannot be resolved as URI,
i.e. if the resource is not available as descriptorpublic java.io.File getFile() throws java.io.IOException
AbstractResource
getFile
in interface Resource
getFile
in class AbstractResource
java.io.IOException
- if the resource cannot be resolved as absolute
file path, i.e. if the resource is not available in a file systempublic long contentLength() throws java.io.IOException
AbstractResource
contentLength
in interface Resource
contentLength
in class AbstractResource
java.io.IOException
- if the resource cannot be resolved
(in the file system or as some other known physical resource type)InputStreamSource.getInputStream()
public long lastModified() throws java.io.IOException
AbstractResource
lastModified
in interface Resource
lastModified
in class AbstractResource
java.io.IOException
- if the resource cannot be resolved
(in the file system or as some other known physical resource type)AbstractResource.getFileForLastModifiedCheck()
public Resource createRelative(java.lang.String relativePath) throws java.io.IOException
AbstractResource
createRelative
in interface Resource
createRelative
in class AbstractResource
relativePath
- the relative path (relative to this resource)java.io.IOException
- if the relative resource cannot be determinedpublic java.lang.String getFilename()
AbstractResource
null
,
assuming that this resource type does not have a filename.getFilename
in interface Resource
getFilename
in class AbstractResource
public java.lang.String getDescription()
Resource
Implementations are also encouraged to return this value
from their toString
method.
getDescription
in interface Resource
Object.toString()
public java.lang.String getContentEncoding()
EncodedResource
getContentEncoding
in interface EncodedResource