本文整理汇总了Java中org.apache.james.mime4j.dom.BinaryBody类的典型用法代码示例。如果您正苦于以下问题:Java BinaryBody类的具体用法?Java BinaryBody怎么用?Java BinaryBody使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
BinaryBody类属于org.apache.james.mime4j.dom包,在下文中一共展示了BinaryBody类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: append
import org.apache.james.mime4j.dom.BinaryBody; //导入依赖的package包/类
/***************************************************************************/
private void append(StringBuilder sb, Body body) {
if (body instanceof TextBody) {
/*
* A text body. Display its contents.
*/
TextBody textBody = (TextBody) body;
try {
Reader r = textBody.getReader();
int c;
while ((c = r.read()) != -1) {
sb.append((char) c);
}
} catch (IOException ex) {
ex.printStackTrace();
}
} else if (body instanceof BinaryBody) {
BinaryBody bBody = (BinaryBody) body;
append(sb, bBody);
} else if (body instanceof Multipart) {
Multipart mbody = (Multipart) body;
for (Entity part : mbody.getBodyParts()) {
append(sb, part);
}
}
/*
* Ignore Fields </br>
*
* ContentTypeField,AddressListField,DateTimeField UnstructuredField,
* Field
*
*/
else {
sb.append(body.toString());
}
}
示例2: originalMessageBodyPart
import org.apache.james.mime4j.dom.BinaryBody; //导入依赖的package包/类
private BodyPart originalMessageBodyPart() {
BinaryBody body = new MessageContentBody(originalMail.mailData);
BodyPart result = new BodyPart();
result.setBody(body, "message/rfc822");
return result;
}
示例3: createNode
import org.apache.james.mime4j.dom.BinaryBody; //导入依赖的package包/类
/**
* Creates the tree nodes given a MIME entity (either a Message or
* a BodyPart).
*
* @param entity the entity.
* @return the root node of the tree displaying the specified entity and
* its children.
*/
private DefaultMutableTreeNode createNode(Entity entity) {
/*
* Create the root node for the entity. It's either a
* Message or a Body part.
*/
String type = "Message";
if (entity instanceof BodyPart) {
type = "Body part";
}
DefaultMutableTreeNode node = new DefaultMutableTreeNode(
new ObjectWrapper(type, entity));
/*
* Add the node encapsulating the entity Header.
*/
node.add(createNode(entity.getHeader()));
Body body = entity.getBody();
if (body instanceof Multipart) {
/*
* The body of the entity is a Multipart.
*/
node.add(createNode((Multipart) body));
} else if (body instanceof MessageImpl) {
/*
* The body is another Message.
*/
node.add(createNode((MessageImpl) body));
} else {
/*
* Discrete Body (either of type TextBody or BinaryBody).
*/
type = "Text body";
if (body instanceof BinaryBody) {
type = "Binary body";
}
type += " (" + entity.getMimeType() + ")";
node.add(new DefaultMutableTreeNode(new ObjectWrapper(type, body)));
}
return node;
}