|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.openexchange.mail.dataobjects.MailPart
public abstract class MailPart
MailPart - Abstract super class for all MailPart subclasses.
It's main purpose is to provide access to common part headers and part's content.
| Field Summary | |
|---|---|
static int |
NO_ENCLOSED_PARTS
The integer constant returned by getEnclosedCount() if mail part's content type does not match multipart/* and
therefore does not hold any enclosed parts. |
| Method Summary | |
|---|---|
void |
addHeader(java.lang.String name,
java.lang.String value)
Adds a header |
void |
addHeaders(HeaderCollection headers)
Adds a header collection |
java.lang.Object |
clone()
|
boolean |
containsContentDisposition()
|
boolean |
containsContentId()
|
boolean |
containsContentType()
|
boolean |
containsFileName()
|
boolean |
containsHeader(java.lang.String name)
Checks for a header entry for specified header |
boolean |
containsHeaders()
|
boolean |
containsMsgref()
|
boolean |
containsSequenceId()
|
boolean |
containsSize()
|
abstract java.lang.Object |
getContent()
Returns the part's content as a Java object dependent on underlying implementation. |
ContentDisposition |
getContentDisposition()
Gets the disposition |
java.lang.String |
getContentId()
Gets the contentId |
ContentType |
getContentType()
Gets the content type |
abstract javax.activation.DataHandler |
getDataHandler()
Returns an appropriate DataHandler for this mail part. |
abstract int |
getEnclosedCount()
Gets the number of enclosed mail parts. |
abstract MailPart |
getEnclosedMailPart(int index)
Gets the mail part located at given index. |
java.lang.String |
getFileName()
Gets the fileName |
java.lang.String |
getFirstHeader(java.lang.String name)
Gets the first header for specified header name. |
java.lang.String[] |
getHeader(java.lang.String name)
Gets all the values for the specified header. |
java.lang.String |
getHeader(java.lang.String name,
char delimiter)
Gets all the headers for this header name, returned as a single String, with headers separated by the delimiter. |
java.lang.String |
getHeader(java.lang.String name,
java.lang.String delimiter)
Gets all the headers for this header name, returned as a single String, with headers separated by the delimiter. |
HeaderCollection |
getHeaders()
Gets a read-only version of this part's headers |
java.util.Iterator<java.util.Map.Entry<java.lang.String,java.lang.String>> |
getHeadersIterator()
Gets an instance of Iterator to iterate all headers |
int |
getHeadersSize()
Gets the number of headers |
abstract java.io.InputStream |
getInputStream()
Returns an input stream for this part. |
java.util.Iterator<java.util.Map.Entry<java.lang.String,java.lang.String>> |
getMatchingHeaders(java.lang.String[] matchingHeaders)
Gets an iterator for matching headers |
MailPath |
getMsgref()
Gets the message reference |
java.util.Iterator<java.util.Map.Entry<java.lang.String,java.lang.String>> |
getNonMatchingHeaders(java.lang.String[] nonMatchingHeaders)
Gets an iterator for non-matching headers |
java.lang.String |
getSequenceId()
Gets the sequenceId |
long |
getSize()
Gets the size |
java.lang.String |
getSource()
Gets the mail part's source |
byte[] |
getSourceBytes()
Gets a newly allocated byte array containing the mail part's source bytes |
boolean |
hasEnclosedParts()
Checks if part's MIME type is multipart/* |
boolean |
hasHeaders(java.lang.String... names)
Checks if this part contains all of specified headers. |
abstract void |
loadContent()
Ensures that the part's content is loaded, thus this part is independent of the original. |
abstract void |
prepareForCaching()
Prepares this mail part to be put into cache; meaning to release all kept resources |
void |
removeContentDisposition()
Removes the disposition |
void |
removeContentId()
Removes the contentId |
void |
removeContentType()
Removes the content type |
void |
removeFileName()
Removes the fileName |
void |
removeHeader(java.lang.String name)
Removes the header if present |
void |
removeHeaders()
Removes the headers |
void |
removeMsgref()
Removes the message reference |
void |
removeSequenceId()
Removes the sequenceId |
void |
removeSize()
Removes the size |
void |
setContentDisposition(ContentDisposition disposition)
Sets the disposition |
void |
setContentDisposition(java.lang.String disposition)
Sets the disposition |
void |
setContentId(java.lang.String contentId)
Sets the contentId |
void |
setContentType(ContentType contentType)
Sets the content type |
void |
setContentType(java.lang.String contentType)
Parses and sets the content type |
void |
setFileName(java.lang.String fileName)
Sets the fileName |
void |
setMsgref(MailPath msgref)
Sets the message reference |
void |
setSequenceId(java.lang.String sequenceId)
Sets the sequenceId |
void |
setSize(long size)
Sets the size |
void |
writeTo(java.io.OutputStream out)
Writes complete part's data into given output stream |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final int NO_ENCLOSED_PARTS
getEnclosedCount() if mail part's content type does not match multipart/* and
therefore does not hold any enclosed parts.
| Method Detail |
|---|
public ContentType getContentType()
public boolean containsContentType()
true if content type is set; otherwise falsepublic void removeContentType()
public void setContentType(ContentType contentType)
contentType - the contentType to set
public void setContentType(java.lang.String contentType)
throws MailException
contentType - the content type to parse
MailException - If content type is invalid or could not be parsedpublic ContentDisposition getContentDisposition()
public boolean containsContentDisposition()
true if disposition is set; otherwise falsepublic void removeContentDisposition()
public void setContentDisposition(java.lang.String disposition)
throws MailException
disposition - the disposition to set
MailException - If content disposition is invalid or could not be parsedpublic void setContentDisposition(ContentDisposition disposition)
disposition - the disposition to setpublic java.lang.String getFileName()
public boolean containsFileName()
true if fileName is set; otherwise falsepublic void removeFileName()
public void setFileName(java.lang.String fileName)
fileName - the fileName to set
public void addHeader(java.lang.String name,
java.lang.String value)
name - The header namevalue - The header valuepublic void addHeaders(HeaderCollection headers)
headers - The header collectionpublic boolean containsHeaders()
true if headers is set; otherwise falsepublic void removeHeaders()
public int getHeadersSize()
public java.util.Iterator<java.util.Map.Entry<java.lang.String,java.lang.String>> getHeadersIterator()
Iterator to iterate all headers
Iterator to iterate all headersgetHeadersSize()public boolean containsHeader(java.lang.String name)
name - The header name
true if a header entry exists for specified header; otherwise falsepublic java.lang.String[] getHeader(java.lang.String name)
name - The header name
nullpublic java.lang.String getFirstHeader(java.lang.String name)
This is a convenience method that invokes getHeader(String, String) with the latter parameter set to null.
name - The header name
null
public java.lang.String getHeader(java.lang.String name,
java.lang.String delimiter)
null, only the first header is returned. Returns null if no headers with the specified name exist.
name - The header namedelimiter - The delimiter
null
public java.lang.String getHeader(java.lang.String name,
char delimiter)
'\0', only the first header is returned. Returns null if no headers with the specified name exist.
name - The header namedelimiter - The delimiter character
nullpublic HeaderCollection getHeaders()
public java.util.Iterator<java.util.Map.Entry<java.lang.String,java.lang.String>> getNonMatchingHeaders(java.lang.String[] nonMatchingHeaders)
nonMatchingHeaders - The non-matching headers
public java.util.Iterator<java.util.Map.Entry<java.lang.String,java.lang.String>> getMatchingHeaders(java.lang.String[] matchingHeaders)
matchingHeaders - The matching headers
null if not existspublic void removeHeader(java.lang.String name)
name - The header namepublic boolean hasHeaders(java.lang.String... names)
names - The names of the headers to check
true if this part contains all of specified headers; otherwise falsepublic long getSize()
public boolean containsSize()
true if size is set; otherwise falsepublic void removeSize()
public void setSize(long size)
size - the size to setpublic java.lang.String getContentId()
public boolean containsContentId()
true if contentId is set; otherwise falsepublic void removeContentId()
public void setContentId(java.lang.String contentId)
contentId - the contentId to setpublic java.lang.String getSequenceId()
public boolean containsSequenceId()
true if sequenceId is set; otherwise falsepublic void removeSequenceId()
public void setSequenceId(java.lang.String sequenceId)
sequenceId - the sequenceId to setpublic MailPath getMsgref()
public boolean containsMsgref()
true if message reference is set; otherwise falsepublic void removeMsgref()
public void setMsgref(MailPath msgref)
msgref - the message reference to setpublic java.lang.Object clone()
clone in class java.lang.Object
public boolean hasEnclosedParts()
throws MailException
multipart/*
true if part holds enclosed parts; otherwise false
MailException - If check fails
public abstract java.lang.Object getContent()
throws MailException
multipart/*
null if not applicable
MailException - If content cannot be returned as a Java object
public abstract javax.activation.DataHandler getDataHandler()
throws MailException
DataHandler for this mail part. multipart/*
DataHandler or null if not applicable
MailException - If an appropriate DataHandler cannot be returned
public abstract java.io.InputStream getInputStream()
throws MailException
multipart/*
null if not applicable
MailException - If no input stream could be returned
public abstract int getEnclosedCount()
throws MailException
multipart/*
NO_ENCLOSED_PARTS if not applicable
MailExceptionNO_ENCLOSED_PARTS
public abstract MailPart getEnclosedMailPart(int index)
throws MailException
multipart/*
index - The index of desired mail part or null if not applicable
MailException
public abstract void loadContent()
throws MailException
This method is intended for mailing systems that read the contents stepwise on demand. If dealing with such a mail part with its underlying connection closed, the part's content is no more accessible. Otherwise this method may be implemented with an empty body.
Moreover the loaded content is no more discarded when prepareForCaching() is invoked.
MailException - If loading part's content fails
public void writeTo(java.io.OutputStream out)
throws MailException
out - The output stream to write to
MailException - If writing to output stream fails
public java.lang.String getSource()
throws MailException
MailException - If mail part's source cannot be returned
public byte[] getSourceBytes()
throws MailException
MailException - If mail part's source cannot be returnedpublic abstract void prepareForCaching()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||