Class BodypartFTBP


  • public class BodypartFTBP
    extends Bodypart
    This class represents a File Transfer bodypart.

    This kind of bodypart is used to preserve attributes like the file name, the size, creation time, modification time, file permission, etc.

    Note that the dates returned by the get() method, and those expected by set() methods are in UTC Time format. This encodes it as YYMMDDHHMMSSzone.
    For example, 2 October 2008, at 15:37:41 GMT is 081002153741Z.

    • Constructor Summary

      Constructors 
      Constructor Description
      BodypartFTBP​(BodyPart bp_obj)
      Constructor based on an existing bodypart object, for example, one read from an existing message.
      BodypartFTBP​(java.lang.String filename)
      Create a new File Transfer bodypart, with only the binary data taken from the file provided by the filename.
      BodypartFTBP​(java.lang.String filename, boolean set_common_attributes)
      Create a new File Transfer bodypart, optionally setting all the common attributes with information taken from the file itself.
      BodypartFTBP​(java.lang.String filename, byte[] ftbp_data)
      Create a new File Transfer bodypart, with the binary data provided (in memory) and the filename.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.String getApplicationReferenceOID()
      Returns the application reference OID of the File Transfer Body Part The value is a dotted decimal value.
      java.lang.String getApplicationReferenceString()
      Returns the application reference of the File Transfer Body Part, as a String
      byte[] getBodyData()
      Returns the data of the File Transfer Body Part as an array of bytes
      java.lang.String getContentDescription()
      Returns the content description of the File Transfer Body Part
      java.lang.String getCreationDate()
      Returns the creation date of the File Transfer Body Part, encoded as a UTC time string
      java.lang.String getFileName()
      Returns the name of the file attribute of the File Transfer Body Part
      java.lang.String getModificationDate()
      Returns the modification date of the File Transfer Body Part, encoded as a UTC time string
      java.lang.String getReadDate()
      Returns the read date of the File Transfer Body Part, encoded as a UTC time string
      int getSize()
      Returns the size (in bytes) of the file in the File Transfer Body Part, or -1 if the size cannot be calculated.
      java.lang.String getStringRepresentation()
      Returns the string of the File Transfer bodypart.
      void saveFTBPInDir​(java.lang.String outputDir)
      Save the FTBP in the specified directory, the file name will be the one specified in the actual bodypart
      void setApplicationReference​(java.lang.String appRefStr)
      Set the application reference of the File Transfer Body Part
      void setApplicationReferenceOID​(java.lang.String appRefOID)
      Set the application reference OID of the File Transfer Body Part The value is a dotted decimal value.
      void setBodyData​(byte[] data)
      Set the data of the File Transfer Body Part as an array of bytes
      void setContentDescription​(java.lang.String description)
      Set the content description of the File Transfer Body Part
      void setCreationDate​(java.lang.String cd)
      Set the creation date of the File Transfer Body Part, encoded as a UTC time string
      void setFileName​(java.lang.String filename)
      Set the name of the file attribute of the File Transfer Body Part
      void setFTBPSize​(int size)
      Set the size (in bytes) of the FTBP
      void setModificationDate​(java.lang.String md)
      Set the modification date of the File Transfer Body Part
      void setReadDate​(java.lang.String rd)
      Set the read date of the File Transfer Body Part, encoded as a UTC time string
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • BodypartFTBP

        public BodypartFTBP​(BodyPart bp_obj)
                     throws X400APIException
        Constructor based on an existing bodypart object, for example, one read from an existing message.
        Parameters:
        bp_obj -
        Throws:
        X400APIException
      • BodypartFTBP

        public BodypartFTBP​(java.lang.String filename)
                     throws X400APIException
        Create a new File Transfer bodypart, with only the binary data taken from the file provided by the filename.

        All the other attributes, like file name, modification date, etc, can be added independently after.

        Alternatively, you can use the BodypartFTBP(filename, true) method to set the standard values automatically.

        Throws:
        X400APIException
      • BodypartFTBP

        public BodypartFTBP​(java.lang.String filename,
                            boolean set_common_attributes)
                     throws X400APIException
        Create a new File Transfer bodypart, optionally setting all the common attributes with information taken from the file itself.
        Parameters:
        filename - Full path name to the file to use as a bodypart
        set_common_attributes - If true, set the file name, file size and encoding
        Throws:
        X400APIException
      • BodypartFTBP

        public BodypartFTBP​(java.lang.String filename,
                            byte[] ftbp_data)
                     throws X400APIException
        Create a new File Transfer bodypart, with the binary data provided (in memory) and the filename. This method can be used when the data is already held in memory, and there's no file in the file system corresponding to "filename".

        All the other attributes, like modification date, etc, can be added independently after.

        Alternatively, if the file name exists, you can use the BodypartFTBP(filename, true) method to set the standard values automatically.

        Throws:
        X400APIException
    • Method Detail

      • setFTBPSize

        public void setFTBPSize​(int size)
                         throws X400APIException
        Set the size (in bytes) of the FTBP
        Parameters:
        size - The size, in bytes, of the file
        Throws:
        X400APIException
      • getSize

        public int getSize()
        Returns the size (in bytes) of the file in the File Transfer Body Part, or -1 if the size cannot be calculated.
        Overrides:
        getSize in class Bodypart
      • setFileName

        public void setFileName​(java.lang.String filename)
                         throws X400APIException
        Set the name of the file attribute of the File Transfer Body Part
        Parameters:
        filename - Name of the file (doesn't have to contain the full path)
        Throws:
        X400APIException
      • getFileName

        public java.lang.String getFileName()
                                     throws X400APIException
        Returns the name of the file attribute of the File Transfer Body Part
        Throws:
        X400APIException
      • getStringRepresentation

        public java.lang.String getStringRepresentation()
        Returns the string of the File Transfer bodypart.

        The format of this string is suitable for informing the user about the forwarded message bodypart, but does not contain all the information.

      • setApplicationReference

        public void setApplicationReference​(java.lang.String appRefStr)
                                     throws X400APIException
        Set the application reference of the File Transfer Body Part
        Parameters:
        appRefStr - application reference string
        Throws:
        X400APIException
      • getApplicationReferenceString

        public java.lang.String getApplicationReferenceString()
                                                       throws X400APIException
        Returns the application reference of the File Transfer Body Part, as a String
        Throws:
        X400APIException
      • setApplicationReferenceOID

        public void setApplicationReferenceOID​(java.lang.String appRefOID)
                                        throws X400APIException
        Set the application reference OID of the File Transfer Body Part The value is a dotted decimal value.

        For example: the value "2.16.840.1.113694.2.2.1.1" corresponds to ID value registered by the Electronic Messaging Association (EMA) to represent the abstract-value 'generic-binary-attachment'

        Parameters:
        appRefOID - application reference OID
        Throws:
        X400APIException
      • getApplicationReferenceOID

        public java.lang.String getApplicationReferenceOID()
                                                    throws X400APIException
        Returns the application reference OID of the File Transfer Body Part The value is a dotted decimal value.

        For example: the value "2.16.840.1.113694.2.2.1.1" corresponds to ID value registered by the Electronic Messaging Association (EMA) to represent the abstract-value 'generic-binary-attachment'

        Throws:
        X400APIException
      • setContentDescription

        public void setContentDescription​(java.lang.String description)
                                   throws X400APIException
        Set the content description of the File Transfer Body Part
        Parameters:
        description - description
        Throws:
        X400APIException
      • getContentDescription

        public java.lang.String getContentDescription()
                                               throws X400APIException
        Returns the content description of the File Transfer Body Part
        Throws:
        X400APIException
      • setModificationDate

        public void setModificationDate​(java.lang.String md)
                                 throws X400APIException
        Set the modification date of the File Transfer Body Part
        Parameters:
        md - the file's modification date, encoded as a UTC time string
        Throws:
        X400APIException
      • getModificationDate

        public java.lang.String getModificationDate()
                                             throws X400APIException
        Returns the modification date of the File Transfer Body Part, encoded as a UTC time string
        Throws:
        X400APIException
      • setCreationDate

        public void setCreationDate​(java.lang.String cd)
                             throws X400APIException
        Set the creation date of the File Transfer Body Part, encoded as a UTC time string
        Parameters:
        cd - creation date
        Throws:
        X400APIException
      • getCreationDate

        public java.lang.String getCreationDate()
                                         throws X400APIException
        Returns the creation date of the File Transfer Body Part, encoded as a UTC time string
        Throws:
        X400APIException
      • setReadDate

        public void setReadDate​(java.lang.String rd)
                         throws X400APIException
        Set the read date of the File Transfer Body Part, encoded as a UTC time string
        Parameters:
        rd - read date
        Throws:
        X400APIException
      • getReadDate

        public java.lang.String getReadDate()
                                     throws X400APIException
        Returns the read date of the File Transfer Body Part, encoded as a UTC time string
        Throws:
        X400APIException
      • setBodyData

        public void setBodyData​(byte[] data)
                         throws X400APIException
        Set the data of the File Transfer Body Part as an array of bytes
        Parameters:
        data - Data to use for the FTBP
        Throws:
        X400APIException
      • getBodyData

        public byte[] getBodyData()
                           throws X400APIException
        Returns the data of the File Transfer Body Part as an array of bytes
        Throws:
        X400APIException
      • saveFTBPInDir

        public void saveFTBPInDir​(java.lang.String outputDir)
                           throws X400APIException
        Save the FTBP in the specified directory, the file name will be the one specified in the actual bodypart
        Parameters:
        outputDir -
        Throws:
        X400APIException