Class AssociatedFilesManager


  • public class AssociatedFilesManager
    extends java.lang.Object
    Manager class to deal with associated files
    • Constructor Detail

      • AssociatedFilesManager

        public AssociatedFilesManager()
    • Method Detail

      • getInstance

        public static AssociatedFilesManager getInstance()
        returns the singleton instance
        Returns:
        the singleton instance
      • getFiles

        public java.util.Set<java.io.File> getFiles​(java.io.File file)
        Retrieve all associated files of the File
        Parameters:
        file - the File. It must not be a directory
        Returns:
        All associated files of the File
      • addFile

        public java.io.File addFile​(java.io.File file,
                                    java.io.File associatedFile,
                                    boolean replace)
                             throws java.io.IOException
        Add a associated File to a File. If the provided File is not in the correct directory, the file is moved into correct directory and rename if replace is false.
        Parameters:
        file - the File. It must not be a directory
        associatedFile - the File
        replace - true if a associated file with the same name should be overwrite or not
        Returns:
        the moved and/or renamed File
        Throws:
        java.io.IOException - Exception if any problem on file
      • addFile

        public java.io.File addFile​(java.io.File file,
                                    java.io.File associatedFile)
                             throws java.io.IOException
        Add a associated File to a File. If the provided File is not in the correct directory, the file is moved into correct directory and rename if needed.
        Parameters:
        file - the File. It must not be a directory
        associatedFile - the File
        Returns:
        the moved and/or renamed File
        Throws:
        java.io.IOException - Exception if any problem on file
      • addFile

        public java.io.File addFile​(java.io.File file,
                                    java.lang.String associatedFilename)
                             throws java.io.IOException
        Add a associated File to a File. If the File already exists in associated directory, it will be overwrite.
        Parameters:
        file - the File. It must not be a directory
        associatedFilename - the file name
        Returns:
        the associated File
        Throws:
        java.io.IOException - Exception if any problem on file
      • addFile

        public java.io.File addFile​(java.io.File file,
                                    java.lang.String associatedFilename,
                                    boolean replace)
                             throws java.io.IOException
        Add a associated File to a File.
        Parameters:
        file - the File. It must not be a directory
        associatedFilename - the file name
        replace - true if a associated file with the same name should be overwrite or not
        Returns:
        the associated File
        Throws:
        java.io.IOException - Exception if any problem on file
      • removeFile

        public void removeFile​(java.io.File file,
                               java.lang.String filename)
        Remove File associated to a File
        Parameters:
        file - the File. It must not be a directory
        filename - the name of the associated file
      • removeFile

        public void removeFile​(java.io.File file,
                               java.io.File associatedFile)
        Remove File associated to a File
        Parameters:
        file - the File. It must not be a directory
        associatedFile - the associated File
      • getAssociatedFile

        public java.io.File getAssociatedFile​(java.io.File file,
                                              java.lang.String filename)
        Returns the File associated with a File with provided name
        Parameters:
        file - the File
        filename - the name of the associated associatedFile
        Returns:
        the File associated with a File with provided name
      • getAssociatedDirectory

        public java.io.File getAssociatedDirectory​(FileDocument fileDoc)
        Returns the File which is the directory in which associated files are stored
        Parameters:
        fileDoc - the FileDocument
        Returns:
        the File which is the directory in which associated files are stored
      • getAssociatedDirectory

        public java.io.File getAssociatedDirectory​(java.io.File file)
        Returns the File which is the directory in which associated files are stored
        Parameters:
        file - the File
        Returns:
        the File which is the directory in which associated files are stored
      • getAssociatedDirectory

        public java.io.File getAssociatedDirectory​(java.io.File file,
                                                   boolean createMissingDir)
        Returns the File which is the directory in which associated files are stored
        Parameters:
        file - the File
        createMissingDir - true if the directory should be created
        Returns:
        the File which is the directory in which associated files are stored
      • fireAddEvent

        public void fireAddEvent​(java.io.File file,
                                 java.io.File associatedFile)
      • fireDeleteEvent

        public void fireDeleteEvent​(java.io.File file,
                                    java.io.File associatedFile)
      • fireUpdateEvent

        public void fireUpdateEvent​(java.io.File file,
                                    java.io.File associatedFile)
      • removeAllAssociatedFilesEventListener

        public void removeAllAssociatedFilesEventListener()
      • deleteAllAssociatedFile

        public void deleteAllAssociatedFile​(java.io.File fileDocument)
                                     throws java.io.IOException
        Throws:
        java.io.IOException
      • getFile

        public java.io.File getFile​(java.io.File file,
                                    java.lang.String filename)
      • getOriginatedFile

        public java.io.File getOriginatedFile​(java.io.File file)