Class BodyPartHelper

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

public class BodyPartHelper extends Object
  • Field Details

    • theBodyPart

      protected jakarta.mail.BodyPart theBodyPart
  • Constructor Details

    • BodyPartHelper

      public BodyPartHelper(jakarta.mail.BodyPart bp)
      Parameters:
      bp -
    • BodyPartHelper

      public BodyPartHelper()
      creates a new bodypart
  • Method Details

    • getBodyPart

      public jakarta.mail.BodyPart getBodyPart()
      Returns:
    • createBodyPart

      public void createBodyPart()
    • setHeader

      public boolean setHeader(String key, String value)
    • 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 jakarta.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:
      jakarta.mail.MessagingException
      IOException
    • setContent

      public boolean setContent(InputStream is, String contentType)
    • createFromURL

      public jakarta.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, jakarta.mail.MessagingException
      Parameters:
      directory -
      Throws:
      jakarta.mail.MessagingException
      IOException
    • getIndex

      public int getIndex()
      Returns:
    • getInputStream

      public InputStream getInputStream()
      Returns:
    • getContentType

      public String getContentType()
    • toString

      public String toString()
      Overrides:
      toString in class Object
      See Also:
    • getHeaderMap

      public JDFAttributeMap getHeaderMap()
    • matchesKey

      public boolean matchesKey(String key, String value)
    • matchesFileName

      public boolean matchesFileName(String name)