Package com.ilib.tools.jsa
Class AssemblyFile
- java.lang.Object
- 
- com.ilib.tools.jsa.AssemblyFile
 
- 
- 
Field SummaryFields Modifier and Type Field Description protected java.util.ArrayList<AssemblyFile>dependenciesprotected java.io.Filefileprotected java.util.ArrayList<AssemblyFile>parentsprotected java.io.Fileroot
 - 
Constructor SummaryConstructors Modifier Constructor Description protectedAssemblyFile(java.io.File root, java.io.File file)Construct a new assembly file instance.
 - 
Method SummaryAll Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidaddParent(AssemblyFile parent)Add a parent to the list of parents for this node.java.io.FilegetFile()Return the path to the current node's file in the file system.java.io.FilegetRoot()If this file was created from a relative path, this function returns the root directory that the relative path was relative to.booleanisProcessed()Return whether or not this file has been processed already for dependencies.booleanisWritten()Return whether or not this file has been written to the output yet.abstract 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.protected java.lang.StringBufferreadFile()Read a file into memory in the form of a StringBuffer and then return it.protected voidsetProcessed(boolean pro)Set the processed flag, which indicates that the file has been processed for dependencies already and does not need to be processed again.protected voidsetWritten(boolean wr)Set the written flag to true, which indicates that this file has been written to the output already and does not need to be written again.abstract 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.abstract 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.
 
- 
- 
- 
Field Detail- 
rootprotected java.io.File root 
 - 
fileprotected java.io.File file 
 - 
dependenciesprotected java.util.ArrayList<AssemblyFile> dependencies 
 - 
parentsprotected java.util.ArrayList<AssemblyFile> parents 
 
- 
 - 
Method Detail- 
getFilepublic java.io.File getFile() Return the path to the current node's file in the file system.- Returns:
- the path to the current node's file in the file system
 
 - 
getRootpublic java.io.File getRoot() If this file was created from a relative path, this function returns the root directory that the relative path was relative to.- Returns:
- the root path that this file is relative to
 
 - 
addParentpublic void addParent(AssemblyFile parent) Add a parent to the list of parents for this node.- Parameters:
- parent- node to add
 
 - 
setWrittenprotected void setWritten(boolean wr) Set the written flag to true, which indicates that this file has been written to the output already and does not need to be written again.- Parameters:
- wr- the value to set the written flag to
 
 - 
isWrittenpublic boolean isWritten() Return whether or not this file has been written to the output yet. If so, it should not be written again.- Returns:
- whether or not this file has been written to the output already
 
 - 
setProcessedprotected void setProcessed(boolean pro) Set the processed flag, which indicates that the file has been processed for dependencies already and does not need to be processed again.- Parameters:
- pro- the value to set the processed flag to
 
 - 
isProcessedpublic boolean isProcessed() Return whether or not this file has been processed already for dependencies.- Returns:
- whether or not this file has been processed already for dependencies.
 
 - 
readFileprotected java.lang.StringBuffer readFile() throws java.io.IOException, java.io.FileNotFoundExceptionRead a file into memory in the form of a StringBuffer and then return it.- Returns:
- a StringBuffer containing the contents of the file.
- Throws:
- java.io.IOException- if the file could not be read
- java.io.FileNotFoundException- if the file could not be opened
 
 - 
processpublic abstract 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.ExceptionProcess 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.- 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 abstract void writeParents(java.io.Writer out, java.util.ArrayList<java.lang.String> visited, java.util.ArrayList<IlibLocale> locales) throws java.lang.ExceptionWrite 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.- 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 abstract void writeDependencies(java.io.Writer out, java.util.ArrayList<java.lang.String> visited, java.util.ArrayList<IlibLocale> locales) throws java.lang.ExceptionWrite 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.- Parameters:
- out-
- visited-
- locales- set of locales to generate data for
- Throws:
- java.lang.Exception
 
 
- 
 
-