Class AbstractEntity
java.lang.Object
org.apache.james.mime4j.message.AbstractEntity
- All Implemented Interfaces:
Disposable, Entity
- Direct Known Subclasses:
AbstractMessage, BodyPart
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract StringcalcCharset(ContentTypeField contentType) protected abstract StringcalcMimeType(ContentTypeField child, ContentTypeField parent) protected abstract Stringvoiddispose()Disposes of the body of this entity.getBody()Gets the body of this entity.Determines the MIME character set encoding of thisEntity.Determines the transfer encoding of thisEntity.private ContentTypeFieldReturn the disposition type of the content disposition of thisEntity.Returns the filename parameter of the content disposition of thisEntity.Gets the entity header.Determines the MIME type of thisEntity.Gets the parent entity of this entity.booleanDetermines if the MIME type of thisEntityismultipart/*.(package private) <F extends ParsedField>
FobtainField(String fieldName) Obtains the header field with the specified name.(package private) HeaderObtains the header of this entity.Removes and returns the body of this entity.voidSets the body of this entity.voidSets the entity header.voidSets the parent entity of this entity.
-
Field Details
-
header
-
body
-
parent
-
-
Constructor Details
-
AbstractEntity
protected AbstractEntity()Creates a newEntity. Typically invoked implicitly by a subclass constructor.
-
-
Method Details
-
getParent
-
setParent
-
getHeader
-
setHeader
-
getBody
-
setBody
Sets the body of this entity.- Specified by:
setBodyin interfaceEntity- Parameters:
body- the body.- Throws:
IllegalStateException- if the body has already been set.
-
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
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.
-
getContentTypeField
-
getCharset
Determines the MIME character set encoding of thisEntity.- Specified by:
getCharsetin interfaceEntity- Returns:
- the MIME character set encoding.
-
getContentTransferEncoding
Determines the transfer encoding of thisEntity.- Specified by:
getContentTransferEncodingin interfaceEntity- Returns:
- the transfer encoding.
-
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
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:
-
obtainHeader
Header obtainHeader()Obtains the header of this entity. Creates and sets a new header if this entity's header is currentlynull.- Returns:
- the header of this entity; never
null.
-
obtainField
Obtains the header field with the specified name.- Type Parameters:
F- concrete field type.- Parameters:
fieldName- name of the field to retrieve.- Returns:
- the header field or
nullif this entity has no header or the header contains no such field.
-
calcMimeType
-
calcTransferEncoding
-
calcCharset
-