Top Description Fields Constructors Methods
org.apache.tools.ant.taskdefs

public Class KeySubst

extends Task
Class Inheritance
Annotations
@Deprecated
Imports
java.io.BufferedReader, .BufferedWriter, .File, .FileReader, .FileWriter, .IOException, java.util.Hashtable, .StringTokenizer, org.apache.tools.ant.BuildException, .Project, .Task, org.apache.tools.ant.util.FileUtils, .StringUtils

Deprecated

KeySubst is deprecated since Ant 1.1. Use Filter + Copy instead.

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

Modifier and TypeField and Description
private File
private Hashtable<String, String>
private String
private File
Inherited from org.apache.tools.ant.Task:
targettaskNametaskTypewrapper

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
execute()

Overrides org.apache.tools.ant.Task.execute.

Do the execution.
public static void
main(String[]
not used
args
)

A test method.

public static String

Returns:

the string with the replacements in it.
replace
(String
an input string
origString
,
Hashtable<String, String>
mapping of keys to values
keys
)

Does replacement on text using the hashtable of keys.

public void
setDest(File
the destination file
dest
)

Set the destination file.

public void
setKeys(String
a String value
keys
)

Sets the keys.

public void
setSep(String
the separator string
sep
)

Sets the separator between name=value arguments in setKeys().

public void
setSrc(File
the source file
s
)

Set the source file.

Inherited from org.apache.tools.ant.Task:
bindToOwnergetOwningTargetgetRuntimeConfigurableWrappergetTaskNamegetTaskTypegetWrapperhandleErrorFlushhandleErrorOutputhandleFlushhandleInputhandleOutputinitisInvalidloglogloglogmaybeConfigureperformreconfiguresetOwningTargetsetRuntimeConfigurableWrappersetTaskNamesetTaskType

Field Detail

destback to summary
private File dest
replacementsback to summary
private Hashtable<String, String> replacements
sepback to summary
private String sep
sourceback to summary
private File source

Constructor Detail

KeySubstback to summary
public KeySubst()

Method Detail

executeback to summary
public void execute() throws BuildException

Overrides org.apache.tools.ant.Task.execute.

Do the execution.

Exceptions
BuildException:
on error
mainback to summary
public static void main(String[] args)

A test method.

Parameters
args:String[]

not used

replaceback to summary
public static String replace(String origString, Hashtable<String, String> keys) throws BuildException

Does replacement on text using the hashtable of keys.

Parameters
origString:String

an input string

keys:Hashtable<String, String>

mapping of keys to values

Returns:String

the string with the replacements in it.

Exceptions
BuildException:
on error
setDestback to summary
public void setDest(File dest)

Set the destination file.

Parameters
dest:File

the destination file

setKeysback to summary
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.

Parameters
keys:String

a String value

setSepback to summary
public void setSep(String sep)

Sets the separator between name=value arguments in setKeys(). By default it is "*".

Parameters
sep:String

the separator string

setSrcback to summary
public void setSrc(File s)

Set the source file.

Parameters
s:File

the source file