public class CodeGeneratorUtilities
extends java.lang.Object
| Red (cxh) |
| Green (cxh) |
| Constructor and Description |
|---|
CodeGeneratorUtilities() |
| Modifier and Type | Method and Description |
|---|---|
static java.util.HashMap<java.lang.String,java.lang.String> |
newMap(NamedObj namedObj)
Given a NamedObj, generate a HashMap containing String key/value
pairs where each key is a Variable contained in the namedObj
argument, and each value is the value of the Variable.
|
static java.io.BufferedReader |
openAsFileOrURL(java.lang.String inputFileName)
Given a string that names a file, URL or resource, try to
open as a file, and then as a URL, then as a resource.
|
static void |
substitute(java.io.BufferedReader inputFile,
java.util.Map<java.lang.String,java.lang.String> substituteMap,
java.lang.String outputFileName)
Read in the contents of inputFile, and replace each matching
String key found in substituteMap with the corresponding
String value and write the results to outputFileName.
|
static java.lang.String |
substitute(java.lang.String input,
java.util.Map<java.lang.String,java.lang.String> substituteMap)
Given a string and a Map containing String key/value pairs,
substitute any keys found in the input with the corresponding
values.
|
static void |
substitute(java.lang.String inputFileName,
java.util.Map<java.lang.String,java.lang.String> substituteMap,
java.lang.String outputFileName)
Read in the contents of inputFileName, and replace each
matching String key found in substituteMap with the
corresponding String value and write the results to
outputFileName.
|
static java.lang.String |
substitute(java.lang.String inputFileName,
NamedObj namedObj)
Read in the contents of inputFileName, and for each Parameter
in namedObj, search for strings like
@ParameterName@ in inputFileName, and
substitute in the value of the Parameter and return the results. |
public static java.util.HashMap<java.lang.String,java.lang.String> newMap(NamedObj namedObj) throws IllegalActionException
namedObj - The NamedObj that contains VariablesIllegalActionException - If there is a problem getting the
Variables.public static java.io.BufferedReader openAsFileOrURL(java.lang.String inputFileName)
throws java.io.FileNotFoundException,
java.io.IOException
inputFileName - The name of the file or URL to openjava.io.FileNotFoundException - If the file cannot be found.java.io.IOException - If there were problems creating
the BufferedReader.public static java.lang.String substitute(java.lang.String input,
java.util.Map<java.lang.String,java.lang.String> substituteMap)
input - The input string that contains substrings
like "@codeBase@". If the string "@help:all@" appears, then
all the key/value pairs are echoed.substituteMap - The Map of String keys like "@codeBase@"
and String values like "../../..".public static java.lang.String substitute(java.lang.String inputFileName,
NamedObj namedObj)
throws java.io.FileNotFoundException,
java.io.IOException
@ParameterName@ in inputFileName, and
substitute in the value of the Parameter and return the results.inputFileName - The name of the file to read from.namedObj - The NamedObj that contains Parameters to
be searched for in inputFileName.java.io.FileNotFoundException - If the input file cannot be found.java.io.IOException - If there is a problem creating the
substitution map.public static void substitute(java.io.BufferedReader inputFile,
java.util.Map<java.lang.String,java.lang.String> substituteMap,
java.lang.String outputFileName)
throws java.io.FileNotFoundException,
java.io.IOException
inputFile - A BufferedReader that refers to the file to be
read in. This BufferedReader is always closed by this method.substituteMap - The Map of String keys like "@codeBase@"
and String values like "../../..".outputFileName - The name of the file to write to.java.io.FileNotFoundException - If the input file cannot be found.java.io.IOException - If there is a problem creating the
substitution map.substitute(String, Map, String)public static void substitute(java.lang.String inputFileName,
java.util.Map<java.lang.String,java.lang.String> substituteMap,
java.lang.String outputFileName)
throws java.io.FileNotFoundException,
java.io.IOException
inputFileName - The name of the file to read from.substituteMap - The Map of String keys like "@codeBase@"
and String values like "../../..".outputFileName - The name of the file to write to.java.io.FileNotFoundException - If the input file cannot be found.java.io.IOException - If there is a problem creating the
substitution map.substitute(BufferedReader, Map, String)