public Header newHeader(final Header source) { return copy(source); }
public Multipart newMultipart(final Multipart source) { return copy(source); }
public Message newMessage(final Message source) { return copy(source); }
/** * Creates a new <code>BodyPart</code> from the specified * <code>Entity</code>. The <code>BodyPart</code> instance is initialized * with copies of header and body of the specified <code>Entity</code>. * The parent entity of the new body part is <code>null</code>. * * @param other * body part to copy. * @throws UnsupportedOperationException * if <code>other</code> contains a {@link SingleBody} that * does not support the {@link SingleBody#copy() copy()} * operation. * @throws IllegalArgumentException * if <code>other</code> contains a <code>Body</code> that * is neither a {@link Message}, {@link Multipart} or * {@link SingleBody}. */ public BodyPart copy(Entity other) { BodyPart copy = new BodyPart(); if (other.getHeader() != null) { copy.setHeader(copy(other.getHeader())); } if (other.getBody() != null) { copy.setBody(copy(other.getBody())); } return copy; }
/** * Creates a new <code>Message</code> from the specified * <code>Message</code>. The <code>Message</code> instance is * initialized with copies of header and body of the specified * <code>Message</code>. The parent entity of the new message is * <code>null</code>. * * @param other * message to copy. * @throws UnsupportedOperationException * if <code>other</code> contains a {@link SingleBody} that * does not support the {@link SingleBody#copy() copy()} * operation. * @throws IllegalArgumentException * if <code>other</code> contains a <code>Body</code> that * is neither a {@link MessageImpl}, {@link Multipart} or * {@link SingleBody}. */ public Message copy(Message other) { MessageImpl copy = newMessageImpl(); if (other.getHeader() != null) { copy.setHeader(copy(other.getHeader())); } if (other.getBody() != null) { copy.setBody(copy(other.getBody())); } return copy; }
/** * Creates a new <code>Multipart</code> from the specified * <code>Multipart</code>. The <code>Multipart</code> instance is * initialized with copies of preamble, epilogue, sub type and the list of * body parts of the specified <code>Multipart</code>. The parent entity * of the new multipart is <code>null</code>. * * @param other * multipart to copy. * @throws UnsupportedOperationException * if <code>other</code> contains a {@link SingleBody} that * does not support the {@link SingleBody#copy() copy()} * operation. * @throws IllegalArgumentException * if <code>other</code> contains a <code>Body</code> that * is neither a {@link Message}, {@link Multipart} or * {@link SingleBody}. */ public Multipart copy(Multipart other) { MultipartImpl copy = new MultipartImpl(other.getSubType(), other.getContentTypeParameters()); for (Entity otherBodyPart : other.getBodyParts()) { copy.addBodyPart(copy(otherBodyPart)); } copy.setPreamble(other.getPreamble()); copy.setEpilogue(other.getEpilogue()); return copy; }