Class BodyPartHelper


  • public class BodyPartHelper
    extends java.lang.Object
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected javax.mail.BodyPart theBodyPart  
    • Constructor Summary

      Constructors 
      Constructor Description
      BodyPartHelper()
      creates a new bodypart
      BodyPartHelper​(javax.mail.BodyPart bp)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void createBodyPart()  
      javax.mail.BodyPart createFromURL​(java.lang.String urlString)  
      javax.mail.BodyPart getBodyPart()  
      java.lang.String getContentID()
      get the ContentID header of a bodypart a string
      java.lang.String getContentType()  
      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
      JDFAttributeMap getHeaderMap()  
      int getIndex()  
      java.io.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​(java.lang.String cid)
      check if a BodyPart matches a given cid
      boolean matchesFileName​(java.lang.String name)  
      boolean matchesKey​(java.lang.String key, java.lang.String value)  
      boolean setContent​(java.io.InputStream is, java.lang.String contentType)  
      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​(java.lang.String cid)  
      void setFileName​(java.lang.String path)
      set the filename header of a bodypart to a string
      boolean setHeader​(java.lang.String key, java.lang.String value)  
      java.lang.String toString()  
      void writeToDir​(java.io.File directory)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, 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()
      • 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.MessagingException
        java.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.MessagingException
        java.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:
        toString in class java.lang.Object
        See Also:
        Object.toString()
      • matchesKey

        public boolean matchesKey​(java.lang.String key,
                                  java.lang.String value)
      • matchesFileName

        public boolean matchesFileName​(java.lang.String name)