Oracle Application Server Wireless Java API Reference
B14043-01


oracle.panama.messaging.common
Class MessagePart

java.lang.Object
  extended byoracle.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 complex as composed 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 actual Java object type of the message content depending on Mime type of the Part:
&nbsp1) MultiPart If the MIME type indicates multipart. In this case, the individual parts will be furthur examined.
&nbsp2) text If the MIME type indicates text, the content should be a String object.
&nbsp3) byte[] Any other MIME types. This is essentially an opaque block of data upto the protocol handlers to process.
&nbsp4) 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 three types:
&nbsp&nbsp&nbsp&nbspWapSettings - deliver to handset WAP provisioning messages
&nbsp&nbsp&nbsp&nbspRING_TONE - deliver to handset a piece of music as ringtone
&nbsp&nbsp&nbsp&nbspGRAPHICS - 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.

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
Constant for content id header.
static java.lang.String CONTENT_LOCATION_KEY
Constant for content location header.
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.
Headers are name value pairs both in the form of Strings.
boolean equals(java.lang.Object other)
Checks equality of two MessagePart.
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()
Returns the value of "Content-ID" header field.
java.lang.String getContentLocation()
Returns the value of "Content-Location" header field.
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)
Get the first value for the named header.
int hashCode()
Generates and return hashcode for the instance.
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)
Set the value of "Content-ID" header field.
void setContentLocation(java.lang.String contentLoc)
set the value of "Content-Location" header field.
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.
Disposition describes how a part should be presented to the user.
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.
Headers are name value pairs both in the form of Strings.
java.lang.String toString()
Overrides the default toString.
void writeExternal(java.io.ObjectOutput oo)
Write a message instance to a stream.

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

Field Detail

CHARSET_KEY

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

CONTENT_DISPOSITION_KEY

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

CONTENT_ID_KEY

public static final java.lang.String CONTENT_ID_KEY
Constant for content id header.
See Also:
Constant Field Values

CONTENT_LOCATION_KEY

public static final java.lang.String CONTENT_LOCATION_KEY
Constant for content location 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

FILENAME_KEY

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

Constructor Detail

MessagePart

public MessagePart()

Method Detail

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)

equals

public boolean equals(java.lang.Object other)
Checks equality of two MessagePart.
Parameters:
other - MessagePart which is to checked for equality with "this" object.
Returns:
true if the MessageParts are equal else returns false.

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.

getContent

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

getContentId

public java.lang.String getContentId()
Returns the value of "Content-ID" header field.
Returns:
the content id.

getContentLocation

public java.lang.String getContentLocation()
Returns the value of "Content-Location" header field.
Returns:
the content location

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.

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.

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)

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

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)

getSimpleHeader

public java.lang.String getSimpleHeader(java.lang.String name)
Get the first value for the named header.
Parameters:
name - name of the header
Returns:
value of the header.

hashCode

public int hashCode()
Generates and return hashcode for the instance.
Returns:
hash code.

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

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.
Throws:
java.io.IOException
java.lang.ClassNotFoundException

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.

setContent

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

setContentId

public void setContentId(java.lang.String contentId)
Set the value of "Content-ID" header field.
Parameters:
contentId -

setContentLocation

public void setContentLocation(java.lang.String contentLoc)
set the value of "Content-Location" header field.
Parameters:
contentLoc -

setContentType

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

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.

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 -

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.

toString

public java.lang.String toString()
Overrides the default toString.
Returns:
string containing the header and content of the MessagePart.

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.
Throws:
java.io.IOException

Oracle Application Server Wireless Java API Reference
B14043-01


Copyright © 2004 Oracle Corporation. All Rights Reserved.