public class FileManager
extends java.lang.Object
FileManager
is a singleton class that manages the files
generated by the backend code generators. This class tracks what files
were generated and their "file group" for use in makefile generation.Constructor and Description |
---|
FileManager(Context context)
Create a new instance of the backend file manager object.
|
Modifier and Type | Method and Description |
---|---|
void |
addListener(FileListener listener)
Add a listener to the file manager.
|
java.io.PrintWriter |
createFile(SymbolID id,
int type,
java.lang.String groupname,
java.lang.String filename)
Create a file given a symbol ID, type, file group, and file name.
|
java.io.Writer |
createWriter(SymbolID id,
int type,
java.lang.String groupname,
java.lang.String filename)
Create a file given a symbol, file group, and file name.
|
java.io.File |
expandDirectory(SymbolID id,
int type)
Generate the relative file name from the symbol ID.
|
java.io.File |
expandGlueSubdir(SymbolID id,
java.io.File file) |
java.io.File |
expandLanguageSubdir(SymbolID id,
java.io.File file,
java.lang.String language) |
java.io.File |
expandStubMatlabDirectory(SymbolID id,
int type,
java.lang.String groupname)
Generate the relative Matlab file name from the symbol ID.
|
java.io.File |
expandVPathDirectory(SymbolID id,
int type)
Generate the VPATH for the symbol ID.
|
void |
fakeFileCreation(SymbolID id,
int type,
java.lang.String groupname,
java.lang.String filename) |
boolean |
fileExists(SymbolID id,
int type,
java.lang.String groupname,
java.lang.String filename) |
CodeSplicer |
getCodeSplicer(SymbolID id,
int type,
java.lang.String file,
boolean isSource,
boolean prependFullName)
Read the specified file and return a code splicer object representing
code splices from the file that should be preserved in the next file.
|
boolean |
getGlueSubdirGeneration()
Get the current style of "glue" code generation.
|
boolean |
getJavaStylePackageGeneration()
Get the current style of file generation, either all in one directory
or Java-style package directories.
|
void |
removeListener(FileListener listener)
Remove a listener from this file manager.
|
void |
removeListeners(java.util.Collection listeners)
Remove a collection of listeners from this file manager.
|
void |
setFileGenerationRootDirectory(java.lang.String directory)
Change the root directory where files will be generated
to something other than the current working directory
|
void |
setGlueSubdirGeneration(boolean glue_dir)
Set the style of file generation for impl and non-impl (ior, etc)
files, either all in one directory, or generating the "glue"
code (stubs, skels, ior) in a separate glue/ subdirectory.
|
void |
setJavaStylePackageGeneration(boolean java_style)
Set the style of file generation, either all in one directory or
Java-style package directories.
|
void |
setVPathDirectory(java.lang.String directory)
Set the VPATH directory where files can be found
(notably IMPLS for CodeSplicers).
|
public FileManager(Context context)
public void addListener(FileListener listener)
listener
- a new listener to be added.public void removeListener(FileListener listener)
listener
- the listener to remove.public void removeListeners(java.util.Collection listeners)
listeners
- the listener collection to remove.public boolean getJavaStylePackageGeneration()
public void setJavaStylePackageGeneration(boolean java_style)
public void setGlueSubdirGeneration(boolean glue_dir)
public boolean getGlueSubdirGeneration()
public void setVPathDirectory(java.lang.String directory) throws CodeGenerationException
directory
- String name of directory ( relative or absolute).
If it's null, "", or "." then VPATH is disabled.CodeGenerationException
public void setFileGenerationRootDirectory(java.lang.String directory) throws CodeGenerationException
directory
- String name of directory (relative or absolute)
if it's null, empty, or "." then current directory
is assumed.CodeGenerationException
public java.io.PrintWriter createFile(SymbolID id, int type, java.lang.String groupname, java.lang.String filename) throws CodeGenerationException
PrintWriter
stream that must be closed
by the caller when the file handle is no longer needed. The symbol is
used to expand the file path; it may be null if no expansion is
desired.id
- the file is associated with this symbol ID.type
- the symbol ID is of this type. This should be one
of the constants from
Type
.groupname
- the category this file belongs in.filename
- the file name.CodeGenerationException
public boolean fileExists(SymbolID id, int type, java.lang.String groupname, java.lang.String filename) throws CodeGenerationException
CodeGenerationException
public void fakeFileCreation(SymbolID id, int type, java.lang.String groupname, java.lang.String filename) throws CodeGenerationException
CodeGenerationException
public java.io.Writer createWriter(SymbolID id, int type, java.lang.String groupname, java.lang.String filename) throws CodeGenerationException
Writer
that will typically be used to
create a PrintWriter
stream that must be closed by the
caller when the file handle is no longer needed. The symbol is used
to expand the file path; it may be null if no expansion is desired.id
- the file being created is related to this symbol id.type
- this constant from
Type
indicates
the type of id.groupname
- the category this file belongs infilename
- the file nameCodeGenerationException
public CodeSplicer getCodeSplicer(SymbolID id, int type, java.lang.String file, boolean isSource, boolean prependFullName) throws java.io.IOException
java.io.IOException
public java.io.File expandDirectory(SymbolID id, int type)
id
- The symbol ID to generate files fortype
- The type of the symbol ID. This should be one of the
constants from Type
.java.io.File
representation for
the directory to generate the code. Can be null
if
setJavaStylePackageGeneration(false)
, andsetFileGenerationRootDirectory(null)
, andsetJavaStylePackageGeneration(boolean)
,
setFileGenerationRootDirectory(java.lang.String)
public java.io.File expandStubMatlabDirectory(SymbolID id, int type, java.lang.String groupname)
id
- The symbol ID to generate files fortype
- The type of the symbol ID. This should be one of the
constants from Type
.java.io.File
representation for
the directory to generate the code. Can be null
if
setJavaStylePackageGeneration(false)
, andsetFileGenerationRootDirectory(null)
, andsetJavaStylePackageGeneration(boolean)
,
setFileGenerationRootDirectory(java.lang.String)
public java.io.File expandLanguageSubdir(SymbolID id, java.io.File file, java.lang.String language)
public java.io.File expandGlueSubdir(SymbolID id, java.io.File file)
public java.io.File expandVPathDirectory(SymbolID id, int type)
id
- The symbol ID to generate files fortype
- The type of the symbol ID being generated. This should
be one of the constants from
Type
.java.io.File
representation for
the directory to generate the code. Can be null
if
setVPathDirectory(null)
, or
setJavaStylePackageGeneration(boolean)
,
setFileGenerationRootDirectory(java.lang.String)