public interface MimeEntity
| Modifier and Type | Interface and Description |
|---|---|
static class |
MimeEntity.Encoding |
| Modifier and Type | Method and Description |
|---|---|
MimeHeader |
addHeader(String headerName)
Adds a header with the provied
headerName and blank content. |
MimeHeader |
addHeader(String headerName,
String value)
Adds a header with the provied
headerName and blank with the
provided value. |
void |
appendChildEntity(MimeEntity entity)
Append a child entity beneath this entity, with an auto-generated boundary.
|
MimeEntity |
createChildEntity()
Creates a child entity beneath this entity, with an auto-generated boundary.
|
MimeEntity |
createChildEntity(MimeEntity sibling)
Creates a child entity beneath this entity and placed immediately before the provided
entity, with an auto-generated boundary.
|
Optional<String> |
getBoundary()
Retrieves the boundary value used to separate children within this multipart entity
|
Optional<Iterable<MimeEntity>> |
getChildren()
Returns a mutable
Iterable view of the children of this multipart entity's
children. |
Optional<String> |
getContentAsString()
Retrieves the content of this entity as a string.
|
default Optional<jakarta.mail.internet.ContentType> |
getContentType()
Retrieves and parses the
Content-Type header of this entity,
if present. |
MimeEntity.Encoding |
getEncoding() |
List<MimeHeader> |
getHeaders()
Returns a list of all headers for this entity.
|
List<MimeHeader> |
getHeaders(String headerName)
Returns a list of all headers for this entity that match the provided
headerName. |
default Optional<InputStream> |
getInputStream()
Retrieves the content of the entity as an
InputStream. |
Optional<InputStream> |
getInputStream(boolean decode)
Retrieves the content of the entity as an
InputStream. |
Optional<MimeEntity> |
getParent()
Retrieves the parent of this entity, if it is part of a multipart tree.
|
Optional<String> |
getPreamble()
Gets the preamble of this multipart entity.
|
Optional<Reader> |
getReader()
Retrieves a
Reader for the text content of this entity. |
default boolean |
isMultipart() |
void |
removeChildEntity(MimeEntity child)
Removes the provided child entity from this multipart entity.
|
void |
removeHeaders(String headerName)
Removes all headers of the given name from this entity.
|
void |
setContent(InputStream is,
MimeEntity.Encoding encoding)
Sets the content of the MIME entity from the provided
InputStream, applying
the requested storage encoding. |
void |
setPreamble(String preamble)
Sets the preamble of this multipart entity.
|
MimeEntity.Encoding getEncoding()
default Optional<InputStream> getInputStream()
InputStream. If the entity's content is
encoded, this decodes it.
This is equivalent to calling getInputStream(true).
Optional describing a InputStream of the content of the entity,
decoded from storage format, or an empty one if this is a multipart entityOptional<InputStream> getInputStream(boolean decode)
InputStream. If the entity's content is
encoded, this decodes it if decode is true and leaves it encoded if it is
false.
This is equivalent to calling getInputStream(true).
decode - whether the content should be decoded from its storage formatOptional describing a InputStream of the content of the entity,
optionally decoded from storage format, or an empty one if this is a multipart entityOptional<Reader> getReader()
Reader for the text content of this entity. If the entity is encoded,
this decodes it. Additionally, this reader will obey any charset parameter in the
entity's Content-Type header, if present.Optional<String> getContentAsString()
void setContent(InputStream is, MimeEntity.Encoding encoding)
InputStream, applying
the requested storage encoding.
Note: the content of the stream should not be already encoded.
is - an InputStream to read; cannot be nullencoding - the MimeEntity.Encoding value to useIllegalStateException - if this is a multipart entitydefault Optional<jakarta.mail.internet.ContentType> getContentType() throws jakarta.mail.internet.ParseException
Content-Type header of this entity,
if present.Optional describing the ContentType object, or
an empty one if no header is setjakarta.mail.internet.ParseException - if the Content-Type header is present and invalidOptional<MimeEntity> getParent()
Optional describing the the parent MimeEntity, or
an empty one if this entity has no parentdefault boolean isMultipart()
throws jakarta.mail.internet.ParseException
true if this entity is a multipart typejakarta.mail.internet.ParseException - if the Content-Type header is present and invalidOptional<String> getPreamble()
Optional describing the preamble text of the entity,
an Optional empty string if there is no preamble, or an empty
Optional if this is not a multipart entityvoid setPreamble(String preamble)
preamble - the text of the preamble to set, or null to clear an existing
preambleIllegalStateException - if this is not a multipart entityOptional<String> getBoundary()
Optional describing the multipart boundary string, or an empty one
if this is not a multipart entityMimeEntity createChildEntity()
If this entity does not currently have a multipart content type, this
method sets the content type to multipart/mixed and any existing content
is removed.
MimeEntity createChildEntity(MimeEntity sibling)
If this entity does not currently have a multipart content type, this
method sets the content type to multipart/mixed and any existing content
is removed.
sibling - the entity in front of which to place the new childIllegalArgumentException - if sibling is not a child of the current entityvoid appendChildEntity(MimeEntity entity)
If the provided entity already has a parent entity, it is removed from that tree.
If this entity does not currently have a multipart content type, this
method sets the content type to multipart/mixed and any existing content
is removed.
entity - the entity to appendvoid removeChildEntity(MimeEntity child)
child - the child MimeEntity to removeOptional<Iterable<MimeEntity>> getChildren()
Iterable view of the children of this multipart entity's
children.
Calling createChildEntity(MimeEntity) will invalidate any objects previously
returned by this method.
List<MimeHeader> getHeaders()
List of MimeHeadersList<MimeHeader> getHeaders(String headerName)
headerName.headerName - the name of the headers to retrieveList of MimeHeadersMimeHeader addHeader(String headerName)
headerName and blank content.headerName - the name of the header to createMimeHeaderMimeHeader addHeader(String headerName, String value)
headerName and blank with the
provided value.
value is treated as the entire content of the header, and may contain
parameters.
headerName - the name of the header to createvalue - the value of the header to setMimeHeadervoid removeHeaders(String headerName)
headerName - the name of the headers to removeCopyright © 2019–2021 HCL. All rights reserved.