|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.ccg.macros.at.Base
com.ccg.macros.at.Strings
public class Strings
General purpose "String" related macros.
This class defines many macros related to the processing of strings. This class is not typically used directly by Java developers, but indirectly when @macro processing text files.
| Constructor Summary | |
|---|---|
Strings()
Constructs the object and readies it for installation. |
|
| Method Summary | |
|---|---|
void |
changeCase(Output out,
Vector args)
@changeCase(TEXT,MODE) - change the case of TEXT to uppercase, lowercase or mixed case. |
void |
indexOf(Output out,
Vector args)
@indexOf(TEXT,SEARCH_IN) - searches for index of text string in larger string. |
void |
javaEscape(Output out,
Vector args)
@javaEscape(TEXT) - create a Java "escape" string from a source string. |
void |
javaUnescape(Output out,
Vector args)
@javaUnescape(TEXT) - takes a "escaped" Java string and outputs the "unescaped" values. |
void |
replaceChar(Output out,
Vector args)
@replaceChar(TEXT,OLDCHAR,NEWCHAR) - replace all occurances of one character with another. |
void |
toOsFileName(Output out,
Vector args)
@toOsFileName(TEXT) - replace '/' or '\' characters in file names according to the OS preference. |
| Methods inherited from class com.ccg.macros.at.Base |
|---|
getAtMacros, getDoubleParameter, getIntParameter, getLongParameter, getStringParameter, install |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public Strings()
installation.
Base.install(com.ccg.macros.AtMacros)| Method Detail |
|---|
public void javaEscape(Output out,
Vector args)
throws IOException,
InterpretException
This macro evaluates the TEXT argument and then puts in a Java escape code for each character that a escape code exists for (for example, a tab character would become "\t").
Refer to the JavaString class for additional details
on the recognized escape codes.
out - The output device to write the results of
processing the argument to.args - A vector of arguments which were passed to the macro.
IOException - If there is a problem writing to the output device
InterpretException - If a problem is encountered interpretting the arguments passed.
public void javaUnescape(Output out,
Vector args)
throws IOException,
InterpretException
This macro evaluates the TEXT argument and then replaces each Java escape code with its proper character (for example, a "\t" would become a REAL tab character).
Refer to the JavaString class for additional details
on the recognized escape codes.
out - The output device to write the results of
processing the argument to.args - A vector of arguments which were passed to the macro.
IOException - If there is a problem writing to the output device
InterpretException - If a problem is encountered interpretting the arguments passed.
public void replaceChar(Output out,
Vector args)
throws IOException,
InterpretException
This macro evaluates the TEXT argument passed and replaces ALL occurrences of the OLDCHAR with the NEWCHAR. For example, "@replaceChar("hello world"," ","_")" would result in "hello_world".
out - The output device to write the results of
processing the argument to.args - A vector of arguments which were passed to the macro.
IOException - If there is a problem writing to the output device
InterpretException - If a problem is encountered interpretting the arguments passed.
public void indexOf(Output out,
Vector args)
throws IOException,
InterpretException
This macro evaluates the TEXT argument passed and evaluates
the SEARCH_IN argument. It then uses the String.indexOf(String) method and returns th eposition
indicated. It is really useful to determine if one string contains
another as shown below:
@define("goodValues","megan|erik|scott")
@define("lookFor","erik")
@if("@indexOf("@lookFor()","@goodValues()")","-1","Not Found","Found")
out - The output device to write the results of
processing the argument to.args - A vector of arguments which were passed to the macro.
IOException - If there is a problem writing to the output device
InterpretException - If a problem is encountered interpretting the arguments passed.
public void toOsFileName(Output out,
Vector args)
throws IOException,
InterpretException
This macro is typically used when creating scripts. It takes a TEXT string and replaces any '/' or '\' characters found with the proper character for the Operating System's file naming scheme. For example, "/tmp\fred.txt" would become "/tmp/fred.txt" on a Unix system and "\tmp\fred.txt" on a Windows system.
NOTE: In the future, this macro may strip off any leading drive letter (like "c:" in the DOS world) if the output is for a Unix system.
out - The output device to write the results of
processing the argument to.args - A vector of arguments which were passed to the macro.
IOException - If there is a problem writing to the output device
InterpretException - If a problem is encountered interpretting the arguments passed.
public void changeCase(Output out,
Vector args)
throws IOException,
InterpretException
This macro is used to change the case of the specified TEXT. The MODE should be "u" if you want UPPER CASE, "l" if you want lower case, or "m" if you want "Mixed Case".
out - The output device to write the results of
processing the argument to.args - A vector of arguments which were passed to the macro.
IOException - If there is a problem writing to the output device
InterpretException - If a problem is encountered interpretting the arguments passed.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||