Methods Summary |
---|
public void | addBodyPart(BodyPart bodyPart)Adds a body part to the end of the list of body parts.
bodyParts.add(bodyPart);
bodyPart.setParent(parent);
|
public java.util.List | getBodyParts()Gets the list of body parts. The list is immutable.
return Collections.unmodifiableList(bodyParts);
|
private java.lang.String | getBoundary()Return the boundory of the parent Entity
Entity e = getParent();
ContentTypeField cField = (ContentTypeField) e.getHeader().getField(
Field.CONTENT_TYPE);
return cField.getBoundary();
|
private java.lang.String | getCharset()
Entity e = getParent();
String charString = ((ContentTypeField) e.getHeader().getField(Field.CONTENT_TYPE)).getCharset();
return charString;
|
public java.lang.String | getEpilogue()Gets the epilogue.
return epilogue;
|
public Entity | getParent()
return parent;
|
public java.lang.String | getPreamble()Gets the preamble.
return preamble;
|
public java.lang.String | getSubType()Gets the multipart sub-type. E.g. alternative (the default)
or parallel . See RFC 2045 for common sub-types and their
meaning.
return subType;
|
public void | setBodyParts(java.util.List bodyParts)Sets the list of body parts.
this.bodyParts = bodyParts;
for (Iterator it = bodyParts.iterator(); it.hasNext();) {
((BodyPart) it.next()).setParent(parent);
}
|
public void | setEpilogue(java.lang.String epilogue)Sets the epilogue.
this.epilogue = epilogue;
|
public void | setParent(Entity parent)
this.parent = parent;
for (Iterator it = bodyParts.iterator(); it.hasNext();) {
((BodyPart) it.next()).setParent(parent);
}
|
public void | setPreamble(java.lang.String preamble)Sets the preamble.
this.preamble = preamble;
|
public void | setSubType(java.lang.String subType)Sets the multipart sub-type. E.g. alternative
or parallel . See RFC 2045 for common sub-types and their
meaning.
this.subType = subType;
|
public void | writeTo(java.io.OutputStream out)
String boundary = getBoundary();
List bodyParts = getBodyParts();
BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(out, CharsetUtil.getCharset(getCharset())),8192);
writer.write(getPreamble() + "\r\n");
for (int i = 0; i < bodyParts.size(); i++) {
writer.write(boundary + "\r\n");
((BodyPart) bodyParts.get(i)).writeTo(out);
}
writer.write(getEpilogue() + "\r\n");
writer.write(boundary + "--" + "\r\n");
|