本文整理了Java中com.fsck.k9.mail.Message.getHeader()
方法的一些代码示例,展示了Message.getHeader()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Message.getHeader()
方法的具体详情如下:
包路径:com.fsck.k9.mail.Message
类名称:Message
方法名:getHeader
暂无
代码示例来源:origin: k9mail/k-9
private String extractMessageId(Message message) {
String[] messageIdHeader = message.getHeader("Message-ID");
return messageIdHeader.length == 0 ? null : messageIdHeader[0];
}
代码示例来源:origin: k9mail/k-9
private List<HeaderEntry> getAdditionalHeaders(final Message message) {
List<HeaderEntry> additionalHeaders = new LinkedList<>();
Set<String> headerNames = new LinkedHashSet<>(message.getHeaderNames());
for (String headerName : headerNames) {
String[] headerValues = message.getHeader(headerName);
for (String headerValue : headerValues) {
additionalHeaders.add(new HeaderEntry(headerName, headerValue));
}
}
return additionalHeaders;
}
代码示例来源:origin: k9mail/k-9
public boolean hasAutocryptHeader(Message currentMessage) {
return currentMessage.getHeader(AutocryptHeader.AUTOCRYPT_HEADER).length > 0;
}
代码示例来源:origin: k9mail/k-9
private static String getJisVariantFromMailerHeaders(Message message) {
String[] mailerHeaders = message.getHeader("X-Mailer");
if (mailerHeaders.length == 0) {
return null;
}
if (mailerHeaders[0].startsWith("iPhone Mail ") || mailerHeaders[0].startsWith("iPad Mail ")) {
return "iphone";
}
return null;
}
代码示例来源:origin: k9mail/k-9
@Nullable
AutocryptHeader getValidAutocryptHeader(Message currentMessage) {
String[] headers = currentMessage.getHeader(AutocryptHeader.AUTOCRYPT_HEADER);
ArrayList<AutocryptHeader> autocryptHeaders = parseAllAutocryptHeaders(headers);
boolean isSingleValidHeader = autocryptHeaders.size() == 1;
return isSingleValidHeader ? autocryptHeaders.get(0) : null;
}
代码示例来源:origin: k9mail/k-9
public static Address[] getListPostAddresses(Message message) {
String[] headerValues = message.getHeader(LIST_POST_HEADER);
if (headerValues.length < 1) {
return new Address[0];
}
List<Address> listPostAddresses = new ArrayList<>();
for (String headerValue : headerValues) {
Address address = extractAddress(headerValue);
if (address != null) {
listPostAddresses.add(address);
}
}
return listPostAddresses.toArray(new Address[listPostAddresses.size()]);
}
代码示例来源:origin: k9mail/k-9
public void initFromDraftMessage(Message message) {
initRecipientsFromDraftMessage(message);
String[] draftStateHeader = message.getHeader(AutocryptDraftStateHeader.AUTOCRYPT_DRAFT_STATE_HEADER);
if (draftStateHeader.length == 1) {
initEncryptionStateFromDraftStateHeader(draftStateHeader[0]);
} else {
initPgpInlineFromDraftMessage(message);
}
}
代码示例来源:origin: k9mail/k-9
String[] referencesArray = message.getHeader("References");
List<String> messageIds = null;
if (referencesArray.length > 0) {
String[] inReplyToArray = message.getHeader("In-Reply-To");
String inReplyTo;
if (inReplyToArray.length > 0) {
代码示例来源:origin: k9mail/k-9
@Test
public void getRecipientsToReplyTo_should_prefer_from_ifOtherIsIdentity() throws Exception {
when(message.getReplyTo()).thenReturn(REPLY_TO_ADDRESSES);
when(message.getHeader(ListHeaders.LIST_POST_HEADER)).thenReturn(LIST_POST_HEADER_VALUES);
when(message.getFrom()).thenReturn(FROM_ADDRESSES);
when(message.getRecipients(RecipientType.TO)).thenReturn(TO_ADDRESSES);
when(account.isAnIdentity(any(Address[].class))).thenReturn(true);
ReplyToAddresses result = replyToParser.getRecipientsToReplyTo(message, account);
assertArrayEquals(TO_ADDRESSES, result.to);
assertArrayEquals(EMPTY_ADDRESSES, result.cc);
}
代码示例来源:origin: k9mail/k-9
@Test
public void getRecipientsToReplyAllTo_should_returnFromAndToAndCcRecipients() throws Exception {
when(message.getReplyTo()).thenReturn(EMPTY_ADDRESSES);
when(message.getHeader(ListHeaders.LIST_POST_HEADER)).thenReturn(new String[0]);
when(message.getFrom()).thenReturn(FROM_ADDRESSES);
when(message.getRecipients(RecipientType.TO)).thenReturn(TO_ADDRESSES);
when(message.getRecipients(RecipientType.CC)).thenReturn(CC_ADDRESSES);
ReplyToAddresses recipientsToReplyAllTo = replyToParser.getRecipientsToReplyAllTo(message, account);
assertArrayEquals(arrayConcatenate(FROM_ADDRESSES, TO_ADDRESSES, Address.class), recipientsToReplyAllTo.to);
assertArrayEquals(CC_ADDRESSES, recipientsToReplyAllTo.cc);
}
代码示例来源:origin: k9mail/k-9
@Test
public void getRecipientsToReplyTo_should_return_from_otherwise() throws Exception {
when(message.getReplyTo()).thenReturn(EMPTY_ADDRESSES);
when(message.getHeader(ListHeaders.LIST_POST_HEADER)).thenReturn(new String[0]);
when(message.getFrom()).thenReturn(FROM_ADDRESSES);
ReplyToAddresses result = replyToParser.getRecipientsToReplyTo(message, account);
assertArrayEquals(FROM_ADDRESSES, result.to);
assertArrayEquals(EMPTY_ADDRESSES, result.cc);
verify(account).isAnIdentity(result.to);
}
代码示例来源:origin: k9mail/k-9
@Test
public void getRecipientsToReplyTo_should_prefer_replyTo_over_any_other_field() throws Exception {
when(message.getReplyTo()).thenReturn(REPLY_TO_ADDRESSES);
when(message.getHeader(ListHeaders.LIST_POST_HEADER)).thenReturn(LIST_POST_HEADER_VALUES);
when(message.getFrom()).thenReturn(FROM_ADDRESSES);
ReplyToAddresses result = replyToParser.getRecipientsToReplyTo(message, account);
assertArrayEquals(REPLY_TO_ADDRESSES, result.to);
assertArrayEquals(EMPTY_ADDRESSES, result.cc);
verify(account).isAnIdentity(result.to);
}
代码示例来源:origin: k9mail/k-9
@Test
public void getRecipientsToReplyTo_should_prefer_listPost_over_from_field() throws Exception {
when(message.getReplyTo()).thenReturn(EMPTY_ADDRESSES);
when(message.getHeader(ListHeaders.LIST_POST_HEADER)).thenReturn(LIST_POST_HEADER_VALUES);
when(message.getFrom()).thenReturn(FROM_ADDRESSES);
ReplyToAddresses result = replyToParser.getRecipientsToReplyTo(message, account);
assertArrayEquals(LIST_POST_ADDRESSES, result.to);
assertArrayEquals(EMPTY_ADDRESSES, result.cc);
verify(account).isAnIdentity(result.to);
}
代码示例来源:origin: k9mail/k-9
@Test
public void getRecipientsToReplyAllTo_should_excludeIdentityAddresses() throws Exception {
when(message.getReplyTo()).thenReturn(EMPTY_ADDRESSES);
when(message.getHeader(ListHeaders.LIST_POST_HEADER)).thenReturn(new String[0]);
when(message.getFrom()).thenReturn(EMPTY_ADDRESSES);
when(message.getRecipients(RecipientType.TO)).thenReturn(TO_ADDRESSES);
when(message.getRecipients(RecipientType.CC)).thenReturn(CC_ADDRESSES);
Address excludedCcAddress = CC_ADDRESSES[1];
Address excludedToAddress = TO_ADDRESSES[0];
when(account.isAnIdentity(eq(excludedToAddress))).thenReturn(true);
when(account.isAnIdentity(eq(excludedCcAddress))).thenReturn(true);
ReplyToAddresses recipientsToReplyAllTo = replyToParser.getRecipientsToReplyAllTo(message, account);
assertArrayEquals(arrayExcept(TO_ADDRESSES, excludedToAddress), recipientsToReplyAllTo.to);
assertArrayEquals(arrayExcept(CC_ADDRESSES, excludedCcAddress), recipientsToReplyAllTo.cc);
}
代码示例来源:origin: k9mail/k-9
@Test
public void getRecipientsToReplyAllTo_should_excludeDuplicates() throws Exception {
when(message.getReplyTo()).thenReturn(REPLY_TO_ADDRESSES);
when(message.getFrom()).thenReturn(arrayConcatenate(FROM_ADDRESSES, REPLY_TO_ADDRESSES, Address.class));
when(message.getRecipients(RecipientType.TO)).thenReturn(arrayConcatenate(FROM_ADDRESSES, TO_ADDRESSES, Address.class));
when(message.getRecipients(RecipientType.CC)).thenReturn(arrayConcatenate(CC_ADDRESSES, TO_ADDRESSES, Address.class));
when(message.getHeader(ListHeaders.LIST_POST_HEADER)).thenReturn(new String[0]);
ReplyToAddresses recipientsToReplyAllTo = replyToParser.getRecipientsToReplyAllTo(message, account);
assertArrayContainsAll(REPLY_TO_ADDRESSES, recipientsToReplyAllTo.to);
assertArrayContainsAll(FROM_ADDRESSES, recipientsToReplyAllTo.to);
assertArrayContainsAll(TO_ADDRESSES, recipientsToReplyAllTo.to);
int totalExpectedAddresses = REPLY_TO_ADDRESSES.length + FROM_ADDRESSES.length + TO_ADDRESSES.length;
assertEquals(totalExpectedAddresses, recipientsToReplyAllTo.to.length);
assertArrayEquals(CC_ADDRESSES, recipientsToReplyAllTo.cc);
}
代码示例来源:origin: k9mail/k-9
final String[] inReplyTo = message.getHeader("In-Reply-To");
if (inReplyTo.length >= 1) {
repliedToMessageId = inReplyTo[0];
final String[] references = message.getHeader("References");
if (references.length >= 1) {
referencedMessageIds = references[0];
String[] identityHeaders = message.getHeader(K9.IDENTITY_HEADER);
if (identityHeaders.length == 0) {
identityHeaders = messageViewInfo.rootPart.getHeader(K9.IDENTITY_HEADER);
代码示例来源:origin: jberkel/sms-backup-plus
public static @Nullable String get(Message msg, String header) {
final String[] headers = msg.getHeader(header);
if (headers.length > 0) {
return headers[0];
} else {
return null;
}
}
}
代码示例来源:origin: jberkel/sms-backup-plus
@Test public void shouldAddMessageWithValidDate() throws Exception {
ConversionResult result = new ConversionResult(DataType.SMS);
Message message = mock(Message.class);
when(message.getHeader(Headers.DATE)).thenReturn(new String[] { "12345" });
Map<String, String> map = new HashMap<String, String>();
result.add(message, map);
assertThat(result.isEmpty()).isFalse();
assertThat(result.getMaxDate()).isEqualTo(12345);
}
代码示例来源:origin: jberkel/sms-backup-plus
@Test public void shouldAddMessageWithInvalidDate() throws Exception {
ConversionResult result = new ConversionResult(DataType.SMS);
Message message = mock(Message.class);
when(message.getHeader(Headers.DATE)).thenReturn(new String[] { "foo" });
Map<String, String> map = new HashMap<String, String>();
result.add(message, map);
assertThat(result.isEmpty()).isFalse();
assertThat(result.getMaxDate()).isEqualTo(-1);
}
代码示例来源:origin: jberkel/sms-backup-plus
@Test public void testShouldGenerateMMSMessageWithCorrectEncoding() throws Exception {
PersonRecord personRecord = new PersonRecord(1, "Foo Bar", "foo@bar.com", "1234");
MmsSupport.MmsDetails details = new MmsSupport.MmsDetails(true, "foo",
personRecord,
new Address("foo@bar.com"));
when(mmsSupport.getDetails(any(Uri.class), any(AddressStyle.class))).thenReturn(details);
Message msg = generator.messageForDataType(mockMessage("1234", personRecord), DataType.MMS);
assertThat(msg.getHeader(MimeHeader.HEADER_CONTENT_TRANSFER_ENCODING)).isEqualTo(new String[] {
MimeUtil.ENC_7BIT
});
}
内容来源于网络,如有侵权,请联系作者删除!