Methods Summary |
---|
public void | addHeader(java.lang.String name, java.lang.String value)
mHeader.addHeader(name, value);
|
private java.lang.String | generateMessageId()
StringBuffer sb = new StringBuffer();
sb.append("<");
for (int i = 0; i < 24; i++) {
sb.append(Integer.toString((int)(Math.random() * 35), 36));
}
sb.append(".");
sb.append(Long.toString(System.currentTimeMillis()));
sb.append("@email.android.com>");
return sb.toString();
|
public com.android.email.mail.Body | getBody()
return mBody;
|
public java.lang.String | getContentId()
String contentId = getFirstHeader(MimeHeader.HEADER_CONTENT_ID);
if (contentId == null) {
return null;
} else {
// remove optionally surrounding brackets.
return REMOVE_OPTIONAL_BRACKETS.matcher(contentId).replaceAll("$1");
}
|
public java.lang.String | getContentType()
String contentType = getFirstHeader(MimeHeader.HEADER_CONTENT_TYPE);
if (contentType == null) {
return "text/plain";
} else {
return contentType;
}
|
public java.lang.String | getDisposition()
String contentDisposition = getFirstHeader(MimeHeader.HEADER_CONTENT_DISPOSITION);
if (contentDisposition == null) {
return null;
} else {
return contentDisposition;
}
|
protected java.lang.String | getFirstHeader(java.lang.String name)
return mHeader.getFirstHeader(name);
|
public com.android.email.mail.Address[] | getFrom()
if (mFrom == null) {
String list = MimeUtility.unfold(getFirstHeader("From"));
if (list == null || list.length() == 0) {
list = MimeUtility.unfold(getFirstHeader("Sender"));
}
mFrom = Address.parse(list);
}
return mFrom;
|
public java.lang.String[] | getHeader(java.lang.String name)
return mHeader.getHeader(name);
|
public java.io.InputStream | getInputStream()
return null;
|
public java.lang.String | getMessageId()Get the mime "Message-ID" header. Note, this field is preset (randomly) in every new
message, so it should never return null.
String[] headers = getHeader("Message-ID");
if (headers != null) {
// There should really only be one Message-ID here
return headers[0];
}
throw new MessagingException("A message was found without a Message-ID header");
|
public java.lang.String | getMimeType()
return MimeUtility.getHeaderParameter(getContentType(), null);
|
public java.util.Date | getReceivedDate()
return null;
|
public com.android.email.mail.Address[] | getRecipients(RecipientType type)Returns a list of the given recipient type from this message. If no addresses are
found the method returns an empty array.
if (type == RecipientType.TO) {
if (mTo == null) {
mTo = Address.parse(MimeUtility.unfold(getFirstHeader("To")));
}
return mTo;
} else if (type == RecipientType.CC) {
if (mCc == null) {
mCc = Address.parse(MimeUtility.unfold(getFirstHeader("CC")));
}
return mCc;
} else if (type == RecipientType.BCC) {
if (mBcc == null) {
mBcc = Address.parse(MimeUtility.unfold(getFirstHeader("BCC")));
}
return mBcc;
} else {
throw new MessagingException("Unrecognized recipient type.");
}
|
public com.android.email.mail.Address[] | getReplyTo()
if (mReplyTo == null) {
mReplyTo = Address.parse(MimeUtility.unfold(getFirstHeader("Reply-to")));
}
return mReplyTo;
|
public java.util.Date | getSentDate()
if (mSentDate == null) {
try {
DateTimeField field = (DateTimeField)Field.parse("Date: "
+ MimeUtility.unfoldAndDecode(getFirstHeader("Date")));
mSentDate = field.getDate();
} catch (Exception e) {
}
}
return mSentDate;
|
public int | getSize()
return mSize;
|
public java.lang.String | getSubject()Returns the unfolded, decoded value of the Subject header.
return MimeUtility.unfoldAndDecode(getFirstHeader("Subject"));
|
protected void | parse(java.io.InputStream in)
// Before parsing the input stream, clear all local fields that may be superceded by
// the new incoming message.
mHeader.clear();
mFrom = null;
mTo = null;
mCc = null;
mBcc = null;
mReplyTo = null;
mSentDate = null;
mBody = null;
MimeStreamParser parser = new MimeStreamParser();
parser.setContentHandler(new MimeMessageBuilder());
parser.parse(new EOLConvertingInputStream(in));
|
public void | removeHeader(java.lang.String name)
mHeader.removeHeader(name);
|
public void | saveChanges()
throw new MessagingException("saveChanges not yet implemented");
|
public void | setBody(com.android.email.mail.Body body)
this.mBody = body;
if (body instanceof com.android.email.mail.Multipart) {
com.android.email.mail.Multipart multipart = ((com.android.email.mail.Multipart)body);
multipart.setParent(this);
setHeader(MimeHeader.HEADER_CONTENT_TYPE, multipart.getContentType());
setHeader("MIME-Version", "1.0");
}
else if (body instanceof TextBody) {
setHeader(MimeHeader.HEADER_CONTENT_TYPE, String.format("%s;\n charset=utf-8",
getMimeType()));
setHeader(MimeHeader.HEADER_CONTENT_TRANSFER_ENCODING, "base64");
}
|
public void | setFrom(com.android.email.mail.Address from)
if (from != null) {
setHeader("From", from.toString());
this.mFrom = new Address[] {
from
};
} else {
this.mFrom = null;
}
|
public void | setHeader(java.lang.String name, java.lang.String value)
mHeader.setHeader(name, value);
|
public void | setMessageId(java.lang.String messageId)Set the mime "Message-ID" header
setHeader("Message-ID", messageId);
|
public void | setRecipients(RecipientType type, com.android.email.mail.Address[] addresses)
if (type == RecipientType.TO) {
if (addresses == null || addresses.length == 0) {
removeHeader("To");
this.mTo = null;
} else {
setHeader("To", Address.toString(addresses));
this.mTo = addresses;
}
} else if (type == RecipientType.CC) {
if (addresses == null || addresses.length == 0) {
removeHeader("CC");
this.mCc = null;
} else {
setHeader("CC", Address.toString(addresses));
this.mCc = addresses;
}
} else if (type == RecipientType.BCC) {
if (addresses == null || addresses.length == 0) {
removeHeader("BCC");
this.mBcc = null;
} else {
setHeader("BCC", Address.toString(addresses));
this.mBcc = addresses;
}
} else {
throw new MessagingException("Unrecognized recipient type.");
}
|
public void | setReplyTo(com.android.email.mail.Address[] replyTo)
if (replyTo == null || replyTo.length == 0) {
removeHeader("Reply-to");
mReplyTo = null;
} else {
setHeader("Reply-to", Address.toString(replyTo));
mReplyTo = replyTo;
}
|
public void | setSentDate(java.util.Date sentDate)
setHeader("Date", mDateFormat.format(sentDate));
this.mSentDate = sentDate;
|
public void | setSubject(java.lang.String subject)
final int HEADER_NAME_LENGTH = 9; // "Subject: "
setHeader("Subject", MimeUtility.foldAndEncode2(subject, HEADER_NAME_LENGTH));
|
public void | writeTo(java.io.OutputStream out)
BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(out), 1024);
mHeader.writeTo(out);
writer.write("\r\n");
writer.flush();
if (mBody != null) {
mBody.writeTo(out);
}
|