Package de.intarsys.tools.file
Class AttachmentTools
java.lang.Object
de.intarsys.tools.file.AttachmentTools
Utility methods to handle attachment relationships between files.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected static String
createAttachmentName
(String masterName, String movedName, String attachName) static List
createAttachments
(File master, File[] files, String extensions) Create a list ofFile
instances selected from the array of candidates that are recognized as attachments tofile
.static List
createAttachments
(File master, String extensions) Find all attachments tomaster
.static void
deleteAttachments
(List attachments) static File
moveAttachment
(File master, File attachment, File movedFile, boolean delete) protected static File
moveAttachment
(String masterName, Object attachment, String movedName, File dir, boolean delete) static List
moveAttachments
(File master, List attachments, File movedFile, boolean delete)
-
Constructor Details
-
AttachmentTools
public AttachmentTools()
-
-
Method Details
-
createAttachmentName
-
createAttachments
Create a list ofFile
instances selected from the array of candidates that are recognized as attachments tofile
.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 tofile
.
-
createAttachments
Find all attachments tomaster
. Attachments are defined to be all files in the same directory asmaster
that satisfy one of theextensions
.- Parameters:
master
-extensions
-- Returns:
- all attachments to
master
-
deleteAttachments
-
moveAttachment
-
moveAttachment
protected static File moveAttachment(String masterName, Object attachment, String movedName, File dir, boolean delete) throws IOException - Throws:
IOException
-
moveAttachments
-