Class BodypartFTBP

java.lang.Object
com.isode.x400.highlevel.Bodypart
com.isode.x400.highlevel.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 Details

    • 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(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(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(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 Details

    • 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(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 String getFileName() throws X400APIException
      Returns the name of the file attribute of the File Transfer Body Part
      Throws:
      X400APIException
    • getStringRepresentation

      public 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(String appRefStr) throws X400APIException
      Set the application reference of the File Transfer Body Part
      Parameters:
      appRefStr - application reference string
      Throws:
      X400APIException
    • getApplicationReferenceString

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

      public void setApplicationReferenceOID(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 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(String description) throws X400APIException
      Set the content description of the File Transfer Body Part
      Parameters:
      description - description
      Throws:
      X400APIException
    • getContentDescription

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

      public void setModificationDate(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 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(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 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(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 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(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