org.cip4.jdflib.util.mime
Class BodyPartHelper

java.lang.Object
  extended by org.cip4.jdflib.util.mime.BodyPartHelper

public class BodyPartHelper
extends Object

Author:
Dr. Rainer Prosi, Heidelberger Druckmaschinen AG Jul 24, 2009

Field Summary
protected  javax.mail.BodyPart theBodyPart
           
 
Constructor Summary
BodyPartHelper()
          creates a new bodypart
BodyPartHelper(javax.mail.BodyPart bp)
           
 
Method Summary
 void createBodyPart()
           
 javax.mail.BodyPart createFromURL(String urlString)
           
 javax.mail.BodyPart getBodyPart()
           
 String getContentID()
          get the ContentID header of a bodypart a string
 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
 int getIndex()
           
 InputStream getInputStream()
           
 JDFDoc getJDFDoc()
          get the JDF Doc from a given body part
 XMLDoc getXMLDoc()
          get the JDF Doc from a given body part
 boolean matchesCID(String cid)
          check if a BodyPart matches a given cid
 void setContent(XMLDoc xmlDoc)
          sets the content of a bodypart to the xmlDoc - correctly handling non-ascii features and setting the correct content type
 void setContentID(String cid)
           
 void setFileName(String path)
          set the filename header of a bodypart to a string
 void writeToDir(File directory)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

theBodyPart

protected javax.mail.BodyPart theBodyPart
Constructor Detail

BodyPartHelper

public BodyPartHelper(javax.mail.BodyPart bp)
Parameters:
bp -

BodyPartHelper

public BodyPartHelper()
creates a new bodypart

Method Detail

getBodyPart

public javax.mail.BodyPart getBodyPart()
Returns:

createBodyPart

public void createBodyPart()

setContentID

public void setContentID(String cid)
Parameters:
cid -

setFileName

public void setFileName(String path)
set the filename header of a bodypart to a string

Parameters:
path - the path to set

getFileName

public 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(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 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,
                       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.MessagingException
IOException

createFromURL

public javax.mail.BodyPart createFromURL(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(File directory)
                throws IOException,
                       javax.mail.MessagingException
Parameters:
directory -
Throws:
javax.mail.MessagingException
IOException

getIndex

public int getIndex()
Returns:

getInputStream

public InputStream getInputStream()
Returns:


Copyright © 2013. All Rights Reserved.