Class AttachmentTools


  • public class AttachmentTools
    extends java.lang.Object
    Utility methods to handle attachment relationships between files.
    • Constructor Summary

      Constructors 
      Constructor Description
      AttachmentTools()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      protected static java.lang.String createAttachmentName​(java.lang.String masterName, java.lang.String movedName, java.lang.String attachName)  
      static java.util.List createAttachments​(java.io.File master, java.io.File[] files, java.lang.String extensions)
      Create a list of File instances selected from the array of candidates that are recognized as attachments to file.
      static java.util.List createAttachments​(java.io.File master, java.lang.String extensions)
      Find all attachments to master.
      static void deleteAttachments​(java.util.List attachments)  
      static java.io.File moveAttachment​(java.io.File master, java.io.File attachment, java.io.File movedFile, boolean delete)  
      protected static java.io.File moveAttachment​(java.lang.String masterName, java.lang.Object attachment, java.lang.String movedName, java.io.File dir, boolean delete)  
      static java.util.List moveAttachments​(java.io.File master, java.util.List attachments, java.io.File movedFile, boolean delete)  
      • Methods inherited from class java.lang.Object

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

      • AttachmentTools

        public AttachmentTools()
    • Method Detail

      • createAttachmentName

        protected static java.lang.String createAttachmentName​(java.lang.String masterName,
                                                               java.lang.String movedName,
                                                               java.lang.String attachName)
      • createAttachments

        public static java.util.List createAttachments​(java.io.File master,
                                                       java.io.File[] files,
                                                       java.lang.String extensions)
        Create a list of File instances selected from the array of candidates that are recognized as attachments to file.

        The attachments are selected using a ";" separated list of suffixes (including the ".").

        A file is accepted as an attachment if it has an attachment suffix and the file base name is either the same as the target filename or target file base name.
        foo.bar foo.bar.suffix (accepted) foo.suffix (accepted) foo.txt (rejected)

        All checks are case insensitive.

        Parameters:
        master -
        files -
        extensions -
        Returns:
        a list of File instances selected from the array of candidates that are recognized as attachments to file.
      • createAttachments

        public static java.util.List createAttachments​(java.io.File master,
                                                       java.lang.String extensions)
        Find all attachments to master. Attachments are defined to be all files in the same directory as master that satisfy one of the extensions.
        Parameters:
        master -
        extensions -
        Returns:
        all attachments to master
      • deleteAttachments

        public static void deleteAttachments​(java.util.List attachments)
      • moveAttachment

        public static java.io.File moveAttachment​(java.io.File master,
                                                  java.io.File attachment,
                                                  java.io.File movedFile,
                                                  boolean delete)
      • moveAttachment

        protected static java.io.File moveAttachment​(java.lang.String masterName,
                                                     java.lang.Object attachment,
                                                     java.lang.String movedName,
                                                     java.io.File dir,
                                                     boolean delete)
                                              throws java.io.IOException
        Throws:
        java.io.IOException
      • moveAttachments

        public static java.util.List moveAttachments​(java.io.File master,
                                                     java.util.List attachments,
                                                     java.io.File movedFile,
                                                     boolean delete)