org.apache.james.mime4j.message
Class SingleBody

java.lang.Object
  extended by org.apache.james.mime4j.message.SingleBody
All Implemented Interfaces:
Body, Disposable
Direct Known Subclasses:
BinaryBody, TextBody

public abstract class SingleBody
extends java.lang.Object
implements Body

Abstract implementation of a single message body; that is, a body that does not contain (directly or indirectly) any other child bodies. It also provides the parent functionality required by bodies.


Constructor Summary
protected SingleBody()
          Sole constructor.
 
Method Summary
 SingleBody copy()
          Returns a copy of this SingleBody (optional operation).
 void dispose()
          Subclasses should override this method if they have allocated resources that need to be freed explicitly (e.g.
 Entity getParent()
          Gets the parent of this body.
 void setParent(Entity parent)
          Sets the parent of this body.
abstract  void writeTo(java.io.OutputStream out)
          Writes this single body to the given stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SingleBody

protected SingleBody()
Sole constructor.

Method Detail

getParent

public Entity getParent()
Description copied from interface: Body
Gets the parent of this body.

Specified by:
getParent in interface Body
Returns:
the parent.
See Also:
Body.getParent()

setParent

public void setParent(Entity parent)
Description copied from interface: Body
Sets the parent of this body.

Specified by:
setParent in interface Body
Parameters:
parent - the parent.
See Also:
Body.setParent(org.apache.james.mime4j.message.Entity)

writeTo

public abstract void writeTo(java.io.OutputStream out)
                      throws java.io.IOException
Writes this single body to the given stream.

Parameters:
out - the stream to write to.
Throws:
java.io.IOException - in case of an I/O error

copy

public SingleBody copy()
Returns a copy of this SingleBody (optional operation).

The general contract of this method is as follows:

This implementation always throws an UnsupportedOperationException.

Returns:
a copy of this SingleBody.
Throws:
java.lang.UnsupportedOperationException - if the copy operation is not supported by this single body.

dispose

public void dispose()
Subclasses should override this method if they have allocated resources that need to be freed explicitly (e.g. cannot be simply reclaimed by the garbage collector). The default implementation of this method does nothing.

Specified by:
dispose in interface Disposable
See Also:
Disposable.dispose()


Copyright © 2004-2009 The Apache Software Foundation. All Rights Reserved.