本文整理汇总了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);
}
}
示例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);
}
}
示例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);
}