electric.util.mime
Class MIMEData

java.lang.Object
  extended byelectric.util.mime.MIMEData
All Implemented Interfaces:
IHTTPConstants, IIDGenerator, IMIMEConstants

public class MIMEData
extends java.lang.Object
implements IIDGenerator, IMIMEConstants, IHTTPConstants

MIMEData.

Author:
webMethods

Field Summary
 MIMEHeaders headers
           
 java.io.InputStream input
           
 
Fields inherited from interface electric.util.mime.IMIMEConstants
DATA_DIRECTORY, DEFAULT_MIMEDATA_DIRECTORY, DEFAULT_START_MIME_PART, MIME_ATTACHMENT_STYLE, MIME_EXTENSION, STAR_SLASH_STAR_DATAHANDLER
 
Fields inherited from interface electric.util.http.IHTTPConstants
ACCEPT_LANGUAGE, ACCEPT_RANGES, APPLICATION_BINARY, APPLICATION_OCTET_STREAM, ASCII, AUTHORIZATION, BASIC, BOUNDARY, CHARSET_EQUALS, CHUNKED, CLOSE, COLON_SLASH_SLASH, CONNECT, CONNECTION, CONTENT_ID, CONTENT_LANGUAGE, CONTENT_LENGTH, CONTENT_LOCATION, CONTENT_TYPE, CONTINUATION_STATUS, CONTINUE_EXPECTATION, COOKIE, COOKIE_LISTENER, DATE, DEFAULT_CONTENT_TYPE, DEFAULT_HTTP_CHARSET, DEFAULT_HTTPS_PORT, DEFAULT_MIME_TYPE, DEFAULT_PROXY_PORT, DIGEST, EOL, EXPECT, EXPECT_HEADER, FORM_URLENCODED, GET, GLUE_SESSION, HEAD, HOST, HTTP_1_0, HTTP_1_1, HTTP_PROTOCOL, HTTPS_PROTOCOL, IF_MODIFIED_SINCE, KEEP_ALIVE, LAST_MODIFIED, LOCATION, MD5_HASH, MIME_BOUNDARY, MIME_VERSION, MULTIPART_CONTENT_TYPE, OK, POST, PROXY_AUTHORIZATION, RANGE, SC_CONTINUE, SC_MOVED, SC_MOVED_PERMANENTLY, SC_OK, SC_PROXY_AUTHENTICATION_REQUIRED, SC_UNAUTHORIZED, SEPARATOR, SERVER, SERVER_PREFIX, SERVER_TYPE, SET_COOKIE_0, SET_COOKIE_1, SLASH, START, TEXT_HTML, TEXT_PLAIN, TEXT_XML, TEXT_XML_UTF_8, TRANSFER_ENCODING, USER_AGENT, WWW_AUTHENTICATE
 
Constructor Summary
MIMEData()
           
MIMEData(byte[] bytes)
          Construct a MIMEData out of the bytes provided, in the content type "application/binary".
MIMEData(byte[] bytes, java.lang.String contentType)
          Construct a MIMEData out of the bytes provided in the content type specified.
MIMEData(java.io.File file)
          Construct a MIMEData out of the file, with the content-type "application/binary".
MIMEData(java.io.File file, java.lang.String contentType)
          Construct a MIMEData with the file provided as the body, of the content type provided.
MIMEData(java.io.InputStream input, int contentLength)
          Construct a MIMEData out of the InputStream, with a content length provided, of type "application/binary".
MIMEData(java.io.InputStream input, int contentLength, java.lang.String contentType)
          Construct a MIMEData out of the InputStream, with the content-length provided, of the type provided.
MIMEData(java.io.InputStream input, java.lang.String contentLocation, Context context)
          Construct a MIMEData from data on the InputStream, with the Content-Location, using whatever parameters are in the Context.
MIMEData(java.io.InputStream input, java.lang.String contentLocation, java.lang.String seperator, Context context)
          Construct a MIMEData from data on the InputStream, with the Content-Location, using whatever parameters are in the Context.
MIMEData(java.lang.String content)
          Construct a MIMEData out of the content provided.
MIMEData(java.lang.String content, java.lang.String contentType)
          Construct a MIMEData out of the content provided, in the content type provided.
MIMEData(java.net.URL url)
          Construct a MIMEData out of the url provided.
 
Method Summary
 boolean dispose()
          Dispose of me, via my handler.
 java.lang.String generateId()
          Generate a Universally Unique id for me.
 byte[] getBytes()
          Return an array of bytes of my content.
 java.lang.String getContentId()
          Return my "Content-ID" header.
 java.lang.String getContentLabel()
          Return my appropriate label according to the MIME Spec.
 int getContentLength()
          Return the length of my body.
 java.lang.String getContentType()
          Return my Content-Type.
 byte[] getDelimiter()
          Get my MIME part separator.
 int getFormattedContentLength()
          to understand how the content length is calculated consider the following template of a mime data part in a message: -------------------------------- | EOL | |------------------------------| | --mime_boundary | - this one is set by setDelimeter() |------------------------------| | EOL | |------------------------------| | headers | - the headers include Content-Location, |------------------------------| Content-ID, and Content-Type | EOL | |------------------------------| | content | |------------------------------| | EOL | --------------------------------
 java.io.InputStream getFormattedInputStream()
          Return an InputStream with the header, body, and seperator for the MIMEData object.
 IDataHandler getHandler()
          Return my MIME data handler.
 java.io.InputStream getInputStream()
          Return the InputStream that represents my body.
 void readContent(java.io.InputStream inputStream, Context context)
          Create the InputStream for my body from the InputStream.
 void readHeaders(java.io.InputStream input)
          Read my headers off the InputStream, and do what preprocessing needs to be done.
 void setBaseContentLocation(java.lang.String baseContentLocation)
          Set my baseContentLocation.
 void setContentLabel(java.lang.String contentLabel)
           
 void setContentLength(int contentLength)
          Set the length of my body.
 void setContentType(java.lang.String type)
          Set my Content-Type.
 void setDelimiter(byte[] delimiter)
          Set my MIME part separator.
 void setHandler(IDataHandler handler)
          Set my MIME data handler.
 void setInputStream(java.io.InputStream input)
          Set the InputStream that represents my body.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

headers

public MIMEHeaders headers

input

public java.io.InputStream input
Constructor Detail

MIMEData

public MIMEData()

MIMEData

public MIMEData(java.lang.String content)
Construct a MIMEData out of the content provided. It will be in "text/plain" content type.

Parameters:
content -

MIMEData

public MIMEData(java.lang.String content,
                java.lang.String contentType)
Construct a MIMEData out of the content provided, in the content type provided.

Parameters:
content -
contentType -

MIMEData

public MIMEData(byte[] bytes)
Construct a MIMEData out of the bytes provided, in the content type "application/binary".

Parameters:
bytes -

MIMEData

public MIMEData(byte[] bytes,
                java.lang.String contentType)
Construct a MIMEData out of the bytes provided in the content type specified.

Parameters:
bytes -
contentType -

MIMEData

public MIMEData(java.net.URL url)
         throws java.io.IOException
Construct a MIMEData out of the url provided. The "Content-Location" header is set to the url.

Parameters:
url -
Throws:
java.io.IOException

MIMEData

public MIMEData(java.io.InputStream input,
                int contentLength)
Construct a MIMEData out of the InputStream, with a content length provided, of type "application/binary".

Parameters:
input -
contentLength - the length of the content.

MIMEData

public MIMEData(java.io.InputStream input,
                int contentLength,
                java.lang.String contentType)
Construct a MIMEData out of the InputStream, with the content-length provided, of the type provided.

Parameters:
input - The input stream where we pull the content from.
contentLength - the length of the content.
contentType - The contentType that should be placed in the header of this MIME part.

MIMEData

public MIMEData(java.io.File file)
         throws java.io.FileNotFoundException
Construct a MIMEData out of the file, with the content-type "application/binary".

Parameters:
file - A handle to the file to be sent as a MIMEData
Throws:
java.io.FileNotFoundException

MIMEData

public MIMEData(java.io.File file,
                java.lang.String contentType)
         throws java.io.FileNotFoundException
Construct a MIMEData with the file provided as the body, of the content type provided.

Parameters:
file - A handle to the file to be sent as a MIMEData
contentType - The contentType that should be placed in the header of this MIME part.
Throws:
java.io.FileNotFoundException

MIMEData

public MIMEData(java.io.InputStream input,
                java.lang.String contentLocation,
                Context context)
         throws java.io.IOException
Construct a MIMEData from data on the InputStream, with the Content-Location, using whatever parameters are in the Context.

Parameters:
input -
contentLocation -
context -
Throws:
java.io.IOException

MIMEData

public MIMEData(java.io.InputStream input,
                java.lang.String contentLocation,
                java.lang.String seperator,
                Context context)
         throws java.io.IOException
Construct a MIMEData from data on the InputStream, with the Content-Location, using whatever parameters are in the Context.

Parameters:
input - The input stream where we pull the content from.
contentLocation -
seperator - The MIMEData Seperator for this message.
context -
Throws:
java.io.IOException
Method Detail

setInputStream

public void setInputStream(java.io.InputStream input)
Set the InputStream that represents my body.

Parameters:
input -

getInputStream

public java.io.InputStream getInputStream()
Return the InputStream that represents my body.


setContentType

public void setContentType(java.lang.String type)
Set my Content-Type.

Parameters:
type -

getContentType

public java.lang.String getContentType()
Return my Content-Type.


getContentLength

public int getContentLength()
Return the length of my body.


setContentLength

public void setContentLength(int contentLength)
Set the length of my body.

Parameters:
contentLength -

getFormattedInputStream

public java.io.InputStream getFormattedInputStream()
                                            throws java.io.IOException
Return an InputStream with the header, body, and seperator for the MIMEData object.

Throws:
java.io.IOException

getFormattedContentLength

public int getFormattedContentLength()
                              throws java.io.IOException
to understand how the content length is calculated consider the following template of a mime data part in a message: -------------------------------- | EOL | |------------------------------| | --mime_boundary | - this one is set by setDelimeter() |------------------------------| | EOL | |------------------------------| | headers | - the headers include Content-Location, |------------------------------| Content-ID, and Content-Type | EOL | |------------------------------| | content | |------------------------------| | EOL | --------------------------------

Throws:
java.io.IOException

setBaseContentLocation

public void setBaseContentLocation(java.lang.String baseContentLocation)
Set my baseContentLocation. The baseContentLocation is the Content-Location from the headers on the MIME message. If you have a multi-part MIME message with an absolute Content-Location header in the header section of the entire MIME message, and a relative Content-Location in me, the Content-Location is the Content-Location of the message + "/" + my Content-Location.

Parameters:
baseContentLocation -

getContentId

public java.lang.String getContentId()
Return my "Content-ID" header. If one exists, it should be "Universally Unique".


getContentLabel

public java.lang.String getContentLabel()
Return my appropriate label according to the MIME Spec. If I have a Content-Location header and it is absolute, it is the Label. If it's relative, and there is an absolute Content-Location for the MIME message I am a part of, the Label is the concatenation of them. If the message has no Content-Location or it is relative, the start of the absolute path is "thismessage:/".


setContentLabel

public void setContentLabel(java.lang.String contentLabel)
Parameters:
contentLabel -

setHandler

public void setHandler(IDataHandler handler)
Set my MIME data handler.

Parameters:
handler - The new value.

getHandler

public IDataHandler getHandler()
Return my MIME data handler.


getBytes

public byte[] getBytes()
                throws java.io.IOException
Return an array of bytes of my content. Users of this method call must be very careful as I could be very large and this operation may result in unstable behavior or even failure of the VM.

Throws:
java.io.IOException

dispose

public boolean dispose()
                throws java.io.IOException
Dispose of me, via my handler. Return true if my handler was able to dispose of me properly.

Throws:
java.io.IOException

readHeaders

public void readHeaders(java.io.InputStream input)
                 throws java.io.IOException
Read my headers off the InputStream, and do what preprocessing needs to be done.

Parameters:
input -
Throws:
java.io.IOException

readContent

public void readContent(java.io.InputStream inputStream,
                        Context context)
                 throws java.io.IOException
Create the InputStream for my body from the InputStream. The context should contain the appropriate dataHandler for the Content-Type of this MIME part.

Parameters:
inputStream -
context -
Throws:
java.io.IOException

generateId

public java.lang.String generateId()
Generate a Universally Unique id for me.

Specified by:
generateId in interface IIDGenerator

setDelimiter

public void setDelimiter(byte[] delimiter)
Set my MIME part separator.

Parameters:
delimiter -

getDelimiter

public byte[] getDelimiter()
Get my MIME part separator.



copyright© 2001-2004 by webMethods All Rights Reserved.