Package org.cip4.jdflib.util.mime
Class BodyPartHelper
- java.lang.Object
-
- org.cip4.jdflib.util.mime.BodyPartHelper
-
public class BodyPartHelper extends java.lang.Object
-
-
Field Summary
Fields Modifier and Type Field Description protected javax.mail.BodyParttheBodyPart
-
Constructor Summary
Constructors Constructor Description BodyPartHelper()creates a new bodypartBodyPartHelper(javax.mail.BodyPart bp)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcreateBodyPart()javax.mail.BodyPartcreateFromURL(java.lang.String urlString)javax.mail.BodyPartgetBodyPart()java.lang.StringgetContentID()get the ContentID header of a bodypart a stringjava.lang.StringgetContentType()java.lang.StringgetFileName()get the filename header of a bodypart a string if no file name is set, a unique filename is generated from cid and content typeJDFAttributeMapgetHeaderMap()intgetIndex()java.io.InputStreamgetInputStream()JDFDocgetJDFDoc()get the JDF Doc from a given body partXMLDocgetXMLDoc()get the JDF Doc from a given body partbooleanmatchesCID(java.lang.String cid)check if a BodyPart matches a given cidbooleanmatchesFileName(java.lang.String name)booleanmatchesKey(java.lang.String key, java.lang.String value)booleansetContent(java.io.InputStream is, java.lang.String contentType)voidsetContent(XMLDoc xmlDoc)sets the content of a bodypart to the xmlDoc - correctly handling non-ascii features and setting the correct content typevoidsetContentID(java.lang.String cid)voidsetFileName(java.lang.String path)set the filename header of a bodypart to a stringbooleansetHeader(java.lang.String key, java.lang.String value)java.lang.StringtoString()voidwriteToDir(java.io.File directory)
-
-
-
Method Detail
-
getBodyPart
public javax.mail.BodyPart getBodyPart()
- Returns:
-
createBodyPart
public void createBodyPart()
-
setHeader
public boolean setHeader(java.lang.String key, java.lang.String value)
-
setContentID
public void setContentID(java.lang.String cid)
- Parameters:
cid-
-
setFileName
public void setFileName(java.lang.String path)
set the filename header of a bodypart to a string- Parameters:
path- the path to set
-
getFileName
public java.lang.String getFileName()
get the filename header of a bodypart a string if no file name is set, a unique filename is generated from cid and content type- Returns:
- the file name, null if bp is null
-
matchesCID
public boolean matchesCID(java.lang.String cid)
check if a BodyPart matches a given cid- Parameters:
cid- the cid string any '<' '>' or 'cid:' prefixes are removed if null, anything matches- Returns:
- true if this bp matches the cid
-
getContentID
public java.lang.String getContentID()
get the ContentID header of a bodypart a string- Returns:
- the cid, null if there was an error
-
setContent
public void setContent(XMLDoc xmlDoc) throws javax.mail.MessagingException, java.io.IOException
sets the content of a bodypart to the xmlDoc - correctly handling non-ascii features and setting the correct content type- Parameters:
xmlDoc- the xmlDoc to fill in- Throws:
javax.mail.MessagingExceptionjava.io.IOException
-
setContent
public boolean setContent(java.io.InputStream is, java.lang.String contentType)
-
createFromURL
public javax.mail.BodyPart createFromURL(java.lang.String urlString)
- Parameters:
urlString-- Returns:
-
getJDFDoc
public JDFDoc getJDFDoc()
get the JDF Doc from a given body part- Returns:
- JDFDoc the parsed xml JDFDoc, null if bp does not contain xml
-
getXMLDoc
public XMLDoc getXMLDoc()
get the JDF Doc from a given body part- Returns:
- JDFDoc the parsed xml JDFDoc, null if bp does not contain xml
-
writeToDir
public void writeToDir(java.io.File directory) throws java.io.IOException, javax.mail.MessagingException- Parameters:
directory-- Throws:
javax.mail.MessagingExceptionjava.io.IOException
-
getIndex
public int getIndex()
- Returns:
-
getInputStream
public java.io.InputStream getInputStream()
- Returns:
-
getContentType
public java.lang.String getContentType()
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object- See Also:
Object.toString()
-
getHeaderMap
public JDFAttributeMap getHeaderMap()
-
matchesKey
public boolean matchesKey(java.lang.String key, java.lang.String value)
-
matchesFileName
public boolean matchesFileName(java.lang.String name)
-
-