Package org.cip4.jdflib.util.mime
Class BodyPartHelper
java.lang.Object
org.cip4.jdflib.util.mime.BodyPartHelper
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidjavax.mail.BodyPartcreateFromURL(String urlString) javax.mail.BodyPartget the ContentID header of a bodypart a stringget the filename header of a bodypart a string if no file name is set, a unique filename is generated from cid and content typeintgetIndex()get the JDF Doc from a given body partget the JDF Doc from a given body partbooleanmatchesCID(String cid) check if a BodyPart matches a given cidbooleanmatchesFileName(String name) booleanmatchesKey(String key, String value) booleansetContent(InputStream is, 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(String cid) voidsetFileName(String path) set the filename header of a bodypart to a stringbooleantoString()voidwriteToDir(File directory)
-
Field Details
-
theBodyPart
protected javax.mail.BodyPart theBodyPart
-
-
Constructor Details
-
BodyPartHelper
public BodyPartHelper(javax.mail.BodyPart bp) - Parameters:
bp-
-
BodyPartHelper
public BodyPartHelper()creates a new bodypart
-
-
Method Details
-
getBodyPart
public javax.mail.BodyPart getBodyPart()- Returns:
-
createBodyPart
public void createBodyPart() -
setHeader
-
setContentID
- Parameters:
cid-
-
setFileName
set the filename header of a bodypart to a string- Parameters:
path- the path to set
-
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
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
get the ContentID header of a bodypart a string- Returns:
- the cid, null if there was an error
-
setContent
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.MessagingExceptionIOException
-
setContent
-
createFromURL
- Parameters:
urlString-- Returns:
-
getJDFDoc
get the JDF Doc from a given body part- Returns:
- JDFDoc the parsed xml JDFDoc, null if bp does not contain xml
-
getXMLDoc
get the JDF Doc from a given body part- Returns:
- JDFDoc the parsed xml JDFDoc, null if bp does not contain xml
-
writeToDir
- Parameters:
directory-- Throws:
javax.mail.MessagingExceptionIOException
-
getIndex
public int getIndex()- Returns:
-
getInputStream
- Returns:
-
getContentType
-
toString
-
getHeaderMap
-
matchesKey
-
matchesFileName
-