|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.james.mime4j.message.Entity
public abstract class Entity
MIME entity. An entity has a header and a body (see RFC 2045).
Constructor Summary | |
---|---|
protected |
Entity()
Creates a new Entity . |
protected |
Entity(Entity other)
Creates a new Entity from the specified
Entity . |
Method Summary | |
---|---|
void |
dispose()
Disposes of the body of this entity. |
Body |
getBody()
Gets the body of this entity. |
java.lang.String |
getCharset()
Determines the MIME character set encoding of this Entity . |
java.lang.String |
getContentTransferEncoding()
Determines the transfer encoding of this Entity . |
java.lang.String |
getDispositionType()
Return the disposition type of the content disposition of this Entity . |
java.lang.String |
getFilename()
Returns the filename parameter of the content disposition of this Entity . |
Header |
getHeader()
Gets the entity header. |
java.lang.String |
getMimeType()
Determines the MIME type of this Entity . |
Entity |
getParent()
Gets the parent entity of this entity. |
boolean |
isMimeType(java.lang.String type)
Determines if the MIME type of this Entity matches the
given one. |
boolean |
isMultipart()
Determines if the MIME type of this Entity is
multipart/* . |
Body |
removeBody()
Removes and returns the body of this entity. |
void |
setBody(Body body)
Sets the body of this entity. |
void |
setBody(Body body,
java.lang.String mimeType)
Sets the body of this entity and sets the content-type to the specified value. |
void |
setBody(Body body,
java.lang.String mimeType,
java.util.Map<java.lang.String,java.lang.String> parameters)
Sets the body of this entity and sets the content-type to the specified value. |
void |
setContentDisposition(java.lang.String dispositionType)
Sets the content disposition of this Entity to the
specified disposition type. |
void |
setContentDisposition(java.lang.String dispositionType,
java.lang.String filename)
Sets the content disposition of this Entity to the
specified disposition type and filename. |
void |
setContentDisposition(java.lang.String dispositionType,
java.lang.String filename,
long size)
Sets the content disposition of this Entity to the
specified values. |
void |
setContentDisposition(java.lang.String dispositionType,
java.lang.String filename,
long size,
java.util.Date creationDate,
java.util.Date modificationDate,
java.util.Date readDate)
Sets the content disposition of this Entity to the
specified values. |
void |
setContentTransferEncoding(java.lang.String contentTransferEncoding)
Sets the transfer encoding of this Entity to the specified
value. |
void |
setFilename(java.lang.String filename)
Sets the filename parameter of the content disposition of this Entity to the specified value. |
void |
setHeader(Header header)
Sets the entity header. |
void |
setMessage(Message message)
Sets the specified message as body of this entity and the content type to "message/rfc822". |
void |
setMultipart(Multipart multipart)
Sets the specified multipart as body of this entity. |
void |
setMultipart(Multipart multipart,
java.util.Map<java.lang.String,java.lang.String> parameters)
Sets the specified multipart as body of this entity. |
void |
setParent(Entity parent)
Sets the parent entity of this entity. |
void |
setText(TextBody textBody)
Sets the specified TextBody as body of this entity and the
content type to "text/plain". |
void |
setText(TextBody textBody,
java.lang.String subtype)
Sets the specified TextBody as body of this entity. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
protected Entity()
Entity
. Typically invoked implicitly by a
subclass constructor.
protected Entity(Entity other)
Entity
from the specified
Entity
. The Entity
instance is initialized
with copies of header and body of the specified Entity
.
The parent entity of the new entity is null
.
other
- entity to copy.
java.lang.UnsupportedOperationException
- if other
contains a SingleBody
that
does not support the copy()
operation.
java.lang.IllegalArgumentException
- if other
contains a Body
that
is neither a Message
, Multipart
or
SingleBody
.Method Detail |
---|
public Entity getParent()
null
if this is the root entity.
null
.public void setParent(Entity parent)
parent
- the parent entity or null
if
this will be the root entity.public Header getHeader()
public void setHeader(Header header)
header
- the header.public Body getBody()
public void setBody(Body body)
body
- the body.
java.lang.IllegalStateException
- if the body has already been set.public Body removeBody()
disposed
of.
null
if no body was set.public void setMessage(Message message)
Header
is created if this
entity does not already have one.
message
- the message to set as body.public void setMultipart(Multipart multipart)
Header
is created if this entity does not already have
one.
multipart
- the multipart to set as body.public void setMultipart(Multipart multipart, java.util.Map<java.lang.String,java.lang.String> parameters)
Header
is created if this entity does not already have
one.
multipart
- the multipart to set as body.parameters
- additional parameters for the Content-Type header field.public void setText(TextBody textBody)
TextBody
as body of this entity and the
content type to "text/plain". A Header
is
created if this entity does not already have one.
textBody
- the TextBody
to set as body.BodyFactory.textBody(String)
public void setText(TextBody textBody, java.lang.String subtype)
TextBody
as body of this entity. Also
sets the content type according to the specified sub-type. A
Header
is created if this entity does not already have
one.
textBody
- the TextBody
to set as body.subtype
- the text subtype (e.g. "plain", "html" or
"xml").BodyFactory.textBody(String)
public void setBody(Body body, java.lang.String mimeType)
Header
is created if this entity does not already
have one.
body
- the body.mimeType
- the MIME media type of the specified body
("type/subtype").public void setBody(Body body, java.lang.String mimeType, java.util.Map<java.lang.String,java.lang.String> parameters)
Header
is created if this entity does not already
have one.
body
- the body.mimeType
- the MIME media type of the specified body
("type/subtype").parameters
- additional parameters for the Content-Type header field.public java.lang.String getMimeType()
Entity
. The MIME type
is derived by looking at the parent's Content-Type field if no
Content-Type field is set for this Entity
.
public java.lang.String getCharset()
Entity
.
public java.lang.String getContentTransferEncoding()
Entity
.
public void setContentTransferEncoding(java.lang.String contentTransferEncoding)
Entity
to the specified
value.
contentTransferEncoding
- transfer encoding to use.public java.lang.String getDispositionType()
Entity
.
null
if no disposition
type has been set.public void setContentDisposition(java.lang.String dispositionType)
Entity
to the
specified disposition type. No filename, size or date parameters
are included in the content disposition.
dispositionType
- disposition type value (usually inline
or
attachment
).public void setContentDisposition(java.lang.String dispositionType, java.lang.String filename)
Entity
to the
specified disposition type and filename. No size or date parameters are
included in the content disposition.
dispositionType
- disposition type value (usually inline
or
attachment
).filename
- filename parameter value or null
if the
parameter should not be included.public void setContentDisposition(java.lang.String dispositionType, java.lang.String filename, long size)
Entity
to the
specified values. No date parameters are included in the content
disposition.
dispositionType
- disposition type value (usually inline
or
attachment
).filename
- filename parameter value or null
if the
parameter should not be included.size
- size parameter value or -1
if the parameter
should not be included.public void setContentDisposition(java.lang.String dispositionType, java.lang.String filename, long size, java.util.Date creationDate, java.util.Date modificationDate, java.util.Date readDate)
Entity
to the
specified values.
dispositionType
- disposition type value (usually inline
or
attachment
).filename
- filename parameter value or null
if the
parameter should not be included.size
- size parameter value or -1
if the parameter
should not be included.creationDate
- creation-date parameter value or null
if the
parameter should not be included.modificationDate
- modification-date parameter value or null
if
the parameter should not be included.readDate
- read-date parameter value or null
if the
parameter should not be included.public java.lang.String getFilename()
Entity
.
null
if the filename has not been set.public void setFilename(java.lang.String filename)
Entity
to the specified value. If this entity does not
have a content disposition header field a new one with disposition type
attachment
is created.
filename
- filename parameter value or null
if the
parameter should be removed.public boolean isMimeType(java.lang.String type)
Entity
matches the
given one. MIME types are case-insensitive.
type
- the MIME type to match against.
true
on match, false
otherwise.public boolean isMultipart()
Entity
is
multipart/*
. Since multipart-entities must have
a boundary parameter in the Content-Type
field this
method returns false
if no boundary exists.
true
on match, false
otherwise.public void dispose()
dispose
in interface Disposable
Disposable.dispose()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |