Oracle Application Server Wireless Java API Reference
B10400-01

oracle.panama.messaging.common
Class MessagePart

java.lang.Object
  |
  +--oracle.panama.messaging.common.MessagePart
All Implemented Interfaces:
java.io.Externalizable, java.io.Serializable
Direct Known Subclasses:
Message

public class MessagePart
extends java.lang.Object
implements java.io.Externalizable

This class declares the main construct that represents a message. Messages can be as simple as text only, or as comlex as composing of multi-parts with the type of each part described by its MIME type, similiar to the way email messages are describe. MIME types can be any standard MIME type plus a few predetermined types that have special meanings to OracleAS Wireless as declared in class ContentTypes. From an interface point of view, the content of a Part is of the Java Object type. However, the protocol handlers have an implicit set of types that they operate on. While it'd be syntatically correct to give the content of any java type, semantics there are a few rules to observe. Basically there are several possibility for the actuall Java object type of the message content depending on Mime type of the Part: 1) MultiPart If the MIME type indicates multipart. In this case, the individual parts will be furthur examined. 2) text If the MIME type indicates text, the content should be a String object. 3) Hashtable Hashtable is mostly used currently for messages to be delivered as SMS smart messages. Because different types of smart message requires different set of parameters, hashtable is used for applications to specify the particular parameters needed for the kind of smart message requested. There are a large set of smart message types and OracleAS Wireless out of the box supports 3 types: WapSettings - deliver to handset WAP provisioning messages RING_TONE - deliver to handset a piece of music as ringtone GRAPHICS - deliver to handset an image as logo etc Note that the content of the smart messages are often times handset dependent. The product supports only Nokia and Erricsson handset out of the box. Consult your system administrator to understand the actual set of smart message and handset available to you. 4) byte[] Any other MIME types. This is essentially an opaque block of data upto the protocol handlers to process.

Author:
jxiang
See Also:
WapSettings, RingTone, Graphics, ContentTypes, Serialized Form

Field Summary
static java.lang.String CHARSET_KEY
          Constant for the charset parameter
static java.lang.String CONTENT_DISPOSITION_KEY
          Constant for the content disposition header
static java.lang.String CONTENT_ID_KEY
           
static java.lang.String CONTENT_LOCATION_KEY
           
static java.lang.String CONTENT_TYPE_KEY
          Constant for the content type header
static java.lang.String FILENAME_KEY
          Constant for the filename parameter within the disposition header

 

Constructor Summary
MessagePart()
           

 

Method Summary
 void addHeader(java.lang.String name, java.lang.String value)
          Add one more value for an existing header into the message.
 java.util.Enumeration getAllHeaders()
          Return all the headers from this part as an Enumeration of Header objects.
 java.lang.Object getContent()
          Retrieve content of the message.
 java.lang.String getContentId()
           
 java.lang.String getContentLocation()
           
 java.lang.String getContentType()
          Returns the value of the "Content-Type" header field.
 java.lang.String getDisposition()
          Returns the value of the "Content-Disposition" header field.
 java.lang.String getFileName()
          Get the filename value for the message part.
 java.lang.String[] getHeader(java.lang.String name)
          Get all the value for the named header.
 java.lang.String getHeader(java.lang.String name, java.lang.String delimiter)
          Get all the headers for this header name, returned as a single String, with headers separated by the delimiter.
 java.lang.String getHeaderParameter(java.lang.String header, java.lang.String name)
          Get parameter in the header.
 java.lang.String getSimpleHeader(java.lang.String name)
           
 boolean isMimeType(java.lang.String mimeType)
          Compare and determine if the message MIME type is of the one specified.
 void readExternal(java.io.ObjectInput oi)
          Read a message instance from a stream.
 java.lang.String[] removeHeader(java.lang.String name)
          Remove a named header if set.
 void setContent(java.lang.Object content)
          Set the content of the message part.
 void setContentId(java.lang.String contentId)
           
 void setContentLocation(java.lang.String contentLoc)
           
 void setContentType(java.lang.String contentType)
          Set the value for content type header.
 void setDisposition(java.lang.String disposition)
          Set the value for content disposition header.
 void setFileName(java.lang.String filename)
          Set the filename associated with this message part.
 void setHeader(java.lang.String name, java.lang.String value)
          Set and replace all existing values for this header with this new value.
 void writeExternal(java.io.ObjectOutput oo)
          Write a message instance to a stream.

 

Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

 

Field Detail

CONTENT_DISPOSITION_KEY

public static final java.lang.String CONTENT_DISPOSITION_KEY
Constant for the content disposition header
See Also:
Constant Field Values

CONTENT_TYPE_KEY

public static final java.lang.String CONTENT_TYPE_KEY
Constant for the content type header
See Also:
Constant Field Values

CONTENT_ID_KEY

public static final java.lang.String CONTENT_ID_KEY
See Also:
Constant Field Values

CONTENT_LOCATION_KEY

public static final java.lang.String CONTENT_LOCATION_KEY
See Also:
Constant Field Values

FILENAME_KEY

public static final java.lang.String FILENAME_KEY
Constant for the filename parameter within the disposition header
See Also:
Constant Field Values

CHARSET_KEY

public static final java.lang.String CHARSET_KEY
Constant for the charset parameter
See Also:
Constant Field Values
Constructor Detail

MessagePart

public MessagePart()
Method Detail

getContent

public java.lang.Object getContent()
Retrieve content of the message.
Returns:
content of the message.

setContent

public void setContent(java.lang.Object content)
Set the content of the message part.
Parameters:
content - the message content.

addHeader

public void addHeader(java.lang.String name,
                      java.lang.String value)
Add one more value for an existing header into the message. Headers are name value pairs both in the form of Strings. There can be multiple values associated with one header. A typical example is the 'Received' header specific for e-mail, it's the trace information added by each mail relay. There could be multiple 'Received' header if there're more than one relay between the sending and the destination mail server. Each header value could in turn be name-value pairs themselves. For example, the content-type header can have a value of text/ascii;charset=7bits The name of each of such pairs is called a parameter within that header. For example, charset is a parameter of the content-type header here. A few commonly used headers are defined as constants in this class. Depending on the nature of the message itself, arbitrary number of headers can be set. It is up to the protocol handlers to process the headers and impose whatever semantics it might mean in that particular protocol. And sometime a header that make sense for one protocol might not make sense for another. For example, User-Agent makes sense for email but not for SMS.
Parameters:
name - header name.
value - header value.
See Also:
setHeader(java.lang.String, java.lang.String)

getAllHeaders

public java.util.Enumeration getAllHeaders()
Return all the headers from this part as an Enumeration of Header objects.
Returns:
An instance of Enumeration consisting of all Header objects previous set.

getSimpleHeader

public java.lang.String getSimpleHeader(java.lang.String name)

getHeader

public java.lang.String[] getHeader(java.lang.String name)
Get all the value for the named header.
Parameters:
name - name of header
Returns:
array of the header values.

getHeader

public java.lang.String getHeader(java.lang.String name,
                                  java.lang.String delimiter)
Get all the headers for this header name, returned as a single String, with headers separated by the delimiter.
Parameters:
name - name of header
delimiter - delimiter which separates each header
Returns:
the value fields for all headers with this name

setHeader

public void setHeader(java.lang.String name,
                      java.lang.String value)
Set and replace all existing values for this header with this new value. Headers are name value pairs both in the form of Strings. There can be multiple values associated with one header. A typical example is the 'Received' header specific for e-mail, it's the trace information added by each mail relay. There could be multiple 'Received' header if there're more than one relay between the sending and the destination mail server. Each header value could in turn be name-value pairs themselves. For example, the content-type header can have a value of text/ascii;charset=7bits The name of each of such pairs is called a parameter within that header. For example, charset is a parameter of the content-type header here. A few commonly used headers are defined as constants in this class. Depending on the nature of the message itself, arbitrary number of headers can be set. It is up to the protocol handlers to process the headers and impose whatever semantics it might mean in that particular protocol. And sometime a header that make sense for one protocol might not make sense for another. For example, User-Agent makes sense for email but not for SMS.
Parameters:
name - header name.
value - header value.

removeHeader

public java.lang.String[] removeHeader(java.lang.String name)
Remove a named header if set.
Parameters:
name - header name.
Returns:
the values of the removed header.

getDisposition

public java.lang.String getDisposition()
Returns the value of the "Content-Disposition" header field. This represents the disposition of this part. The disposition describes how the part should be presented to the user. The common values are 'inline' and 'attachment'.
Returns:
the message disposition of the message part.

setDisposition

public void setDisposition(java.lang.String disposition)
Set the value for content disposition header. Disposition describes how a part should be presented to the user. For example, whether it should be in-line or should be a reference. Some of the common values for disposition are: 'inline' and 'attachment'. Generally, a MessagePart should be displayed automatically if its Content-Disposition is specified as 'inline'. Having the value of 'attachment' indicates the the MessagePart is separated from the main body of the message and should be displayed upon some user actions.
Parameters:
disposition - header value of the content disposition.

getContentType

public java.lang.String getContentType()
Returns the value of the "Content-Type" header field. ContentType is basically the MIME type of the message part.
Returns:
the message part MIME type.

getContentId

public java.lang.String getContentId()

getContentLocation

public java.lang.String getContentLocation()

setContentType

public void setContentType(java.lang.String contentType)
Set the value for content type header.
Parameters:
contentType - header value of the content type.

setContentId

public void setContentId(java.lang.String contentId)

setContentLocation

public void setContentLocation(java.lang.String contentLoc)

isMimeType

public boolean isMimeType(java.lang.String mimeType)
Compare and determine if the message MIME type is of the one specified. This method compares the primary and subtype of the message to determine if it is one that's in question.
Returns:
true if the message part MIME type matches the specified type false if the message part MIME type does not match the specified type

getFileName

public java.lang.String getFileName()
Get the filename value for the message part. Returns the value of the "filename" parameter from the "Content-Disposition" header field of this MessagePart. If it is not available, returns the value of the "name" parameter from the "Content-Type" header field of this body part.
Returns:
filename
See Also:
setHeader(java.lang.String, java.lang.String)

setFileName

public void setFileName(java.lang.String filename)
Set the filename associated with this message part. This field is useful when the message part is an attachment. This should be a simple file name without the path information.
Parameters:
filename -

getHeaderParameter

public java.lang.String getHeaderParameter(java.lang.String header,
                                           java.lang.String name)
Get parameter in the header. This method locates the parameter as specified in "name" for the header named "header". One example is to locate the charset value for the Content-Type header
Parameters:
header - the header string
name - the parameter name
Returns:
the value for the parameter name
See Also:
setHeader(java.lang.String, java.lang.String)

readExternal

public void readExternal(java.io.ObjectInput oi)
                  throws java.io.IOException,
                         java.lang.ClassNotFoundException
Read a message instance from a stream.
Specified by:
readExternal in interface java.io.Externalizable
Parameters:
oi - the stream to read from.
java.io.IOException
java.lang.ClassNotFoundException

writeExternal

public void writeExternal(java.io.ObjectOutput oo)
                   throws java.io.IOException
Write a message instance to a stream.
Specified by:
writeExternal in interface java.io.Externalizable
Parameters:
oo - the stream to write to.
java.io.IOException

Oracle Application Server Wireless Java API Reference
B10400-01

Copyright © 2003 Oracle Corporation. All Rights Reserved.