|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object javax.wireless.messaging.MessagePart
Instances of the MessagePart
class can be added to a MultipartMessage
.
Each MessagePart
consists of the content element, MIME type
and content-id. The Content can be of any type. Additionally it's possible
to specify the content location and the encoding scheme.
Constructor Summary | |
MessagePart(byte[] contents,
int offset,
int length,
java.lang.String mimeType,
java.lang.String contentId,
java.lang.String contentLocation,
java.lang.String enc)
Constructs a MessagePart object from a subset of the byte
array. |
|
MessagePart(byte[] contents,
java.lang.String mimeType,
java.lang.String contentId,
java.lang.String contentLocation,
java.lang.String enc)
Constructs a MessagePart object from a byte array. |
|
MessagePart(java.io.InputStream is,
java.lang.String mimeType,
java.lang.String contentId,
java.lang.String contentLocation,
java.lang.String enc)
Constructs a MessagePart object from an InputStream .
|
Method Summary | |
boolean |
equals(java.lang.Object o)
Compares two message parts for equality. |
byte[] |
getContent()
Returns the content of the MessagePart as an array of
bytes. |
java.io.InputStream |
getContentAsStream()
Returns an InputStream for reading the contents of the
MessagePart . |
java.lang.String |
getContentID()
Returns the content-id value of the MessagePart |
java.lang.String |
getContentLocation()
Returns content location of the MessagePart |
java.lang.String |
getEncoding()
Returns the encoding of the content, e.g. |
int |
getLength()
Returns the content size of this MessagePart |
java.lang.String |
getMIMEType()
Returns the mime type of the MessagePart |
int |
hashCode()
Returns the hash code of this message part. |
java.lang.String |
toString()
Returns a string representation of this message part. |
Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public MessagePart(java.io.InputStream is, java.lang.String mimeType, java.lang.String contentId, java.lang.String contentLocation, java.lang.String enc) throws java.io.IOException, SizeExceededException
MessagePart
object from an InputStream
.
The contents of the MessagePart
are loaded from the
InputStream
during the constructor call until the end of
stream is reached.
is
- InputStream
from which the contents of the
MessagePart
are readmimeType
- the MIME Content-Type for the MessagePart
[RFC
2046]contentId
- the content-id header field value for the MessagePart
[RFC 2045]. The content-id is unique over all MessageParts
of a MultipartMessage
and must always be set
for each message partcontentLocation
- the content location which specifies the file name of the
file that is attached. If the content location is set to
null
no content location will be set for this
MessagePart
.enc
- the encoding scheme for the MessagePart
. If
enc is set to null
no encoding will be used
for this MessagePart
.
java.io.IOException
- if the reading of the InputStream
causes an
exception other than EOFException
java.lang.IllegalArgumentException
- if mimeType or contentId is null
. This
exception will be thrown if contentID
or
contentLocation
contains other characters
than specified in US-ASCII format or if the specified
encoding scheme is unknown.
SizeExceededException
- if the content from the InputStream
is larger
than the available memory or supported size for the message
part.public MessagePart(byte[] contents, java.lang.String mimeType, java.lang.String contentId, java.lang.String contentLocation, java.lang.String enc) throws SizeExceededException
MessagePart
object from a byte array. This
constructor is only useful, if the data size is small (roughly less than
10K). For larger content the InputStream
based
constructor should be used.
contents
- byte array containing the contents for the MessagePart
.
The contents of the array will be copied into the MessagePart
.mimeType
- the MIME Content-Type for the MessagePart
[RFC
2046]contentId
- the content-id header field value for the MessagePart
[RFC 2045]. The content-id is unique over all MessageParts
of a MultipartMessage
and must always be set
for each message partcontentLocation
- the content location which specifies the file name of the
file that is attached. If the content location is set to
null
no content location will be set for this
MessagePart
.enc
- the encoding scheme for the MessagePart
. If
enc is set to null
no encoding will be used
for this MessagePart
.
java.lang.IllegalArgumentException
- if mimeType or contentId is null
. This
exception will be thrown if contentID
or
contentLocation
contains other characters
than specified in US-ASCII format or if the specified
encoding scheme is unknown
SizeExceededException
- if the contents
is larger than the available
memory or supported size for the message part.public MessagePart(byte[] contents, int offset, int length, java.lang.String mimeType, java.lang.String contentId, java.lang.String contentLocation, java.lang.String enc) throws SizeExceededException
MessagePart
object from a subset of the byte
array. This constructor is only useful, if the data size is small
(roughly less than 10K). For larger content the InputStream
based constructor should be used.
contents
- byte array containing the contents for the MessagePart
offset
- start positionlength
- the number of bytes to be included in the MessagePart
mimeType
- the MIME Content-Type for the MessagePart
[RFC
2046]contentId
- the content-id header field value for the MessagePart
[RFC 2045]. The content-id is unique over all MessageParts
of a MultipartMessage
and must always be set
for each message partcontentLocation
- the content location which specifies the file name of the
file that is attached. If the content location is set to
null
no content location will be set for this
MessagePart
.enc
- the encoding scheme for the MessagePart
. If
enc is set to null
no encoding will be used
for this MessagePart
.
java.lang.IllegalArgumentException
- if mimeType or contentId is null
. This
exception will be thrown if contentID
or
contentLocation
contains other characters
than specified in US-ASCII format This exception will be
thrown if either length
is less than 0
or offset + length
exceeds the length
of the content
or if offset
is
less than 0
or if the specified encoding
scheme is unknown.
SizeExceededException
- if the contents
is larger than the available
memory or supported size for the message part.Method Detail |
public byte[] getContent()
MessagePart
as an array of
bytes. If it's not possible to create an array, which can contain all
data, this method must throw an OutOfMemoryError
.
MessagePart
data as byte arraypublic java.io.InputStream getContentAsStream()
InputStream
for reading the contents of the
MessagePart
. Returns an empty stream if no content is
available.
InputStream
that can be used for reading the
contents of this MessagePart
public java.lang.String getContentID()
MessagePart
null
if
the content-id is not set It might happen if the message was
sent from a not JSR 205 compliant client.public java.lang.String getMIMEType()
MessagePart
MessagePart
public java.lang.String getEncoding()
String
MessagePart
content or null
if the encoding scheme of the MessagePart
cannot
be determinedpublic java.lang.String getContentLocation()
MessagePart
public int getLength()
MessagePart
MessagePart
or
0
if the MessagePart
is empty.public boolean equals(java.lang.Object o)
public int hashCode()
public java.lang.String toString()
|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |