Class AttachmentCollection

    • Constructor Detail

      • AttachmentCollection

        public AttachmentCollection()
        Initializes a new instance of AttachmentCollection.
    • Method Detail

      • addFileAttachment

        public FileAttachment addFileAttachment​(String fileName)
        Adds a file attachment to the collection.
        Parameters:
        fileName - the file name
        Returns:
        A FileAttachment instance.
      • addFileAttachment

        public FileAttachment addFileAttachment​(String name,
                                                String fileName)
        Adds a file attachment to the collection.
        Parameters:
        name - accepts String display name of the new attachment.
        fileName - accepts String name of the file representing the content of the attachment.
        Returns:
        A FileAttachment instance.
      • addFileAttachment

        public FileAttachment addFileAttachment​(String name,
                                                InputStream contentStream)
        Adds a file attachment to the collection.
        Parameters:
        name - accepts String display name of the new attachment.
        contentStream - accepts InputStream stream from which to read the content of the attachment.
        Returns:
        A FileAttachment instance.
      • addFileAttachment

        public FileAttachment addFileAttachment​(String name,
                                                byte[] content)
        Adds a file attachment to the collection.
        Parameters:
        name - the name
        content - accepts byte byte arrays representing the content of the attachment.
        Returns:
        FileAttachment
      • addAttachment

        public Attachment addAttachment​(Attachment attachment)
        Adds a file attachment to the collection.
        Parameters:
        name - the name
        content - accepts byte byte arrays representing the content of the attachment.
        Returns:
        FileAttachment
      • clear

        public void clear()
        Removes all attachments from this collection.
      • removeAt

        public void removeAt​(int index)
        Removes the attachment at the specified index.
        Parameters:
        index - Index of the attachment to remove.
      • remove

        public boolean remove​(Attachment attachment)
                       throws Exception
        Removes the specified attachment.
        Parameters:
        attachment - The attachment to remove.
        Returns:
        True if the attachment was successfully removed from the collection, false otherwise.
        Throws:
        Exception - the exception
      • save

        public void save()
                  throws Exception
        Saves this collection by creating new attachment and deleting removed ones.
        Throws:
        Exception - the exception