Class AttachmentTools

java.lang.Object
de.intarsys.tools.file.AttachmentTools

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

    • AttachmentTools

      public AttachmentTools()
  • Method Details

    • createAttachmentName

      protected static String createAttachmentName(String masterName, String movedName, String attachName)
    • createAttachments

      public static List createAttachments(File master, File[] files, 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 List createAttachments(File master, 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(List attachments)
    • moveAttachment

      public static File moveAttachment(File master, File attachment, File movedFile, boolean delete)
    • moveAttachment

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

      public static List moveAttachments(File master, List attachments, File movedFile, boolean delete)