Package com.ilib.tools.jsa
Class JSONFile
- java.lang.Object
- 
- com.ilib.tools.jsa.AssemblyFile
- 
- com.ilib.tools.jsa.JSONFile
 
 
- 
 public class JSONFile extends AssemblyFile 
- 
- 
Field SummaryFields Modifier and Type Field Description protected java.lang.StringbaseNameprotected org.apache.log4j.Loggerlogger- 
Fields inherited from class com.ilib.tools.jsa.AssemblyFiledependencies, file, parents, root
 
- 
 - 
Constructor SummaryConstructors Constructor Description JSONFile(java.io.File root, java.io.File file, java.lang.String baseName)
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description voidprocess(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.voidwriteDependencies(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.voidwriteParents(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 com.ilib.tools.jsa.AssemblyFileaddParent, getFile, getRoot, isProcessed, isWritten, readFile, setProcessed, setWritten
 
- 
 
- 
- 
- 
Method Detail- 
processpublic 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.ExceptionDescription copied from class:AssemblyFileProcess 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:
- processin 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
 
 - 
writeParentspublic void writeParents(java.io.Writer out, java.util.ArrayList<java.lang.String> visited, java.util.ArrayList<IlibLocale> locales) throws java.lang.ExceptionDescription copied from class:AssemblyFileWrite 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:
- writeParentsin 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
 
 - 
writeDependenciespublic void writeDependencies(java.io.Writer out, java.util.ArrayList<java.lang.String> visited, java.util.ArrayList<IlibLocale> locales) throws java.lang.ExceptionDescription copied from class:AssemblyFileWrite 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:
- writeDependenciesin class- AssemblyFile
- locales- set of locales to generate data for
- Throws:
- java.lang.Exception
 
 
- 
 
-