Copyright 2012-02-25 Werner Randelshofer

ch.randelshofer.view
Class ZipEntryDataSource

java.lang.Object
  extended by ch.randelshofer.view.ZipEntryDataSource
All Implemented Interfaces:
javax.activation.DataSource

public class ZipEntryDataSource
extends java.lang.Object
implements javax.activation.DataSource

The FileDataSource class implements a simple DataSource object that encapsulates a zip entry. It provides data typing services via a FileTypeMap object.

FileDataSource Typing Semantics:

The FileDataSource class delegates data typing of files to an object subclassed from the FileTypeMap class.The setFileTypeMap method can be used to explicitly set the FileTypeMap for an instance of FileDataSource. If no FileTypeMap is set, the FileDataSource will call the FileTypeMap's getDefaultFileTypeMap method to get the System's default FileTypeMap.

Author:
Werner Randelshofer

Constructor Summary
ZipEntryDataSource(byte[] data, java.util.zip.ZipEntry zipEntry)
          Creates a new instance of ZipEntryDataSource from a ZipEntry object.
ZipEntryDataSource(java.util.zip.ZipFile zipFile, java.util.zip.ZipEntry zipEntry)
          Creates a new instance of ZipEntryDataSource from a ZipEntry object.
 
Method Summary
 java.lang.String getContentType()
          This method returns the MIME type of the data in the form of a string.
 java.io.InputStream getInputStream()
          This method returns an InputStream representing the the data and throws the appropriate exception if it can not do so.
 java.lang.String getName()
          Return the name of this object where the name of the object is dependant on the nature of the underlying objects.
 java.io.OutputStream getOutputStream()
           
 void setFileTypeMap(javax.activation.FileTypeMap map)
          Set the FileTypeMap to use with this FileDataSource.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ZipEntryDataSource

public ZipEntryDataSource(java.util.zip.ZipFile zipFile,
                          java.util.zip.ZipEntry zipEntry)
Creates a new instance of ZipEntryDataSource from a ZipEntry object.


ZipEntryDataSource

public ZipEntryDataSource(byte[] data,
                          java.util.zip.ZipEntry zipEntry)
Creates a new instance of ZipEntryDataSource from a ZipEntry object.

Method Detail

getContentType

public java.lang.String getContentType()
This method returns the MIME type of the data in the form of a string. This method uses the currently installed FileTypeMap. If there is no FileTypeMap explictly set, the FileDataSource will call the getDefaultFileTypeMap method on FileTypeMap to acquire a default FileTypeMap.

Specified by:
getContentType in interface javax.activation.DataSource

getInputStream

public java.io.InputStream getInputStream()
                                   throws java.io.IOException
This method returns an InputStream representing the the data and throws the appropriate exception if it can not do so.

Specified by:
getInputStream in interface javax.activation.DataSource
Returns:
an InputStream
Throws:
java.io.IOException

getName

public java.lang.String getName()
Return the name of this object where the name of the object is dependant on the nature of the underlying objects. DataSources encapsulating files may choose to return the filename of the object. (Typically this would be the last component of the filename, not an entire pathname.)

Specified by:
getName in interface javax.activation.DataSource

getOutputStream

public java.io.OutputStream getOutputStream()
                                     throws java.io.IOException
Specified by:
getOutputStream in interface javax.activation.DataSource
Throws:
java.io.IOException

setFileTypeMap

public void setFileTypeMap(javax.activation.FileTypeMap map)
Set the FileTypeMap to use with this FileDataSource.

Parameters:
map - The FileTypeMap for this object.

Copyright 2012-02-25 Werner Randelshofer