org.apache.tools.ant.taskdefs

Class KeySubst


public class KeySubst
extends Task

Keyword substitution. Input file is written to output file. Do not make input file same as output file. Keywords in input files look like this: @foo@. See the docs for the setKeys method to understand how to do the substitutions.
Since:
Ant 1.1

Field Summary

Fields inherited from class org.apache.tools.ant.Task

description, location, target, taskName, taskType, wrapper

Fields inherited from class org.apache.tools.ant.ProjectComponent

project

Method Summary

void
execute()
Do the execution.
static void
main(String[] args)
static String
replace(String origString, Hashtable keys)
Does replacement on text using the hashtable of keys.
void
setDest(File dest)
Set the destination file.
void
setKeys(String keys)
Sets the keys.
void
setSep(String sep)
Sets the separator between name=value arguments in setKeys().
void
setSrc(File s)
Set the source file.

Methods inherited from class org.apache.tools.ant.Task

execute, getDescription, getLocation, getOwningTarget, getRuntimeConfigurableWrapper, getTaskName, getTaskType, getWrapper, handleErrorFlush, handleErrorOutput, handleFlush, handleInput, handleOutput, init, isInvalid, log, log, maybeConfigure, perform, reconfigure, setDescription, setLocation, setOwningTarget, setRuntimeConfigurableWrapper, setTaskName, setTaskType

Methods inherited from class org.apache.tools.ant.ProjectComponent

getProject, log, log, setProject

Method Details

execute

public void execute()
            throws BuildException
Do the execution.
Overrides:
execute in interface Task

main

public static void main(String[] args)

replace

public static String replace(String origString,
                             Hashtable keys)
            throws BuildException
Does replacement on text using the hashtable of keys.
Returns:
the string with the replacements in it.

setDest

public void setDest(File dest)
Set the destination file.

setKeys

public void setKeys(String keys)
Sets the keys. Format string is like this:

name=value*name2=value

Names are case sensitive.

Use the setSep() method to change the * to something else if you need to use * as a name or value.


setSep

public void setSep(String sep)
Sets the separator between name=value arguments in setKeys(). By default it is "*".

setSrc

public void setSrc(File s)
Set the source file.

Copyright B) 2000-2006 Apache Software Foundation. All Rights Reserved.