addListener
public void addListener(FileListener listener)
Add a listener to the file manager. This listener will receive calls
for each file created.
listener
- a new listener to be added.
createFile
public PrintWriter createFile(SymbolID id,
int type,
String groupname,
String filename)
throws CodeGenerationException
Create a file given a symbol ID, type, file group, and file name. The
return value is 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 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.
createWriter
public Writer createWriter(SymbolID id,
int type,
String groupname,
String filename)
throws CodeGenerationException
Create a file given a symbol, file group, and file name. The return
value is a 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 name
expandDirectory
public File expandDirectory(SymbolID id,
int type)
Generate the relative file name from the symbol ID.
If the symbol is not null and Java style package directories are
enabled, then the sidl package name of the symbol is converted into
a path name. Furthermore, if the root directory and/or the sub
directory is set, they are prepended to the path.
The resulting directory is not guaranteed to exist
in the filesystem.
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)
, and
setFileGenerationRootDirectory(null)
, and
expandGlueSubdir
public File expandGlueSubdir(SymbolID id,
File file)
expandLanguageSubdir
public File expandLanguageSubdir(SymbolID id,
File file,
String language)
expandStubMatlabDirectory
public File expandStubMatlabDirectory(SymbolID id,
int type,
String groupname)
Generate the relative Matlab file name from the symbol ID.
If the symbol is not null and Java style package directories are
enabled, then the sidl package name of the symbol is converted into
a path name with prefix @. Furthermore, if the root directory and/or the sub
directory is set, they are prepended to the path.
The resulting directory is not guaranteed to exist
in the filesystem.
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)
, and
setFileGenerationRootDirectory(null)
, and
expandVPathDirectory
public File expandVPathDirectory(SymbolID id,
int type)
Generate the VPATH for the symbol ID.
If the result is not null, then the resulting directory is guaranteed to exist.
The directory is constructed of the explicit VPATH with the package directories appended
only if Java style package directories are enabled.
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
- VPATH == Output Directory, or
- final directory does not exist.
getCodeSplicer
public CodeSplicer getCodeSplicer(SymbolID id,
int type,
String file,
boolean isSource,
boolean prependFullName)
throws IOException
Read the specified file and return a code splicer object representing
code splices from the file that should be preserved in the next file.
If the file does not exist, an CodeSplicer instance based on the business
rules defined by CodeSplicer is returned.
This will happen whenever code is generated for the first time.
If there is any other error reading the file data, an IOException
is thrown. There should be no need to check for null returns.
- valid (though possibly empty) CodeSplicer
getGlueSubdirGeneration
public boolean getGlueSubdirGeneration()
Get the current style of "glue" code generation.
getJavaStylePackageGeneration
public boolean getJavaStylePackageGeneration()
Get the current style of file generation, either all in one directory
or Java-style package directories.
removeListener
public void removeListener(FileListener listener)
Remove a listener from this file manager.
listener
- the listener to remove.
removeListeners
public void removeListeners(Collection listeners)
Remove a collection of listeners from this file manager.
listeners
- the listener collection to remove.
setFileGenerationRootDirectory
public void setFileGenerationRootDirectory(String directory)
throws CodeGenerationException
Change the root directory where files will be generated
to something other than the current working directory
directory
- String name of directory (relative or absolute)
if it's null, empty, or "." then current directory
is assumed.
setGlueSubdirGeneration
public 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.
setJavaStylePackageGeneration
public void setJavaStylePackageGeneration(boolean java_style)
Set the style of file generation, either all in one directory or
Java-style package directories. In the first case, all files are
stored in the same directory. In the second, files are stored in
package subdirectories that correspond to the sidl package structure.
The default is to use Java-style file generation.
setVPathDirectory
public void setVPathDirectory(String directory)
throws CodeGenerationException
Set the VPATH directory where files can be found
(notably IMPLS for CodeSplicers).
directory
- String name of directory ( relative or absolute).
If it's null, "", or "." then VPATH is disabled.