com.ccg.macros.at
Class Strings

java.lang.Object
  extended by com.ccg.macros.at.Base
      extended by com.ccg.macros.at.Strings

public class Strings
extends Base

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.

Since:
1.0
Version:
$Revision: 1.1.1.1 $
Author:
$Author: pkb $

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

Strings

public Strings()
Constructs the object and readies it for installation.

Since:
1.0
See Also:
Base.install(com.ccg.macros.AtMacros)
Method Detail

javaEscape

public void javaEscape(Output out,
                       Vector args)
                throws IOException,
                       InterpretException
@javaEscape(TEXT) - create a Java "escape" string from a source string.

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.

Parameters:
out - The output device to write the results of processing the argument to.
args - A vector of arguments which were passed to the macro.
Throws:
IOException - If there is a problem writing to the output device
InterpretException - If a problem is encountered interpretting the arguments passed.
Since:
1.0

javaUnescape

public void javaUnescape(Output out,
                         Vector args)
                  throws IOException,
                         InterpretException
@javaUnescape(TEXT) - takes a "escaped" Java string and outputs the "unescaped" values.

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.

Parameters:
out - The output device to write the results of processing the argument to.
args - A vector of arguments which were passed to the macro.
Throws:
IOException - If there is a problem writing to the output device
InterpretException - If a problem is encountered interpretting the arguments passed.
Since:
1.0

replaceChar

public void replaceChar(Output out,
                        Vector args)
                 throws IOException,
                        InterpretException
@replaceChar(TEXT,OLDCHAR,NEWCHAR) - replace all occurances of one character with another.

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".

Parameters:
out - The output device to write the results of processing the argument to.
args - A vector of arguments which were passed to the macro.
Throws:
IOException - If there is a problem writing to the output device
InterpretException - If a problem is encountered interpretting the arguments passed.
Since:
1.0

indexOf

public void indexOf(Output out,
                    Vector args)
             throws IOException,
                    InterpretException
@indexOf(TEXT,SEARCH_IN) - searches for index of text string in larger string.

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")
 

Parameters:
out - The output device to write the results of processing the argument to.
args - A vector of arguments which were passed to the macro.
Throws:
IOException - If there is a problem writing to the output device
InterpretException - If a problem is encountered interpretting the arguments passed.
Since:
1.0

toOsFileName

public void toOsFileName(Output out,
                         Vector args)
                  throws IOException,
                         InterpretException
@toOsFileName(TEXT) - replace '/' or '\' characters in file names according to the OS preference.

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.

Parameters:
out - The output device to write the results of processing the argument to.
args - A vector of arguments which were passed to the macro.
Throws:
IOException - If there is a problem writing to the output device
InterpretException - If a problem is encountered interpretting the arguments passed.
Since:
1.0

changeCase

public void changeCase(Output out,
                       Vector args)
                throws IOException,
                       InterpretException
@changeCase(TEXT,MODE) - change the case of TEXT to uppercase, lowercase or mixed case.

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".

Parameters:
out - The output device to write the results of processing the argument to.
args - A vector of arguments which were passed to the macro.
Throws:
IOException - If there is a problem writing to the output device
InterpretException - If a problem is encountered interpretting the arguments passed.
Since:
1.0


Copyright 1998-1998-2006 null. All Rights Reserved.