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


Java MimeUtility.fold方法代码示例

本文整理汇总了Java中javax.mail.internet.MimeUtility.fold方法的典型用法代码示例。如果您正苦于以下问题:Java MimeUtility.fold方法的具体用法?Java MimeUtility.fold怎么用?Java MimeUtility.fold使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.mail.internet.MimeUtility的用法示例。


在下文中一共展示了MimeUtility.fold方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: Header

import javax.mail.internet.MimeUtility; //导入方法依赖的package包/类
public Header(String name, String value) {
    this.name = name;

    try {
        this.value = MimeUtility.fold(name.length() + 2, MimeUtility.encodeText(value));
    }
    catch (UnsupportedEncodingException e) {
        throw new RuntimeException("Unable to create header", e);
    }
}
 
开发者ID:codylerum,项目名称:simple-email,代码行数:11,代码来源:Header.java

示例2: getArticleHeaders

import javax.mail.internet.MimeUtility; //导入方法依赖的package包/类
private String getArticleHeaders(long articleID)
        throws StorageBackendException {
    ResultSet rs = null;

    try {
        this.pstmtGetArticleHeaders0.setLong(1, articleID);
        rs = this.pstmtGetArticleHeaders0.executeQuery();

        StringBuilder buf = new StringBuilder();
        if (rs.next()) {
            for (;;) {
                buf.append(rs.getString(1)); // key
                buf.append(": ");
                String foldedValue = MimeUtility.fold(0, rs.getString(2));
                buf.append(foldedValue); // value
                if (rs.next()) {
                    buf.append("\r\n");
                } else {
                    break;
                }
            }
        }

        return buf.toString();
    } catch (SQLException ex) {
        restartConnection(ex);
        return getArticleHeaders(articleID);
    } finally {
        closeResultSet(rs);
    }
}
 
开发者ID:cli,项目名称:sonews,代码行数:32,代码来源:JDBCDatabase.java

示例3: encodeValue

import javax.mail.internet.MimeUtility; //导入方法依赖的package包/类
/**
 * <p>
 * Encodes the specified value if necessary. Subclasses should override
 * this method to provide necessary encoding required for the particular
 * header fields, and then call this method before returning. </p>
 * <p>
 * The algorithm used here is:</p>
 * <ul>
 * <li>Remove any leading and trailing whitespaces.</li>
 * <li>Replace every line break character , including <code>'\r'</code>
 * and <code>'\n'</code>, with a space character.
 * </li>
 * <li>Fold the result string by calling
 * {@link javax.mail.internet.MimeUtility#fold(int,String)}</li>
 * </ul>
 * <p>
 * This method will be called by {@link #doEndTag()} method to encode
 * the specified <code>value</code> attribute before adding the header
 * field to the enclosing <code>Part</code> instance.</p>
 *
 * @param value
 * @return the encoded value
 * @throws JspException if the value cannot be encoded
 * @see #doEndTag() 
 */
protected String encodeValue(String value) throws JspException {
    // remove leading and trailing whitespaces
    value = normalizeAttribute(value);
    if (value == null) {
        return null;
    }

    // replace any line break with space
    StringBuffer sb = new StringBuffer(value.length());
    for (int i = 0; i < value.length(); i++) {
        char c = value.charAt(i);
        if (c == '\r' || c == '\n') {
            sb.append(' ');
        } else {
            sb.append(c);
        }
    }

    value = sb.toString();
    int used = this.name.length();
    return MimeUtility.fold(used, value);
}
 
开发者ID:rogersuen,项目名称:jmp,代码行数:48,代码来源:HeaderTag.java


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