Package net.solarnetwork.io
Class DecompressingResource
java.lang.Object
org.springframework.core.io.AbstractResource
net.solarnetwork.io.DecompressingResource
- All Implemented Interfaces:
org.springframework.core.io.InputStreamSource,org.springframework.core.io.Resource
public class DecompressingResource
extends org.springframework.core.io.AbstractResource
A
Resource that can decompress another Resource.
This implementation uses the Apache Commons Compression library to return
InputStream instances from getInputStream() that perform
compression detection and automatic decompression. If a compression type
cannot be detected then the raw stream will be returned and the compression
type will be set to NO_KNOWN_COMPRESSION_TYPE.
- Since:
- 1.47
- Version:
- 1.1
- Author:
- matt
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringA special type returned bygetCompressionType()if the type is not a know compression format, or appears not to be compressed. -
Constructor Summary
ConstructorsConstructorDescriptionDecompressingResource(org.springframework.core.io.Resource source) Constructor.DecompressingResource(org.springframework.core.io.Resource source, String compressionType) Constructor.DecompressingResource(org.springframework.core.io.Resource source, String compressionType, long contentLength) Constructor. -
Method Summary
Methods inherited from class org.springframework.core.io.AbstractResource
equals, getFileForLastModifiedCheck, hashCode, toString
-
Field Details
-
NO_KNOWN_COMPRESSION_TYPE
A special type returned bygetCompressionType()if the type is not a know compression format, or appears not to be compressed.- See Also:
-
-
Constructor Details
-
DecompressingResource
public DecompressingResource(org.springframework.core.io.Resource source) Constructor.- Parameters:
source- the source (compressed) resource
-
DecompressingResource
Constructor.- Parameters:
source- the source (compressed) resourcecompressionType- the compression type to use, or null to try to automatically detect the type
-
DecompressingResource
public DecompressingResource(org.springframework.core.io.Resource source, String compressionType, long contentLength) Constructor.- Parameters:
source- the source (compressed) resourcecompressionType- the compression type to use, or null to try to automatically detect the typecontentLength- the known uncompressed content length of the resource, or -1 to automatically determine- Since:
- 1.1
-
-
Method Details
-
getDescription
-
getInputStream
- Throws:
IOException
-
getCompressionType
Get the detected compression type.- Returns:
- the detected compression type
-
getURL
- Specified by:
getURLin interfaceorg.springframework.core.io.Resource- Overrides:
getURLin classorg.springframework.core.io.AbstractResource- Throws:
IOException
-
getFile
- Specified by:
getFilein interfaceorg.springframework.core.io.Resource- Overrides:
getFilein classorg.springframework.core.io.AbstractResource- Throws:
IOException
-
getFilename
- Specified by:
getFilenamein interfaceorg.springframework.core.io.Resource- Overrides:
getFilenamein classorg.springframework.core.io.AbstractResource
-
exists
public boolean exists()- Specified by:
existsin interfaceorg.springframework.core.io.Resource- Overrides:
existsin classorg.springframework.core.io.AbstractResource
-
isReadable
public boolean isReadable()- Specified by:
isReadablein interfaceorg.springframework.core.io.Resource- Overrides:
isReadablein classorg.springframework.core.io.AbstractResource
-
isOpen
public boolean isOpen()- Specified by:
isOpenin interfaceorg.springframework.core.io.Resource- Overrides:
isOpenin classorg.springframework.core.io.AbstractResource
-
getURI
- Specified by:
getURIin interfaceorg.springframework.core.io.Resource- Overrides:
getURIin classorg.springframework.core.io.AbstractResource- Throws:
IOException
-
contentLength
- Specified by:
contentLengthin interfaceorg.springframework.core.io.Resource- Overrides:
contentLengthin classorg.springframework.core.io.AbstractResource- Throws:
IOException
-
lastModified
- Specified by:
lastModifiedin interfaceorg.springframework.core.io.Resource- Overrides:
lastModifiedin classorg.springframework.core.io.AbstractResource- Throws:
IOException
-
createRelative
- Specified by:
createRelativein interfaceorg.springframework.core.io.Resource- Overrides:
createRelativein classorg.springframework.core.io.AbstractResource- Throws:
IOException
-