com.openexchange.mail.mime.datasource
Class StreamDataSource

java.lang.Object
  extended by com.openexchange.mail.mime.datasource.StreamDataSource
All Implemented Interfaces:
javax.activation.DataSource

public final class StreamDataSource
extends java.lang.Object
implements javax.activation.DataSource

StreamDataSource - A simple data source that encapsulates an input stream provider.

Author:
Thorben Betten

Nested Class Summary
static interface StreamDataSource.InputStreamProvider
          Provides a newly allocated input stream.
 
Constructor Summary
StreamDataSource(StreamDataSource.InputStreamProvider provider)
          Creates a StreamDataSource from an InputStreamProvider object.
StreamDataSource(StreamDataSource.InputStreamProvider provider, java.lang.String contentType)
          Creates a StreamDataSource from an InputStreamProvider object.
 
Method Summary
 java.lang.String getContentType()
           
 java.io.InputStream getInputStream()
           
 java.lang.String getName()
           
 java.io.OutputStream getOutputStream()
          Not implemented
 void setContentType(java.lang.String contentType)
          Sets the content type.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StreamDataSource

public StreamDataSource(StreamDataSource.InputStreamProvider provider)
Creates a StreamDataSource from an InputStreamProvider object. Note: The stream will not actually be opened until a method is called that requires the stream to be opened.

Content type is initially set to "application/octet-stream".

Parameters:
provider - The input stream provider

StreamDataSource

public StreamDataSource(StreamDataSource.InputStreamProvider provider,
                        java.lang.String contentType)
Creates a StreamDataSource from an InputStreamProvider object. Note: The stream will not actually be opened until a method is called that requires the stream to be opened.

Parameters:
provider - The input stream provider
contentType - The content type
Method Detail

getInputStream

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

getOutputStream

public java.io.OutputStream getOutputStream()
                                     throws java.io.IOException
Not implemented

Specified by:
getOutputStream in interface javax.activation.DataSource
Throws:
java.io.IOException

getContentType

public java.lang.String getContentType()
Specified by:
getContentType in interface javax.activation.DataSource

getName

public java.lang.String getName()
Specified by:
getName in interface javax.activation.DataSource

setContentType

public void setContentType(java.lang.String contentType)
Sets the content type.

Parameters:
contentType - The content type.