intarsys runtime library

de.intarsys.tools.file
Class FileAttachmentTools

java.lang.Object
  extended by de.intarsys.tools.file.FileAttachmentTools

public class FileAttachmentTools
extends Object

Utility methods to handle attachment relationships between files.


Constructor Summary
FileAttachmentTools()
           
 
Method Summary
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.
static List createAttachments(File master, String extensions)
          Find all attachments to master.
static void deleteAttachments(List attachments)
           
static File moveAttachment(File master, File attachment, File movedFile, boolean delete)
           
static File moveAttachment(File master, File attachment, File movedFile, boolean delete, boolean keepLastModified)
          Given the original master file and an attachment to this file, move the attachments to the correct location for the new master file location given in movedFile.
static List moveAttachments(File master, List attachments, File movedFile, boolean delete)
           
static List moveAttachments(File master, List attachments, File movedFile, boolean delete, boolean keepLastModified)
          Given the original master file and the list of attachments to this file, move all attachments to the correct location for the new master file location given in movedFile.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileAttachmentTools

public FileAttachmentTools()
Method Detail

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 file name 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)
                           throws IOException
Throws:
IOException

moveAttachment

public static File moveAttachment(File master,
                                  File attachment,
                                  File movedFile,
                                  boolean delete,
                                  boolean keepLastModified)
                           throws IOException
Given the original master file and an attachment to this file, move the attachments to the correct location for the new master file location given in movedFile.

If delete is true, old attachment files are deleted.

Parameters:
master -
attachment -
movedFile -
delete -
keepLastModified -
Returns:
The moved (or unchanged) attachment.
Throws:
IOException

moveAttachments

public static List moveAttachments(File master,
                                   List attachments,
                                   File movedFile,
                                   boolean delete)
                            throws IOException
Throws:
IOException

moveAttachments

public static List moveAttachments(File master,
                                   List attachments,
                                   File movedFile,
                                   boolean delete,
                                   boolean keepLastModified)
                            throws IOException
Given the original master file and the list of attachments to this file, move all attachments to the correct location for the new master file location given in movedFile.

If delete is true, old attachment files are deleted.

Parameters:
master -
attachments -
movedFile -
delete -
Returns:
The list of moved (or unchanged ) attachments
Throws:
IOException

intarsys runtime library

Copyright © 2012 intarsys consulting GmbH. All Rights Reserved.