Class JSONFile

    • Constructor Summary

      Constructors 
      Constructor Description
      JSONFile​(java.io.File root, java.io.File file, java.lang.String baseName)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void process​(java.util.ArrayList<java.io.File> includePath, java.util.ArrayList<IlibLocale> locales, java.util.HashMap<java.lang.String,​AssemblyFile> allFiles)
      Process the file to find all the dependencies on other files and on data.
      void writeDependencies​(java.io.Writer out, java.util.ArrayList<java.lang.String> visited, java.util.ArrayList<IlibLocale> locales)
      Write out the files that this file is dependent upon to the out writer, and recorded that the files have already been visited in the visited array.
      void writeParents​(java.io.Writer out, java.util.ArrayList<java.lang.String> visited, java.util.ArrayList<IlibLocale> locales)
      Write the dependencies for the farthest ancestors above the current node.
      • Methods inherited from class java.lang.Object

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

      • logger

        protected org.apache.log4j.Logger logger
      • baseName

        protected java.lang.String baseName
    • Constructor Detail

      • JSONFile

        public JSONFile​(java.io.File root,
                        java.io.File file,
                        java.lang.String baseName)
    • Method Detail

      • process

        public void process​(java.util.ArrayList<java.io.File> includePath,
                            java.util.ArrayList<IlibLocale> locales,
                            java.util.HashMap<java.lang.String,​AssemblyFile> allFiles)
                     throws java.lang.Exception
        Description copied from class: AssemblyFile
        Process the file to find all the dependencies on other files and on data. This method reads the file contents and searches for comments of the form "// @depends" or "/* @depends *\/". The contents of the comment with that form is a list of files that the current file depends upon. The includePath is a list of directories in which to search for the depended files. The path of a file that is depended upon should be listed as relative to one of the directories in the include path. This method adds all the files found to the allFile hash, mapping the file name to the assembly file instance. In the case where the file already exists in the allFiles hash because some other assembly file already depended upon it, then the dependency is stored, but the mapping is not added again to allFiles.
        Specified by:
        process in class AssemblyFile
        Parameters:
        includePath - a path to search for depended upon files
        allFiles - a hash where all the depended upon files are stored
        Throws:
        java.lang.Exception
      • writeParents

        public void writeParents​(java.io.Writer out,
                                 java.util.ArrayList<java.lang.String> visited,
                                 java.util.ArrayList<IlibLocale> locales)
                          throws java.lang.Exception
        Description copied from class: AssemblyFile
        Write the dependencies for the farthest ancestors above the current node. To get all the dependencies right, we start with any arbitrary node in the graph. From there, we traverse the parent links until we find a source node. That is, a node with no parents. From there, we do a depth-first search of the dependencies of that source until we get to a sink node. (A node with no dependencies.) Then, we write out that sink node and recurse back up. Each level writes out all its dependencies first, then itself and then returns to the previous level. We keep track of all the nodes we have already done so that if a subsequent depth first search hits a node that was already done, we can avoid doing that subtree more than once. Once all the dependencies of the source have been satisfied, we recurse back again to find other sources. Once all the parents for a node have been done, we attempt to do the dependencies for the current node if there are any left. This method is the one that traces the ancestry to the source node and then calls the writeDependencies call to actually write out the entire dependency tree from there.
        Specified by:
        writeParents in class AssemblyFile
        Parameters:
        out - a writer to write the files to
        visited - an array of paths to nodes that have already been visited
        locales - set of locales to generate data for
        Throws:
        CircularDependencyException - if there are any circular dependencies in the code
        java.lang.Exception
      • writeDependencies

        public void writeDependencies​(java.io.Writer out,
                                      java.util.ArrayList<java.lang.String> visited,
                                      java.util.ArrayList<IlibLocale> locales)
                               throws java.lang.Exception
        Description copied from class: AssemblyFile
        Write out the files that this file is dependent upon to the out writer, and recorded that the files have already been visited in the visited array.
        Specified by:
        writeDependencies in class AssemblyFile
        locales - set of locales to generate data for
        Throws:
        java.lang.Exception