Class GZipCompressionDataHandler
- java.lang.Object
-
- javax.activation.DataHandler
-
- org.wso2.carbon.mediation.connector.compression.GZipCompressionDataHandler
-
- All Implemented Interfaces:
Transferable
public class GZipCompressionDataHandler extends DataHandler
This is the data handler which can compress and uncompress the data provided to it.
-
-
Field Summary
Fields Modifier and Type Field Description static String
GZIP_COMPRESSION
-
Constructor Summary
Constructors Constructor Description GZipCompressionDataHandler(DataSource ds)
Constructor which takes a datasource.GZipCompressionDataHandler(DataSource ds, String contentType)
Constructor which takes data source and content type.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description String
getContentType()
Overridden method to return content type.InputStream
getInputStream()
Overridden method to get input stream, this method will differentiate returning input stream depending on the content type of the data handler.void
writeTo(OutputStream out)
Overridden method to write compressed data or uncompressed data depending on the content type.-
Methods inherited from class javax.activation.DataHandler
getAllCommands, getBean, getCommand, getContent, getDataSource, getName, getOutputStream, getPreferredCommands, getTransferData, getTransferDataFlavors, isDataFlavorSupported, setCommandMap, setDataContentHandlerFactory
-
-
-
-
Field Detail
-
GZIP_COMPRESSION
public static String GZIP_COMPRESSION
-
-
Constructor Detail
-
GZipCompressionDataHandler
public GZipCompressionDataHandler(DataSource ds)
Constructor which takes a datasource.- Parameters:
ds
-DataSource
object
-
GZipCompressionDataHandler
public GZipCompressionDataHandler(DataSource ds, String contentType)
Constructor which takes data source and content type.- Parameters:
ds
-DataSource
objectcontentType
- content type
-
-
Method Detail
-
getInputStream
public InputStream getInputStream() throws IOException
Overridden method to get input stream, this method will differentiate returning input stream depending on the content type of the data handler.- Overrides:
getInputStream
in classDataHandler
- Returns:
- inputStream
- Throws:
IOException
-
writeTo
public void writeTo(OutputStream out) throws IOException
Overridden method to write compressed data or uncompressed data depending on the content type.- Overrides:
writeTo
in classDataHandler
- Parameters:
out
-OutputStream
object- Throws:
IOException
-
getContentType
public String getContentType()
Overridden method to return content type.- Overrides:
getContentType
in classDataHandler
- Returns:
- contentType
-
-