@Override public Date getSentDate() { if (mSentDate == null) { String dateHeaderBody = getFirstHeader("Date"); if (dateHeaderBody == null) { return null; } try { DateTimeField field = (DateTimeField) DefaultFieldParser.parse("Date: " + dateHeaderBody); mSentDate = field.getDate(); } catch (Exception e) { Timber.d(e, "Couldn't parse Date header field"); } } return mSentDate; }
private void processAddressList(ParsedField field, String addressListType, String metadataField) throws MimeException { AddressListField toField = (AddressListField) field; if (toField.isValidField()) { AddressList addressList = toField.getAddressList(); for (Address address : addressList) { metadata.add(metadataField, getDisplayString(address)); } } else { String to = stripOutFieldPrefix(field, addressListType); for (String eachTo : to.split(",")) { metadata.add(metadataField, eachTo.trim()); } } }
if (fieldname.equalsIgnoreCase("From")) { MailboxListField fromField = (MailboxListField) parsedField; MailboxList mailboxList = fromField.getMailboxList(); if (fromField.isValidField() && mailboxList != null) { for (Address address : mailboxList) { String from = getDisplayString(address); ((UnstructuredField) parsedField).getValue()); metadata.set(TikaCoreProperties.SUBJECT, ((UnstructuredField) parsedField).getValue()); } else if (fieldname.equalsIgnoreCase("To")) { processAddressList(parsedField, "To:", Metadata.MESSAGE_TO); processAddressList(parsedField, "Bcc:", Metadata.MESSAGE_BCC); } else if (fieldname.equalsIgnoreCase("Content-Type")) { final MediaType contentType = MediaType.parse(parsedField.getBody()); metadata.set(Message.MULTIPART_BOUNDARY, contentType.getParameters().get("boundary")); } else { metadata.add(Metadata.MESSAGE_RAW_HEADER_PREFIX + parsedField.getName(), field.getBody()); Date date = dateField.getDate(); if (date == null) { date = tryOtherDateFormats(field.getBody()); metadata.add(Metadata.MESSAGE_RAW_HEADER_PREFIX+parsedField.getName(), field.getBody());
private AddressList getAddressList(String fieldName) { AddressListField field = obtainField(fieldName); if (field == null) return null; return field.getAddressList(); }
/** * Returns the (decoded) value of the <i>Subject</i> header field of this * message or <code>null</code> if it is not present. * * @return the subject of this message. */ public String getSubject() { UnstructuredField field = obtainField(FieldName.SUBJECT); return field != null ? field.getValue() : null; }
private MailboxList getMailboxList(String fieldName) { MailboxListField field = obtainField(fieldName); if (field == null) return null; return field.getMailboxList(); }
public String getTransferEncoding() { ContentTransferEncodingField contentTransferEncodingField = (ContentTransferEncodingField) fields.get(CONTENT_TRANSFER_ENCODING); return contentTransferEncodingField != null ? contentTransferEncodingField.getEncoding() : MimeUtil.ENC_7BIT; }
/** * Gets the <code>size</code> parameter value of the <code>content-disposition</code> field. * See <a href='http://www.faqs.org/rfcs/rfc2183.html'>RFC2183</a>. * @return size parameter value, * or -1 if this size has not been set */ public long getContentDispositionSize() { ContentDispositionField contentDispositionField = (ContentDispositionField) fields.get(CONTENT_DISPOSITION); return contentDispositionField != null ? contentDispositionField.getSize() : -1; }
/** * Gets the <code>read-date</code> parameter value of the <code>content-disposition</code> field. * See <a href='http://www.faqs.org/rfcs/rfc2183.html'>RFC2183</a>. * @return read-date parameter value, * or null when this is not present */ public Date getContentDispositionReadDate() { ContentDispositionField contentDispositionField = (ContentDispositionField) fields.get(CONTENT_DISPOSITION); return contentDispositionField != null ? contentDispositionField.getReadDate() : null; }
/** * Gets the MIME major version * as specified by the <code>MIME-Version</code> * header. * Defaults to one. * @return positive integer */ public int getMimeMajorVersion() { MimeVersionField mimeVersionField = (MimeVersionField) fields.get(MIME_VERSION); return mimeVersionField != null ? mimeVersionField.getMajorVersion() : MimeVersionFieldImpl.DEFAULT_MAJOR_VERSION; }
/** * Gets the <code>creation-date</code> parameter value of the <code>content-disposition</code> field. * See <a href='http://www.faqs.org/rfcs/rfc2183.html'>RFC2183</a>. * @return creation-date parameter value, * or null when this is not present */ public Date getContentDispositionCreationDate() { ContentDispositionField contentDispositionField = (ContentDispositionField) fields.get(CONTENT_DISPOSITION); return contentDispositionField != null ? contentDispositionField.getCreationDate() : null; }
/** * Gets the <code>filename</code> parameter value of the <code>content-disposition</code> field. * See <a href='http://www.faqs.org/rfcs/rfc2183.html'>RFC2183</a>. * @return filename parameter value, * or null when it is not present */ public String getContentDispositionFilename() { ContentDispositionField contentDispositionField = (ContentDispositionField) fields.get(CONTENT_DISPOSITION); return contentDispositionField != null ? contentDispositionField.getFilename() : null; }
/** * Return disposition type of this message. * * @return the disposition type or <code>null</code> if no disposition * type has been set. */ public String getDispositionType() { ContentDispositionField field = obtainField(FieldName.CONTENT_DISPOSITION); return field != null ? field.getDispositionType() : null; }
/** * Returns modification date of the content disposition of this message. * * @return the modification date parameter of the content disposition or * <code>null</code> if the filename has not been set. */ public Date getModificationDate() { ContentDispositionField field = obtainField(FieldName.CONTENT_DISPOSITION); return field != null ? field.getModificationDate() : null; }
private Mailbox getMailbox(String fieldName) { MailboxField field = obtainField(fieldName); if (field == null) return null; return field.getMailbox(); }
/** * Returns the value of the <i>Date</i> header field of this message as * <code>Date</code> object or <code>null</code> if it is not present. * * @return the date of this message. */ public Date getDate() { DateTimeField field = obtainField(FieldName.DATE); return field != null ? field.getDate() : null; }
/** * Returns transfer encoding of this message. * * @return the transfer encoding. */ public String getContentTransferEncoding() { ContentTransferEncodingField field = obtainField(FieldName.CONTENT_TRANSFER_ENCODING); return field != null ? field.getEncoding() : null; }
/** * Returns size of the content disposition of this message. * * @return the size parameter of the content disposition or * <code>-1</code> if the filename has not been set. */ public long getSize() { ContentDispositionField field = obtainField(FieldName.CONTENT_DISPOSITION); return field != null ? field.getSize() : -1; }
/** * Returns read date of the content disposition of this message. * * @return the read date parameter of the content disposition or * <code>null</code> if the filename has not been set. */ public Date getReadDate() { ContentDispositionField field = obtainField(FieldName.CONTENT_DISPOSITION); return field != null ? field.getReadDate() : null; }
/** * Returns the value of the <i>Date</i> header field of this message as * <code>Date</code> object or <code>null</code> if it is not present. * * @return the date of this message. */ public Date getDate() { DateTimeField dateField = obtainField(FieldName.DATE); if (dateField == null) return null; return dateField.getDate(); }