public class MOOSEFileHandler extends java.lang.Object implements IReader, IWriter
This class reads and writes MOOSE Blocks and Parameters to and from the different MOOSE file types, including parsing from YAML and writing to GetPot.
There are two primary types of files associated with MOOSE: the YAML file used to specify the possible configuration of an input file and the input file itself, which is a GetPot/Perl configuration file.
This class realizes the IComponentVisitor interface to find DataComponents in the TreeComposites that can be converted into a parameter set for a MOOSE input block. If there are other Components in a TreeComposite. They are completely ignored.
Blocks and YAMLBlocks are used because each block needs to be converted to or from a TreeComposite. This is complicated in the case of loading the YAML input specification because it is a *specification* (or schema) and not the input itself. The nodes of this tree are what could be configured, not what is, so they must be setup as child exemplars on a TreeComposite.
Constructor and Description |
---|
MOOSEFileHandler() |
Modifier and Type | Method and Description |
---|---|
void |
dumpInputFile(java.lang.String filePath,
java.util.ArrayList<TreeComposite> blockSet)
This operation writes a set of MOOSE blocks to the specified file path.
|
java.util.ArrayList<Entry> |
findAll(org.eclipse.core.resources.IFile file,
java.lang.String regex)
This realization of IReader.findAll() reads a Form in from the given file
reference and walks the corresponding TreeComposite for occurrences of
the given regular expression.
|
java.lang.String |
getReaderType()
Return the Reader type String that the IOService can use as a key in its
IReader mapping.
|
java.lang.String |
getWriterType()
Return the Writer type String that the IOService can use as a key in its
IWriter mapping.
|
java.util.ArrayList<java.lang.String> |
loadActionSyntax(java.lang.String filePath)
This method is responsible for loading the action syntax file associated
with a MOOSE app.
|
java.util.ArrayList<TreeComposite> |
loadFromGetPot(java.lang.String filePath)
This operations loads a MOOSE GetPot file at the specified path and
returns a fully-configured set of ICE TreeComposites.
|
java.util.ArrayList<TreeComposite> |
loadYAML(java.lang.String filePath)
This operations loads a MOOSE YAML file at the specified path and returns
a fully-configured set of ICE TreeComposites.
|
Form |
read(org.eclipse.core.resources.IFile file)
This realization of IReader.read() takes the given file reference, gets
its file extension, and calls the appropriate routines to either load a
MOOSE input file or a MOOSE YAML specification.
|
void |
replace(org.eclipse.core.resources.IFile file,
java.lang.String regex,
java.lang.String value)
This method provides clients with a basic search and replace
functionality.
|
void |
write(Form formToWrite,
org.eclipse.core.resources.IFile file)
This realization of IWriter.write() gets a valid TreeComposite from the
provided Form and writes it to the given file reference as a valid MOOSE
*.i input file.
|
public void dumpInputFile(java.lang.String filePath, java.util.ArrayList<TreeComposite> blockSet)
filePath
- The file path to which the MOOSE blocks should be dumped. If
the path is null or empty, the operation returns without doing
any work.blockSet
- The collection of TreeComposites that represent MOOSE blocks
to be dumped to the file. The TreeComposites should only
contain a single DataComponent, id = 1, and other
TreeComposites. Any other components in the TreeComposite will
be ignored.public java.util.ArrayList<TreeComposite> loadFromGetPot(java.lang.String filePath)
filePath
- The file path from which the MOOSE blocks written in GetPot
should be read. If the path is null or empty, the operation
returns without doing any work.public java.util.ArrayList<TreeComposite> loadYAML(java.lang.String filePath) throws java.io.IOException
filePath
- The file path from which the MOOSE blocks written in YAML
should be read. If the path is null or empty, the operation
returns without doing any work.java.io.IOException
public java.util.ArrayList<java.lang.String> loadActionSyntax(java.lang.String filePath) throws java.io.IOException
filePath
- The file path pointing to the action syntax filejava.io.IOException
public void write(Form formToWrite, org.eclipse.core.resources.IFile file)
public void replace(org.eclipse.core.resources.IFile file, java.lang.String regex, java.lang.String value)
IWriter
public java.lang.String getWriterType()
getWriterType
in interface IWriter
public Form read(org.eclipse.core.resources.IFile file)
public java.util.ArrayList<Entry> findAll(org.eclipse.core.resources.IFile file, java.lang.String regex)
public java.lang.String getReaderType()
getReaderType
in interface IReader