本文整理汇总了Java中org.apache.james.mime4j.util.MimeUtil.ENC_7BIT属性的典型用法代码示例。如果您正苦于以下问题:Java MimeUtil.ENC_7BIT属性的具体用法?Java MimeUtil.ENC_7BIT怎么用?Java MimeUtil.ENC_7BIT使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.apache.james.mime4j.util.MimeUtil
的用法示例。
在下文中一共展示了MimeUtil.ENC_7BIT属性的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getTransferEncoding
private String getTransferEncoding(Part part) {
String[] contentTransferEncoding = part.getHeader(MimeHeader.HEADER_CONTENT_TRANSFER_ENCODING);
if (contentTransferEncoding.length > 0) {
return contentTransferEncoding[0].toLowerCase(Locale.US);
}
return MimeUtil.ENC_7BIT;
}
示例2: testAddMissingPart
public void testAddMissingPart() throws MessagingException, IOException {
LocalFolder folder = createFolderInDatabase();
MimeMessage message = new MimeMessage();
message.addHeader("To", "[email protected]");
message.addHeader("MIME-Version", "1.0");
message.addHeader("Content-Type", "text/plain");
message.setServerExtra("text");
saveMessageToDatabase(folder, message);
LocalMessage localMessage = readMessageFromDatabase(folder, message);
assertEquals("[email protected]", localMessage.getHeader("To")[0]);
assertEquals("text/plain", localMessage.getHeader(MimeHeader.HEADER_CONTENT_TYPE)[0]);
assertEquals("text", localMessage.getServerExtra());
assertNull(localMessage.getBody());
Body body = new BinaryMemoryBody("Test message body".getBytes(), MimeUtil.ENC_7BIT);
localMessage.setBody(body);
folder.addPartToMessage(localMessage, localMessage);
LocalMessage completeLocalMessage = readMessageFromDatabase(folder, message);
String reconstructedMessage = writeMessageToString(completeLocalMessage);
assertEquals("To: [email protected]\r\n" +
"MIME-Version: 1.0\r\n" +
"Content-Type: text/plain\r\n" +
"\r\n" +
"Test message body",
reconstructedMessage);
}
示例3: getEncodingforType
/**
* Get a default content-transfer-encoding for use with a given content-type
* when adding an unencoded attachment. It's possible that 8bit encodings
* may later be converted to 7bit for 7bit transport.
* <ul>
* <li>null: base64
* <li>message/rfc822: 8bit
* <li>message/*: 7bit
* <li>multipart/signed: 7bit
* <li>multipart/*: 8bit
* <li>*/*: base64
* </ul>
*
* @param type
* A String representing a MIME content-type
* @return A String representing a MIME content-transfer-encoding
*/
public static String getEncodingforType(String type) {
if (type == null) {
return (MimeUtil.ENC_BASE64);
} else if (MimeUtil.isMessage(type)) {
return (MimeUtil.ENC_8BIT);
} else if (isSameMimeType(type, "multipart/signed") || isMessage(type)) {
return (MimeUtil.ENC_7BIT);
} else if (isMultipart(type)) {
return (MimeUtil.ENC_8BIT);
} else {
return (MimeUtil.ENC_BASE64);
}
}
示例4: getEncodingforType
/**
* Get a default content-transfer-encoding for use with a given content-type
* when adding an unencoded attachment. It's possible that 8bit encodings
* may later be converted to 7bit for 7bit transport.
* <ul>
* <li>null: base64
* <li>message/rfc822: 8bit
* <li>message/*: 7bit
* <li>multipart/signed: 7bit
* <li>multipart/*: 8bit
* <li>*/*: base64
* </ul>
*
* @param type
* A String representing a MIME content-type
* @return A String representing a MIME content-transfer-encoding
*/
public static String getEncodingforType(String type) {
if (type == null) {
return (MimeUtil.ENC_BASE64);
} else if (MimeUtil.isMessage(type)) {
return (MimeUtil.ENC_8BIT);
} else if ("multipart/signed".equalsIgnoreCase(type) || type.toLowerCase(Locale.US).startsWith("message/")) {
return (MimeUtil.ENC_7BIT);
} else if (type.toLowerCase(Locale.US).startsWith("multipart/")) {
return (MimeUtil.ENC_8BIT);
} else {
return (MimeUtil.ENC_BASE64);
}
}
示例5: getEncoding
/**
* Gets the encoding of the given field if. Returns the default
* <code>7bit</code> if not set or if
* <code>f</code> is <code>null</code>.
*
* @return the encoding.
*/
public static String getEncoding(ContentTransferEncodingField f) {
if (f != null && f.getEncoding().length() != 0) {
return f.getEncoding();
}
return MimeUtil.ENC_7BIT;
}
示例6: getEncodingforType
/**
* Get a default content-transfer-encoding for use with a given content-type
* when adding an unencoded attachment. It's possible that 8bit encodings
* may later be converted to 7bit for 7bit transport.
* <ul>
* <li>null: base64
* <li>message/rfc822: 8bit
* <li>message/*: 7bit
* <li>multipart/signed: 7bit
* <li>multipart/*: 8bit
* <li>*/*: base64
* </ul>
*
* @param type
* A String representing a MIME content-type
* @return A String representing a MIME content-transfer-encoding
*/
public static String getEncodingforType(String type) {
if (type == null) {
return (MimeUtil.ENC_BASE64);
} else if (MimeUtil.isMessage(type)) {
return (MimeUtil.ENC_8BIT);
} else if (type.contains("application/pgp-signature") || type.contains("application/pgp-encrypted") || type.toLowerCase(Locale.US).startsWith("message/")) {
return (MimeUtil.ENC_7BIT);
} else if (type.toLowerCase(Locale.US).startsWith("multipart/")) {
return (MimeUtil.ENC_8BIT);
} else {
return (MimeUtil.ENC_BASE64);
}
}