/**
* Sets the attachment file name formatters. The format method of each
* attachment formatter will see only the <tt>LogRecord</tt> objects that
* passed its attachment filter during formatting. The format method will
* typically return an empty string. Instead of being used to format
* records, it is used to gather information about the contents of an
* attachment. The <tt>getTail</tt> method should be used to construct the
* attachment file name and reset any formatter collected state. The
* formatter must ensure that the attachment file name does not contain any
* line breaks. The <tt>toString</tt> method of the given formatter should
* be overridden to provide a useful attachment file name, if possible.
* @param formatters and array of attachment name formatters.
* @throws SecurityException if a security manager exists and the
* caller does not have <tt>LoggingPermission("control")</tt>.
* @throws IndexOutOfBoundsException if the number of attachment
* name formatters do not match the number of attachment formatters.
* @throws NullPointerException if any given array or name is <tt>null</tt>.
* @throws IllegalStateException if called from inside a push.
* @see Character#isISOControl(char)
* @see Character#isISOControl(int)
*/
public final void setAttachmentNames(Formatter... formatters) {
checkAccess();
formatters = copyOf(formatters, formatters.length, Formatter[].class);
for (int i = 0; i < formatters.length; ++i) {
if (formatters[i] == null) {
throw new NullPointerException(atIndexMsg(i));
}
}
synchronized (this) {
if (this.attachmentFormatters.length != formatters.length) {
throw attachmentMismatch(this.attachmentFormatters.length, formatters.length);
}
if (isWriting) {
throw new IllegalStateException();
}
this.attachmentNames = formatters;
}
}
MailHandler.java 文件源码
java
阅读 30
收藏 0
点赞 0
评论 0
项目:kore-javamail
作者:
评论列表
文章目录