|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--edu.umbc.cs.daml4jess.Macro
This utility class is designed to replace macros in any text as long as it conforms to the rules as specified as follow. For example, if you define HOMEPATH = /home/xyz, then you can use it as mypath = ${HOMEPATH}/bin. If you want to use the actual string ${...} itself and not as a macro reference, you should use another "$" (dollar sign) to escape, e.g, $${HOMEPATH}, in which case, HOMEPATH won't be expanded. More accurately, if you want the string "${" itself, it must be escaped. Note that '$' is not a general escape character here and is interpreted as an escape char if and only if it is in a sequence of '$' that appear before a macro definition openning string "${". For example, if a = "xy", then ${a} = "xy", $${a} = "$${a}" (escaped), $$${a} = $xy, $$$${a} = "$${a}" (escaped), $$$$$${a} = "$$xy". For now, it does not support nested macro definitions. It saves a copy of the original file with extension "._old".
Nested Class Summary | |
static class |
Macro.MacroException
The macro error exception. |
Constructor Summary | |
Macro(java.util.Properties macroDefs)
Constructor. |
Method Summary | |
static void |
main(java.lang.String[] args)
main program, testing only. |
boolean |
resolveMacros(java.lang.String fileName)
Resolve the macro references in the given text file. |
java.lang.String |
resolveMacros(java.lang.String data,
int lineNo)
Resolve the macro in the given text data. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public Macro(java.util.Properties macroDefs)
macroDefs
- the macro definitions, in Java proeprties format.Method Detail |
public boolean resolveMacros(java.lang.String fileName)
fileName
- the input file.
public java.lang.String resolveMacros(java.lang.String data, int lineNo) throws java.io.IOException, Macro.MacroException
data
- the data that may contain macros.lineNo
- the current line number. Used for error reporting.
java.io.IOException
Macro.MacroException
public static void main(java.lang.String[] args) throws java.lang.Exception
java.lang.Exception
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |