Methods Summary |
---|
public boolean | addAddress(java.lang.String type, java.lang.String address)Adds an address to the multipart message.
MMSAddress parsedAddress = checkValidAddress(address);
String appID = parsedAddress.appId;
if (appID != null) {
checkApplicationID(appID);
}
Vector which = getAddressList(type);
if (!which.contains(address)) {
which.addElement(address);
return true;
}
return false;
|
public void | addMessagePart(com.sun.tck.wma.MessagePart part)Attaches a MessagePart to the multipart message.
String thisContentID = part.getContentID();
boolean duplicateContentID = false;
int totalSizeSoFar = 0;
int numPartsSoFar = parts.size();
for (int i = 0; i < numPartsSoFar; ++i) {
MessagePart onePart = (MessagePart)parts.elementAt(i);
if (thisContentID.equals(onePart.getContentID())) {
throw new IllegalArgumentException(
"Cannot add duplicate content-id: " + thisContentID);
}
totalSizeSoFar += onePart.getLength();
}
if (totalSizeSoFar + part.getLength() > MAX_TOTAL_SIZE) {
throw new SizeExceededException(
"Adding this MessagePart would exceed max size of " +
MAX_TOTAL_SIZE + " bytes");
}
parts.addElement(part);
|
void | checkApplicationID(java.lang.String newAppID)Checks an application ID to see if it can be legally added to this
message. The spec requires that only a single applicationID can be
specified for any MultipartMessage .
if (applicationID != null) {
if (!applicationID.equals(newAppID)) {
throw new IllegalArgumentException(
"Only one Application-ID can be specified per message");
}
} else {
applicationID = newAppID;
}
|
static void | checkHeaderValue(int headerIndex, java.lang.String value)Checks the header field value.
switch (headerIndex) {
case 0: // X-Mms-Delivery-Time
try {
Long.parseLong(value);
return;
} catch (NumberFormatException nfe) {
// do nothing... we'll report the error in a second
}
break;
case 1: // X-Mms-Priority
{
String lower = value.toLowerCase();
if (lower.equals("normal") || lower.equals("high") ||
lower.equals("low")) {
return;
}
// we'll report the error in a second
break;
}
default:
throw new Error("Unknown headerIndex: " + headerIndex);
}
// report the error
throw new IllegalArgumentException("Illegal value for header " +
ALLOWED_HEADER_FIELDS[headerIndex] + ": " + value);
|
MMSAddress | checkValidAddress(java.lang.String addr)Checks if the string is a valid MMS address according to the grammar
in Appendix D of the spec.
MMSAddress parsedAddress = MMSAddress.getParsedMMSAddress(addr);
// check to make sure there's a device address
if (parsedAddress == null ||
parsedAddress.type == MMSAddress.INVALID_ADDRESS ||
parsedAddress.type == MMSAddress.APP_ID) {
throw new IllegalArgumentException("Invalid destination address: "
+ addr);
}
return parsedAddress;
|
private void | cleanupAppID()Cleans application Id value.
Vector addresses = to;
boolean checkedTo = false;
boolean checkedCC = false;
int currIndex = 0;
boolean matchedAppID = false;
while (true) {
if (currIndex >= addresses.size()) {
if (!checkedTo) {
checkedTo = true;
addresses = cc;
currIndex = 0;
continue;
} else if (!checkedCC) {
checkedCC = true;
addresses = bcc;
currIndex = 0;
continue;
} else {
break;
}
}
String addr = (String)addresses.elementAt(currIndex++);
MMSAddress parsedAddress = MMSAddress.getParsedMMSAddress(addr);
if (parsedAddress == null ||
parsedAddress.type == MMSAddress.INVALID_ADDRESS ||
parsedAddress.type == MMSAddress.APP_ID) {
throw new IllegalStateException(
"Invalid MMS address: " + addr);
}
String thisAppID = parsedAddress.appId;
if (thisAppID != null && thisAppID.equals(applicationID)) {
matchedAppID = true;
}
}
if (!matchedAppID) {
applicationID = null;
}
|
public static com.sun.tck.wma.mms.MultipartObject | createFromByteArray(byte[] data)Create a message object from a serialized byte array.
ByteArrayInputStream bais = new ByteArrayInputStream(data);
DataInputStream dis = new DataInputStream(bais);
String signature = dis.readUTF();
if (!signature.equals(STREAM_SIGNATURE)) {
throw new IOException("invalid data format");
}
// eat the first 6 entries: "X-Mms-Message-Type", "m-send-req",
// "X-Mms-Transaction-ID", <transactionID>, "X-Mms-Version", "1.0"
for (int i = 0; i < 6; ++i) {
dis.readUTF();
}
String[] headerValues = new String[ALLOWED_HEADER_FIELDS.length];
String nextField = dis.readUTF();
int headerIndex;
while ((headerIndex = getHeaderFieldIndex(nextField)) != -1) {
headerValues[headerIndex] = dis.readUTF();
nextField = dis.readUTF();
}
String fromAddress = null;
if (nextField.equals("From")) {
fromAddress = "mms://" + dis.readUTF();
nextField = dis.readUTF();
}
Vector to = new Vector();
if (nextField.equals("To")) {
readVector(dis, to, true);
nextField = dis.readUTF();
}
Vector cc = new Vector();
if (nextField.equals("Cc")) {
readVector(dis, cc, true);
nextField = dis.readUTF();
}
Vector bcc = new Vector();
if (nextField.equals("Bcc")) {
readVector(dis, bcc, true);
nextField = dis.readUTF();
}
long date = 0L;
if (nextField.equals("Date")) {
String dateStr = dis.readUTF();
try {
date = Long.parseLong(dateStr);
} catch (NumberFormatException nfe) {
date = 0L;
}
nextField = dis.readUTF();
}
String subject = null;
if (nextField.equals("Subject")) {
subject = dis.readUTF();
nextField = dis.readUTF();
}
// nextField is "Content-Type"
String startContentID = null;
String applicationID = null;
String replyToApplicationID = null;
Vector contentTypeElements = new Vector();
readVector(dis, contentTypeElements, false);
int numContentTypeElements = contentTypeElements.size();
for (int i = 0; i < numContentTypeElements; ++i) {
String element = (String)contentTypeElements.elementAt(i);
if (element.startsWith("start = <")) {
startContentID = element.substring(9);
startContentID = startContentID.substring(0,
startContentID.length()-1);
} else if (element.startsWith("Application-ID = ")) {
applicationID = element.substring(17);
} else if (element.startsWith("Reply-To-Application-ID = ")) {
replyToApplicationID = element.substring(26);
}
}
nextField = dis.readUTF();
// nextField is "nEntries"
int numParts = 0;
String numPartsStr = dis.readUTF();
try {
numParts = Integer.parseInt(numPartsStr);
} catch (NumberFormatException nfe) {
numParts = 0;
}
Vector parts = new Vector();
for (int i = 0; i < numParts; ++i) {
parts.addElement(createMessagePart(dis));
}
dis.close();
bais.close();
MultipartObject mpo = new MultipartObject(fromAddress);
mpo.setTimeStamp(date);
mpo.headerValues = headerValues;
mpo.subject = subject;
mpo.startContentID = startContentID;
mpo.to = to;
mpo.cc = cc;
/*
* Uncomment this if you want the "bcc"s to be visible to the recipients
mpo.bcc = bcc;
*/
mpo.parts = parts;
mpo.applicationID = applicationID;
mpo.replyToApplicationID = replyToApplicationID;
return mpo;
|
static com.sun.tck.wma.MessagePart | createMessagePart(java.io.DataInputStream dis)Create a new message part from the input stream
String nextField = dis.readUTF(); // eats "Content-Type" header
String contentType = dis.readUTF();
nextField = dis.readUTF();
String contentID = null;
if (nextField.equals("Content-ID")) {
contentID = dis.readUTF();
nextField = dis.readUTF();
}
String encoding = null;
if (nextField.equals("Encoding")) {
encoding = dis.readUTF();
nextField = dis.readUTF();
}
// "Content-Length" was just eaten
int length = dis.readInt();
byte[] contents = new byte[length];
nextField = dis.readUTF(); // eats the "Content" header
dis.readFully(contents);
// now separate the content location and mime type
String mimeType = contentType;
String contentLocation = null;
int sepPos = contentType.indexOf(';");
if (sepPos != -1 && contentType.substring(sepPos).
startsWith("; name=\"")) {
contentLocation = contentType.substring(sepPos+8, // ; name="
contentType.length()-1);
mimeType = contentType.substring(0, sepPos);
}
return new MessagePart(contents, mimeType, contentID, contentLocation,
encoding);
|
public void | fixupReceivedMessageAddresses(java.lang.String senderAddress, java.lang.String myAddress)Prepares a received message to be sent right back to the sender.
Removes this device's address from the "to" and "cc"
address lists and sets the sender's address as the first "to" address.
String regularAddress = myAddress;
String plusAddress = myAddress;
if (regularAddress.charAt(0) == '+") {
regularAddress = regularAddress.substring(1);
} else if (plusAddress.charAt(0) != '+") {
plusAddress = "+" + plusAddress;
}
// remove ourselves from "to" and "cc" list
Vector addresses = to;
for (int i = 0; i < 2; ++i) {
int numAdds = addresses.size();
for (int index = 0; index < numAdds; ++index) {
String thisAddress = (String)addresses.elementAt(index);
MMSAddress parsedAddress =
MMSAddress.getParsedMMSAddress(thisAddress);
if (parsedAddress != null &&
(regularAddress.equals(parsedAddress.address) ||
plusAddress.equals(parsedAddress.address))) {
--numAdds;
addresses.removeElementAt(index);
--index;
}
}
addresses = cc;
}
// set the first "to" address to be the sender's address
if (senderAddress != null) {
String formalAddress = senderAddress;
to.insertElementAt(formalAddress, 0);
MMSAddress parsedAddress =
MMSAddress.getParsedMMSAddress(formalAddress);
applicationID = parsedAddress.appId;
} else {
applicationID = null;
}
|
public java.lang.String | getAddress()Returns the "from" address associated with this message, e.g. address of
the sender. If the message is a newly created message, e.g. not a
received one, then the first "to" address is returned.
Returns null if the "from" or "to" address for the
message, dependent on the case, are not set.
Note: This design allows sending responses to a received message easily
by reusing the same Message object and just replacing the
payload. The address field can normally be kept untouched (unless the
used messaging protocol requires some special handling of the address).
String returnMe = null;
Date tStamp = getTimestamp();
if (tStamp == null || tStamp.getTime() == 0L) {
// not a received message - use the first "to" address
if (to.size() > 0) {
returnMe = (String)to.elementAt(0);
}
} else {
// received - use the "from" address
returnMe = super.getAddress();
}
return returnMe;
|
java.util.Vector | getAddressList(java.lang.String type)Gets the requested address list.
String lower = type.toLowerCase();
if (lower.equals("to")) {
return to;
} else if (lower.equals("cc")) {
return cc;
} else if (lower.equals("bcc")) {
return bcc;
}
throw new IllegalArgumentException(
"Address type is not 'to', 'cc', or 'bcc'");
|
public java.lang.String[] | getAddresses(java.lang.String type)Gets the addresses of the multipart message of the specified type (e.g.
"to", "cc", "bcc" or "from") as String . The method is not
case sensitive.
if (type.toLowerCase().equals("from")) {
String address = super.getAddress();
if (address == null) {
return null;
}
return new String[] { address };
}
Vector which = getAddressList(type);
int num = which.size();
if (num == 0) {
return null;
}
String[] addresses = new String[num];
which.copyInto(addresses);
return addresses;
|
public java.lang.String | getApplicationID()Returns the destination application identifier.
return applicationID;
|
public byte[] | getAsByteArray()Gets the message object as a byte array.
ByteArrayOutputStream baos = new ByteArrayOutputStream();
DataOutputStream dos = new DataOutputStream(baos);
dos.writeUTF(STREAM_SIGNATURE);
dos.writeUTF("X-Mms-Message-Type");
dos.writeUTF("m-send-req");
dos.writeUTF("X-Mms-Transaction-ID");
dos.writeUTF(String.valueOf(System.currentTimeMillis()));
dos.writeUTF("X-Mms-Version");
dos.writeUTF("1.0");
for (int i = 0; i < ALLOWED_HEADER_FIELDS.length; ++i) {
String headerValue = headerValues[i];
if (headerValue != null) {
dos.writeUTF(ALLOWED_HEADER_FIELDS[i]);
dos.writeUTF(headerValue);
}
}
String fromAddress = super.getAddress();
if (fromAddress != null) {
dos.writeUTF("From");
dos.writeUTF(getDevicePortionOfAddress(fromAddress));
}
if (to.size() != 0) {
dos.writeUTF("To");
writeVector(dos, to, true);
}
if (cc.size() != 0) {
dos.writeUTF("Cc");
writeVector(dos, cc, true);
}
if (bcc.size() != 0) {
dos.writeUTF("Bcc");
writeVector(dos, bcc, true);
}
long date = 0L;
Date tStamp = getTimestamp();
if (tStamp != null && (date = tStamp.getTime()) != 0L) {
dos.writeUTF("Date");
dos.writeUTF(String.valueOf(date));
}
if (subject != null) {
dos.writeUTF("Subject");
dos.writeUTF(subject);
}
dos.writeUTF("Content-Type");
Vector contentTypeElements = new Vector();
if (startContentID != null) {
contentTypeElements.addElement(
"application/vnd.wap.multipart.related");
} else {
contentTypeElements.addElement(
"application/vnd.wap.multipart.mixed");
}
if (startContentID != null) {
contentTypeElements.addElement("start = <" + startContentID + ">");
contentTypeElements.addElement("type = " +
getMessagePart(startContentID).getMIMEType());
}
if (applicationID != null) {
contentTypeElements.addElement("Application-ID = " + applicationID);
}
if (replyToApplicationID != null) {
contentTypeElements.addElement("Reply-To-Application-ID = " +
replyToApplicationID);
}
writeVector(dos, contentTypeElements, false);
dos.writeUTF("nEntries");
int numParts = parts.size();
dos.writeUTF(String.valueOf(numParts));
for (int i = 0; i < numParts; ++i) {
MessagePart p = (MessagePart)parts.elementAt(i);
writeMessagePart(dos, p);
}
dos.close();
byte[] returnMe = baos.toByteArray();
baos.close();
return returnMe;
|
public byte[] | getBodyAsByteArray()Gets the message object body as a byte array. The body is composed of a
single header that states the number of entries, followed by a serialized
array of MessagePart objects.
ByteArrayOutputStream baos = new ByteArrayOutputStream();
DataOutputStream dos = new DataOutputStream(baos);
dos.writeUTF("nEntries");
int numParts = parts.size();
dos.writeUTF(String.valueOf(numParts));
for (int i = 0; i < numParts; ++i) {
MessagePart p = (MessagePart)parts.elementAt(i);
writeMessagePart(dos, p);
}
dos.close();
byte[] returnMe = baos.toByteArray();
baos.close();
return returnMe;
|
static java.lang.String | getDevicePortionOfAddress(java.lang.String address)Returns only the device part of the MMS Address.
MMSAddress parsedAddress = MMSAddress.getParsedMMSAddress(address);
if (parsedAddress == null || parsedAddress.address == null) {
throw new IllegalArgumentException("MMS Address "
+"has no device portion");
}
return parsedAddress.address;
|
public java.lang.String | getHeader(java.lang.String headerField)Gets the content of the specific header field of the multipart message.
if (headerField == null) {
throw new IllegalArgumentException(
"headerField must not be null");
}
if (isAllowedToAccessHeaderField(headerField)) {
int index = getHeaderFieldIndex(headerField);
if (index != -1) {
return headerValues[index];
}
throw new Error("Allowed to access field but it has no index");
}
if (isKnownHeaderField(headerField)) {
throw new SecurityException(
"Cannot access restricted header field: " + headerField);
} else {
throw new IllegalArgumentException("Unknown header field: " +
headerField);
}
|
public byte[] | getHeaderAsByteArray()Gets the message object header as a byte array. The header is composed of
a number of fields and is exclusive of the MessagePart
contents.
ByteArrayOutputStream baos = new ByteArrayOutputStream();
DataOutputStream dos = new DataOutputStream(baos);
dos.writeUTF(STREAM_SIGNATURE);
// Write headers that
dos.writeUTF("X-Mms-Message-Type");
dos.writeUTF("m-send-req");
dos.writeUTF("X-Mms-Transaction-ID");
dos.writeUTF(String.valueOf(System.currentTimeMillis()));
dos.writeUTF("X-Mms-Version");
dos.writeUTF("1.0");
for (int i = 0; i < ALLOWED_HEADER_FIELDS.length; ++i) {
String headerValue = headerValues[i];
if (headerValue != null) {
dos.writeUTF(ALLOWED_HEADER_FIELDS[i]);
dos.writeUTF(headerValue);
}
}
String fromAddress = super.getAddress();
if (fromAddress != null) {
dos.writeUTF("From");
dos.writeUTF(getDevicePortionOfAddress(fromAddress));
}
if (to.size() != 0) {
dos.writeUTF("To");
writeVector(dos, to, true);
}
if (cc.size() != 0) {
dos.writeUTF("Cc");
writeVector(dos, cc, true);
}
if (bcc.size() != 0) {
dos.writeUTF("Bcc");
writeVector(dos, bcc, true);
}
long date = 0L;
Date tStamp = getTimestamp();
if (tStamp != null && (date = tStamp.getTime()) != 0L) {
dos.writeUTF("Date");
dos.writeUTF(String.valueOf(date));
}
if (subject != null) {
dos.writeUTF("Subject");
dos.writeUTF(subject);
}
dos.writeUTF("Content-Type");
Vector contentTypeElements = new Vector();
if (startContentID != null) {
contentTypeElements.addElement(
"application/vnd.wap.multipart.related");
} else {
contentTypeElements.addElement(
"application/vnd.wap.multipart.mixed");
}
if (startContentID != null) {
contentTypeElements.addElement("start = <" + startContentID + ">");
contentTypeElements.addElement("type = " +
getMessagePart(startContentID).getMIMEType());
}
if (applicationID != null) {
contentTypeElements.addElement("Application-ID = " + applicationID);
}
if (replyToApplicationID != null) {
contentTypeElements.addElement("Reply-To-Application-ID = " +
replyToApplicationID);
}
writeVector(dos, contentTypeElements, false);
dos.close();
byte[] returnMe = baos.toByteArray();
baos.close();
return returnMe;
|
static int | getHeaderFieldIndex(java.lang.String headerField)Gets the location of the requested header from the
list of allowed header fields.
String lowerFieldName = headerField.toLowerCase();
for (int i = 0; i < ALLOWED_HEADER_FIELDS.length; ++i) {
if (lowerFieldName.equals(ALLOWED_HEADER_FIELDS[i].toLowerCase())) {
return i;
}
}
return -1;
|
public com.sun.tck.wma.MessagePart | getMessagePart(java.lang.String contentID)This method returns a MessagePart from the message that
matches the content-id passed as a parameter.
if (contentID == null) {
throw new NullPointerException("contentID must not be null");
}
int numParts = parts.size();
for (int i = 0; i < numParts; ++i) {
MessagePart onePart = (MessagePart)parts.elementAt(i);
if (contentID.equals(onePart.getContentID())) {
return onePart;
}
}
return null;
|
public com.sun.tck.wma.MessagePart[] | getMessageParts()Returns an array of all MessagePart s of this message.
int num = parts.size();
if (num == 0) {
return null;
}
MessagePart[] msgParts = new MessagePart[num];
parts.copyInto(msgParts);
return msgParts;
|
java.lang.String | getReplyToApplicationID()Gets the "reply-to" application identifier.
return replyToApplicationID;
|
public java.lang.String | getStartContentId()Returns the contentId of the start MessagePart .
The start MessagePart is set in
setStartContentId(String)
return startContentID;
|
public java.lang.String | getSubject()Gets the subject of the multipart message.
return subject;
|
boolean | isAllowedToAccessHeaderField(java.lang.String field)Checks if allowed to access the requested header field.
return (getHeaderFieldIndex(field) != -1);
|
static boolean | isKnownHeaderField(java.lang.String headerField)Checks if header field is known.
String lowerFieldName = headerField.toLowerCase();
for (int i = 0; i < KNOWN_HEADER_FIELDS.length; ++i) {
if (lowerFieldName.equals(KNOWN_HEADER_FIELDS[i].toLowerCase())) {
return true;
}
}
return false;
|
static void | readVector(java.io.DataInputStream dis, java.util.Vector v, boolean isAddress)Reads a vector from an input stream. If the content is an MMS Address,
as indicated by the isAddress parameter, then the prefix
"mms://" is added to each address.
String inputStr = dis.readUTF();
int prevDelim = -2;
String prefix = "";
if (isAddress) {
prefix = "mms://";
}
while (prevDelim != -1) {
int nextDelim = inputStr.indexOf("; ", prevDelim + 2);
String addStr = null;
if (nextDelim == -1) {
addStr = prefix + inputStr.substring(prevDelim + 2);
} else {
addStr = prefix + inputStr.substring(prevDelim + 2, nextDelim);
}
v.addElement(addStr);
prevDelim = nextDelim;
}
|
public boolean | removeAddress(java.lang.String type, java.lang.String address)Removes an address from the multipart message.
Vector which = getAddressList(type);
boolean result = which.removeElement(address);
cleanupAppID();
return result;
|
public void | removeAddresses()Removes all addresses of types "to", "cc", "bcc" from the
multipart message.
to.removeAllElements();
cc.removeAllElements();
bcc.removeAllElements();
applicationID = null;
|
public void | removeAddresses(java.lang.String type)Removes all addresses of the specified type from the multipart message.
Vector which = getAddressList(type);
which.removeAllElements();
cleanupAppID();
|
public boolean | removeMessagePart(com.sun.tck.wma.MessagePart part)Removes a MessagePart from the multipart message.
if (part == null) {
throw new NullPointerException("part must not be null");
}
if (part.getContentID().equals(startContentID)) {
startContentID = null;
}
return parts.removeElement(part);
|
public boolean | removeMessagePartId(java.lang.String contentID)Removes a MessagePart with the specific
contentID from the multipart message.
if (contentID == null) {
throw new NullPointerException("contentID must not be null");
}
int numParts = parts.size();
for (int i = 0; i < numParts; ++i) {
MessagePart onePart = (MessagePart)parts.elementAt(i);
if (contentID.equals(onePart.getContentID())) {
if (contentID.equals(startContentID)) {
startContentID = null;
}
parts.removeElementAt(i);
return true;
}
}
return false;
|
public boolean | removeMessagePartLocation(java.lang.String contentLocation)Removes MessagePart s with the specific content location
from the multipart message. All MessagePart s with the
specified contentLocation are removed.
if (contentLocation == null) {
throw new NullPointerException("contentLocation must not be null");
}
int numParts = parts.size();
boolean found = false;
for (int i = 0; i < numParts; ++i) {
MessagePart onePart = (MessagePart)parts.elementAt(i);
if (contentLocation.equals(onePart.getContentLocation())) {
if (onePart.getContentID().equals(startContentID)) {
startContentID = null;
}
parts.removeElementAt(i);
--numParts;
--i;
found = true;
}
}
return found;
|
public void | setAddress(java.lang.String address)Sets the "to" address associated with this message. It works the same way
as addAddress("to", addr) . The address may be set to
null .
if (address != null) {
addAddress("to", address);
}
// otherwise it's a no-op.
|
public void | setFromAddress(java.lang.String fromAddress)Sets the "from" address.
super.setAddress(fromAddress);
|
public void | setHeader(java.lang.String headerField, java.lang.String headerValue)Sets the specified header of the multipart message. The header value can
be null .
if (isAllowedToAccessHeaderField(headerField)) {
int index = getHeaderFieldIndex(headerField);
if (index != -1) {
if (headerValue != null) {
checkHeaderValue(index, headerValue);
}
headerValues[index] = headerValue;
return;
}
throw new Error("Allowed to access field but it has no index");
}
if (isKnownHeaderField(headerField)) {
throw new SecurityException(
"Cannot access restricted header field: " + headerField);
} else {
throw new IllegalArgumentException("Unknown header field: " +
headerField);
}
|
public void | setReplyToApplicationID(java.lang.String appID)Sets the "reply-to" application identifier.
replyToApplicationID = appID;
|
public void | setStartContentId(java.lang.String contentId)Sets the Content-ID of the start MessagePart of
a multipart related message. The Content-ID may be set to
null . The StartContentId is set for the
MessagePart that is used to reference the other MessageParts of the
MultipartMessage for presentation or processing purposes.
if (contentId != null) {
if (getMessagePart(contentId) == null) {
throw new IllegalArgumentException("Unknown contentId: "
+ contentId);
}
}
startContentID = contentId;
|
public void | setSubject(java.lang.String subject)Sets the Subject of the multipart message. This value can be
null .
if (subject != null && subject.length() > 40) { // MMS Conformance limit
throw new IllegalArgumentException("Subject exceeds 40 chars");
}
this.subject = subject;
|
void | setupHeaderFields()Sets default values for all allowed header fields.
headerValues = new String[ALLOWED_HEADER_FIELDS.length];
for (int i = 0; i < DEFAULT_HEADER_VALUES.length; ++i) {
headerValues[i] = DEFAULT_HEADER_VALUES[i];
}
|
static void | writeMessagePart(java.io.DataOutputStream dos, com.sun.tck.wma.MessagePart p)Writes a message part to the output stream
dos.writeUTF("Content-Type");
StringBuffer contentType = new StringBuffer(p.getMIMEType());
String loc = p.getContentLocation();
if (loc != null) {
contentType.append("; name=\"");
contentType.append(loc);
contentType.append("\"");
}
dos.writeUTF(contentType.toString());
String id = p.getContentID();
if (id != null) {
dos.writeUTF("Content-ID");
dos.writeUTF(id);
}
String enc = p.getEncoding();
if (enc != null) {
dos.writeUTF("Encoding");
dos.writeUTF(enc);
}
// the payload
dos.writeUTF("Content-Length");
dos.writeInt(p.getLength());
dos.writeUTF("Content");
dos.write(p.getContent());
|
static void | writeVector(java.io.DataOutputStream dos, java.util.Vector v, boolean isAddress)Writes a vector to an output stream. If the contents are MMS addresses,
as indicated by the isAddress parameter, then
only the device
part of the address is placed into the vector, not the
application-id, if any.
StringBuffer buff = new StringBuffer();
int len = v.size();
String appendMe = null;
if (len > 0) {
appendMe = (String)v.elementAt(0);
if (isAddress) {
appendMe = getDevicePortionOfAddress(appendMe);
}
buff.append(appendMe);
}
for (int i = 1; i < len; ++i) {
buff.append("; ");
appendMe = (String)v.elementAt(i);
if (isAddress) {
appendMe = getDevicePortionOfAddress(appendMe);
}
buff.append(appendMe);
}
dos.writeUTF(buff.toString());
|