Class FileManager


  • public class FileManager
    extends java.lang.Object

    Singleton that handles holding references to JavaFiles. This allows Alexandria to lookup and see if a file has already been parsed out and then it can load the information from memory instead of reparsing the file.

    Note. This assumes that the file will not be modified on disk while Alexandria is running.

    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.lang.String encoding  
      private java.util.Map<java.nio.file.Path,​JavaFile> files  
    • Constructor Summary

      Constructors 
      Constructor Description
      FileManager()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addFile​(JavaFile file)
      Add a file to this file manager.
      java.lang.String getEncoding()
      Gets the encoding of source files.
      JavaFile getFile​(java.nio.file.Path path)
      Gets a file from its name.
      If the file does not exist within the FileManager, creates a new one and returns it.
      void setEncoding​(java.lang.String encoding)
      Sets the encoding of source files.
      • Methods inherited from class java.lang.Object

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

      • files

        private java.util.Map<java.nio.file.Path,​JavaFile> files
      • encoding

        private java.lang.String encoding
    • Constructor Detail

      • FileManager

        public FileManager()
    • Method Detail

      • getFile

        public JavaFile getFile​(java.nio.file.Path path)
                         throws java.io.IOException
        Gets a file from its name.
        If the file does not exist within the FileManager, creates a new one and returns it.
        Parameters:
        path - path of the file
        Returns:
        the JavaFile meta object for the specified file
        Throws:
        java.io.IOException - on parsing failure
      • addFile

        public void addFile​(JavaFile file)
        Add a file to this file manager.
        Parameters:
        file - file to add
      • setEncoding

        public void setEncoding​(java.lang.String encoding)
        Sets the encoding of source files.
        Parameters:
        encoding - encoding of source files
      • getEncoding

        public java.lang.String getEncoding()
        Gets the encoding of source files.
        Returns:
        encoding