当前位置: 首页>>代码示例>>Java>>正文


Java MimeUtil.ENC_7BIT属性代码示例

本文整理汇总了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;
}
 
开发者ID:philipwhiuk,项目名称:q-mail,代码行数:8,代码来源:LocalFolder.java

示例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);
}
 
开发者ID:philipwhiuk,项目名称:q-mail,代码行数:32,代码来源:ReconstructMessageFromDatabaseTest.java

示例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>*&#47;*: 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);
    }
}
 
开发者ID:philipwhiuk,项目名称:q-mail,代码行数:30,代码来源:MimeUtility.java

示例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>*&#47;*: 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);
    }
}
 
开发者ID:daxslab,项目名称:daxSmail,代码行数:30,代码来源:MimeUtility.java

示例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;
}
 
开发者ID:appcelerator-archive,项目名称:ti.box,代码行数:13,代码来源:ContentTransferEncodingField.java

示例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>*&#47;*: 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);
    }
}
 
开发者ID:thialfihar,项目名称:k-9,代码行数:30,代码来源:MimeUtility.java


注:本文中的org.apache.james.mime4j.util.MimeUtil.ENC_7BIT属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。