Package org.apache.james.mime4j.message
Class AbstractEntity
- java.lang.Object
-
- org.apache.james.mime4j.message.AbstractEntity
-
- All Implemented Interfaces:
Disposable,Entity
- Direct Known Subclasses:
AbstractMessage,BodyPart
public abstract class AbstractEntity extends Object implements Entity
Abstract MIME entity.
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractEntity()Creates a newEntity.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract StringcalcCharset(ContentTypeField contentType)protected abstract StringcalcMimeType(ContentTypeField child, ContentTypeField parent)protected abstract StringcalcTransferEncoding(ContentTransferEncodingField f)voiddispose()Disposes of the body of this entity.BodygetBody()Gets the body of this entity.StringgetCharset()Determines the MIME character set encoding of thisEntity.StringgetContentTransferEncoding()Determines the transfer encoding of thisEntity.StringgetDispositionType()Return the disposition type of the content disposition of thisEntity.StringgetFilename()Returns the filename parameter of the content disposition of thisEntity.HeadergetHeader()Gets the entity header.StringgetMimeType()Determines the MIME type of thisEntity.EntitygetParent()Gets the parent entity of this entity.booleanisMultipart()Determines if the MIME type of thisEntityismultipart/*.BodyremoveBody()Removes and returns the body of this entity.voidsetBody(Body body)Sets the body of this entity.voidsetHeader(Header header)Sets the entity header.voidsetParent(Entity parent)Sets the parent entity of this entity.
-
-
-
Method Detail
-
getParent
public Entity getParent()
Gets the parent entity of this entity. Returnsnullif this is the root entity.
-
setParent
public void setParent(Entity parent)
Sets the parent entity of this entity.
-
getHeader
public Header getHeader()
Gets the entity header.
-
setHeader
public void setHeader(Header header)
Sets the entity header.
-
getBody
public Body getBody()
Gets the body of this entity.
-
setBody
public void setBody(Body body)
Sets the body of this entity.- Specified by:
setBodyin interfaceEntity- Parameters:
body- the body.- Throws:
IllegalStateException- if the body has already been set.
-
removeBody
public Body removeBody()
Removes and returns the body of this entity. The removed body may be attached to another entity. If it is no longer needed it should bedisposedof.- Specified by:
removeBodyin interfaceEntity- Returns:
- the removed body or
nullif no body was set.
-
getMimeType
public String getMimeType()
Description copied from interface:EntityDetermines the MIME type of thisEntity. The MIME type is derived by looking at the parent's Content-Type field if no Content-Type field is set for thisEntity.- Specified by:
getMimeTypein interfaceEntity- Returns:
- the MIME type.
-
getCharset
public String getCharset()
Determines the MIME character set encoding of thisEntity.- Specified by:
getCharsetin interfaceEntity- Returns:
- the MIME character set encoding.
-
getContentTransferEncoding
public String getContentTransferEncoding()
Determines the transfer encoding of thisEntity.- Specified by:
getContentTransferEncodingin interfaceEntity- Returns:
- the transfer encoding.
-
getDispositionType
public String getDispositionType()
Return the disposition type of the content disposition of thisEntity.- Specified by:
getDispositionTypein interfaceEntity- Returns:
- the disposition type or
nullif no disposition type has been set.
-
getFilename
public String getFilename()
Returns the filename parameter of the content disposition of thisEntity.- Specified by:
getFilenamein interfaceEntity- Returns:
- the filename parameter of the content disposition or
nullif the filename has not been set.
-
isMultipart
public boolean isMultipart()
Determines if the MIME type of thisEntityismultipart/*. Since multipart-entities must have a boundary parameter in theContent-Typefield this method returnsfalseif no boundary exists.- Specified by:
isMultipartin interfaceEntity- Returns:
trueon match,falseotherwise.
-
dispose
public void dispose()
Disposes of the body of this entity. Note that the dispose call does not get forwarded to the parent entity of this Entity. Subclasses that need to free resources should override this method and invoke super.dispose().- Specified by:
disposein interfaceDisposable- See Also:
Disposable.dispose()
-
calcMimeType
protected abstract String calcMimeType(ContentTypeField child, ContentTypeField parent)
-
calcTransferEncoding
protected abstract String calcTransferEncoding(ContentTransferEncodingField f)
-
calcCharset
protected abstract String calcCharset(ContentTypeField contentType)
-
-