Class FileManager


  • public class FileManager
    extends java.lang.Object
    A file manager that provides standard functionalities for communicating with the file system.
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static interface  FileManager.WriteAction
      A functional interface for a write operation that can throw IOExceptions.
    • Constructor Summary

      Constructors 
      Constructor Description
      FileManager​(java.lang.String workdir)
      Builds a new manager that will produce files in the given workdir.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.util.Collection<java.lang.String> createdFiles()
      Yields the collection of file names that have been created by this manager.
      static void forceDeleteFolder​(java.lang.String path)
      Deletes a folder with all of its contents if it exists.
      void generateSupportFiles()
      Generates, inside the working directory, all supporting files needed for correct visualization of dumped files.
      void mkDotFile​(java.lang.String name, FileManager.WriteAction filler)
      Creates a UTF-8 encoded file with the given name, appending the dot extension.
      void mkGraphmlFile​(java.lang.String name, FileManager.WriteAction filler)
      Creates a UTF-8 encoded file with the given name, appending the graphml extension.
      void mkHtmlFile​(java.lang.String name, FileManager.WriteAction filler)
      Creates a UTF-8 encoded file with the given name, appending the html extension.
      void mkJsonFile​(java.lang.String name, FileManager.WriteAction filler)
      Creates a UTF-8 encoded file with the given name, appending the json extension.
      void mkOutputFile​(java.lang.String name, boolean bom, FileManager.WriteAction filler)
      Creates a UTF-8 encoded file with the given name.
      void mkOutputFile​(java.lang.String name, FileManager.WriteAction filler)
      Creates a UTF-8 encoded file with the given name.
      void mkOutputFile​(java.lang.String path, java.lang.String name, boolean bom, FileManager.WriteAction filler)
      Creates a UTF-8 encoded file with the given name.
      void mkOutputFile​(java.lang.String path, java.lang.String name, FileManager.WriteAction filler)
      Creates a UTF-8 encoded file with the given name.
      void usedCompoundCytoscape()
      Takes note that the at least one of the dumped files needs cytoscape support for compund graphs to be correctly visualized.
      void usedPlainCytoscape()
      Takes note that the at least one of the dumped files needs cytoscape support for non-compund graphs to be correctly visualized.
      • Methods inherited from class java.lang.Object

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

      • FileManager

        public FileManager​(java.lang.String workdir)
        Builds a new manager that will produce files in the given workdir.
        Parameters:
        workdir - the path to the directory where files will be created by this manager
    • Method Detail

      • createdFiles

        public java.util.Collection<java.lang.String> createdFiles()
        Yields the collection of file names that have been created by this manager.
        Returns:
        the names of the created files
      • usedCompoundCytoscape

        public void usedCompoundCytoscape()
        Takes note that the at least one of the dumped files needs cytoscape support for compund graphs to be correctly visualized. This will have an effect on the files produced by generateSupportFiles().
      • usedPlainCytoscape

        public void usedPlainCytoscape()
        Takes note that the at least one of the dumped files needs cytoscape support for non-compund graphs to be correctly visualized. This will have an effect on the files produced by generateSupportFiles().
      • mkOutputFile

        public void mkOutputFile​(java.lang.String name,
                                 FileManager.WriteAction filler)
                          throws java.io.IOException
        Creates a UTF-8 encoded file with the given name. If name is a path, all missing directories will be created as well. The given name will be joined with the workdir used to initialize this file manager, thus raising an exception if name is absolute. filler will then be used to write to the writer.
        Parameters:
        name - the name of the file to create
        filler - the callback to write to the file
        Throws:
        java.io.IOException - if something goes wrong while creating the file
      • mkOutputFile

        public void mkOutputFile​(java.lang.String path,
                                 java.lang.String name,
                                 FileManager.WriteAction filler)
                          throws java.io.IOException
        Creates a UTF-8 encoded file with the given name. If name is a path, all missing directories will be created as well. The given name will be joined with the workdir used to initialize this file manager, thus raising an exception if name is absolute. filler will then be used to write to the writer.
        Parameters:
        path - the sub-path, relative to the workdir, where the file should be created
        name - the name of the file to create
        filler - the callback to write to the file
        Throws:
        java.io.IOException - if something goes wrong while creating the file
      • mkDotFile

        public void mkDotFile​(java.lang.String name,
                              FileManager.WriteAction filler)
                       throws java.io.IOException
        Creates a UTF-8 encoded file with the given name, appending the dot extension. The name will be stripped of any characters that might cause problems in the file name. The given name will be joined with the workdir used to initialize this file manager, thus raising an exception if name is absolute. filler will then be used to write to the writer.
        Parameters:
        name - the name of the file to create
        filler - the callback to write to the file
        Throws:
        java.io.IOException - if something goes wrong while creating the file
      • mkJsonFile

        public void mkJsonFile​(java.lang.String name,
                               FileManager.WriteAction filler)
                        throws java.io.IOException
        Creates a UTF-8 encoded file with the given name, appending the json extension. The name will be stripped of any characters that might cause problems in the file name. The given name will be joined with the workdir used to initialize this file manager, thus raising an exception if name is absolute. filler will then be used to write to the writer.
        Parameters:
        name - the name of the file to create
        filler - the callback to write to the file
        Throws:
        java.io.IOException - if something goes wrong while creating the file
      • mkGraphmlFile

        public void mkGraphmlFile​(java.lang.String name,
                                  FileManager.WriteAction filler)
                           throws java.io.IOException
        Creates a UTF-8 encoded file with the given name, appending the graphml extension. The name will be stripped of any characters that might cause problems in the file name. The given name will be joined with the workdir used to initialize this file manager, thus raising an exception if name is absolute. filler will then be used to write to the writer.
        Parameters:
        name - the name of the file to create
        filler - the callback to write to the file
        Throws:
        java.io.IOException - if something goes wrong while creating the file
      • mkHtmlFile

        public void mkHtmlFile​(java.lang.String name,
                               FileManager.WriteAction filler)
                        throws java.io.IOException
        Creates a UTF-8 encoded file with the given name, appending the html extension. The name will be stripped of any characters that might cause problems in the file name. The given name will be joined with the workdir used to initialize this file manager, thus raising an exception if name is absolute. filler will then be used to write to the writer.
        Parameters:
        name - the name of the file to create
        filler - the callback to write to the file
        Throws:
        java.io.IOException - if something goes wrong while creating the file
      • mkOutputFile

        public void mkOutputFile​(java.lang.String name,
                                 boolean bom,
                                 FileManager.WriteAction filler)
                          throws java.io.IOException
        Creates a UTF-8 encoded file with the given name. If name is a path, all missing directories will be created as well. The given name will be joined with the workdir used to initialize this file manager, thus raising an exception if name is absolute. filler will then be used to write to the writer.
        Parameters:
        name - the name of the file to create
        bom - if true, the bom marker  will be written to the file
        filler - the callback to write to the file
        Throws:
        java.io.IOException - if something goes wrong while creating or writing to the file
      • mkOutputFile

        public void mkOutputFile​(java.lang.String path,
                                 java.lang.String name,
                                 boolean bom,
                                 FileManager.WriteAction filler)
                          throws java.io.IOException
        Creates a UTF-8 encoded file with the given name. If name is a path, all missing directories will be created as well. The given name will be joined with the workdir used to initialize this file manager, thus raising an exception if name is absolute. filler will then be used to write to the writer.
        Parameters:
        path - the sub-path, relative to the workdir, where the file should be created
        name - the name of the file to create
        bom - if true, the bom marker  will be written to the file
        filler - the callback to write to the file
        Throws:
        java.io.IOException - if something goes wrong while creating or writing to the file
      • forceDeleteFolder

        public static void forceDeleteFolder​(java.lang.String path)
                                      throws java.io.IOException
        Deletes a folder with all of its contents if it exists.
        Parameters:
        path - the path to the folder
        Throws:
        java.io.IOException - if an error happens while deleting
      • generateSupportFiles

        public void generateSupportFiles()
                                  throws java.io.IOException
        Generates, inside the working directory, all supporting files needed for correct visualization of dumped files. The generated files depend on the which of the usedX methods exposed by this class have been invoked.
        Throws:
        java.io.IOException - if an error happens during the generation