示例#1
0
 @Override
 public 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;
 }
示例#2
0
 @Override
 public Address[] getReplyTo() {
   if (mReplyTo == null) {
     mReplyTo = Address.parse(MimeUtility.unfold(getFirstHeader("Reply-to")));
   }
   return mReplyTo;
 }
示例#3
0
 public void body(BodyDescriptor bd, InputStream in) throws IOException {
   expect(Part.class);
   Body body = MimeUtility.decodeBody(in, bd.getTransferEncoding());
   try {
     ((Part) stack.peek()).setBody(body);
   } catch (MessagingException me) {
     throw new Error(me);
   }
 }
示例#4
0
 @Override
 public void setCharset(String charset) throws MessagingException {
   if (mBody instanceof Multipart) {
     ((Multipart) mBody).setCharset(charset);
   } else if (mBody instanceof TextBody) {
     MimeUtility.setCharset(charset, this);
     ((TextBody) mBody).setCharset(charset);
   }
 }
示例#5
0
 /**
  * Returns a list of the given recipient type from this message. If no addresses are found the
  * method returns an empty array.
  */
 @Override
 public Address[] getRecipients(RecipientType type) throws MessagingException {
   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.");
   }
 }
示例#6
0
  @Override
  public Date getSentDate() {
    if (mSentDate == null) {
      try {
        DateTimeField field =
            (DateTimeField)
                DefaultFieldParser.parse(
                    "Date: " + MimeUtility.unfoldAndDecode(getFirstHeader("Date")));
        mSentDate = field.getDate();
      } catch (Exception e) {

      }
    }
    return mSentDate;
  }
示例#7
0
 /** Returns the unfolded, decoded value of the Subject header. */
 @Override
 public String getSubject() {
   return MimeUtility.unfoldAndDecode(getFirstHeader("Subject"), this);
 }
示例#8
0
 public String getMimeType() throws MessagingException {
   return MimeUtility.getHeaderParameter(getContentType(), null);
 }