<replacetokens begintoken="#" endtoken="#"> <token key="DATE" value="${TODAY}"/> </replacetokens>Or:
<filterreader classname="org.apache.tools.ant.filters.ReplaceTokens"> <param type="tokenchar" name="begintoken" value="#"/> <param type="tokenchar" name="endtoken" value="#"/> <param type="token" name="DATE" value="${TODAY}"/> </filterreader>
Modifier and Type | Class and Description |
---|---|
public static class | ReplaceTokens.Token
Holds a token |
Modifier and Type | Field and Description |
---|---|
private String | beginToken
Character marking the beginning of a token. |
private static final String | DEFAULT_BEGIN_TOKEN
Default "begin token" character. |
private static final String | DEFAULT_END_TOKEN
Default "end token" character. |
private String | endToken
Character marking the end of a token. |
private Hashtable | hash
Hashtable to holds the original replacee-replacer pairs (String to String). |
private String | readBuffer
Used for comparisons and lookup into the resolvedTokens map. |
private String | replaceData
replacement test from a token |
private int | replaceIndex
Index into replacement data |
private final TreeMap | resolvedTokens
This map holds the "resolved" tokens (begin- and end-tokens are added to make searching simpler) |
private boolean |
Access | Constructor and Description |
---|---|
public | |
public | ReplaceTokens(final Reader
A Reader object providing the underlying stream.
Must not be in)null .Creates a new filtered reader. |
Modifier and Type | Method and Description |
---|---|
public void | addConfiguredToken(final ReplaceTokens.
The token to add to the map of replacements.
Must not be tokennull .Adds a token element to the map of tokens to replace. |
public Reader | Returns: a new filter based on this configuration, but filtering the specified readerA Reader object providing the underlying stream.
Must not be rdr)null .Implements org. |
private String | Returns: the character used to denote the beginning of a tokenReturns the "begin token" character. |
private String | Returns: the character used to denote the end of a tokenReturns the "end token" character. |
private int | Returns: the first character from the read buffer or -1 if read buffer is empty.
|
private Properties | getProperties(Resource
The resource to load properties from. resource)Returns properties from a specified properties file. |
private Hashtable | Returns: a map (String->String) of token keys to replacement valuesReturns the map of tokens which will be replaced. |
private void | |
private void | |
public int | Returns: the next character in the resulting stream, or -1 if the end of the resulting stream has been reachedOverrides java. |
public void | setBeginToken(final String
the character used to denote the beginning of a token beginToken)Sets the "begin token" character. |
public void | setEndToken(final String
the character used to denote the end of a token endToken)Sets the "end token" character. |
public void | setPropertiesResource(Resource
Resource r)A resource containing properties, each of which is interpreted as a token/value pair. |
private void |
beginToken | back to summary |
---|---|
private String beginToken Character marking the beginning of a token. |
DEFAULT_BEGIN_TOKEN | back to summary |
---|---|
private static final String DEFAULT_BEGIN_TOKEN Default "begin token" character. |
DEFAULT_END_TOKEN | back to summary |
---|---|
private static final String DEFAULT_END_TOKEN Default "end token" character. |
endToken | back to summary |
---|---|
private String endToken Character marking the end of a token. |
hash | back to summary |
---|---|
private Hashtable<String, String> hash Hashtable to holds the original replacee-replacer pairs (String to String). |
readBuffer | back to summary |
---|---|
private String readBuffer Used for comparisons and lookup into the resolvedTokens map. |
replaceData | back to summary |
---|---|
private String replaceData replacement test from a token |
replaceIndex | back to summary |
---|---|
private int replaceIndex Index into replacement data |
resolvedTokens | back to summary |
---|---|
private final TreeMap<String, String> resolvedTokens This map holds the "resolved" tokens (begin- and end-tokens are added to make searching simpler) |
resolvedTokensBuilt | back to summary |
---|---|
private boolean resolvedTokensBuilt |
ReplaceTokens | back to summary |
---|---|
public ReplaceTokens() Constructor for "dummy" instances.
|
ReplaceTokens | back to summary |
---|---|
public ReplaceTokens(final Reader in) Creates a new filtered reader.
|
addConfiguredToken | back to summary |
---|---|
public void addConfiguredToken(final ReplaceTokens. Adds a token element to the map of tokens to replace.
|
chain | back to summary |
---|---|
public Reader chain(final Reader rdr) Implements org. Creates a new ReplaceTokens using the passed in Reader for instantiation. |
getBeginToken | back to summary |
---|---|
private String getBeginToken() Returns the "begin token" character.
|
getEndToken | back to summary |
---|---|
private String getEndToken() Returns the "end token" character.
|
getFirstCharacterFromReadBuffer | back to summary |
---|---|
private int getFirstCharacterFromReadBuffer()
|
getProperties | back to summary |
---|---|
private Properties getProperties(Resource resource) Returns properties from a specified properties file.
|
getTokens | back to summary |
---|---|
private Hashtable Returns the map of tokens which will be replaced. |
initialize | back to summary |
---|---|
private void initialize() Initializes tokens and loads the replacee-replacer hashtable. |
makeTokensFromProperties | back to summary |
---|---|
private void makeTokensFromProperties(Resource r) |
read | back to summary |
---|---|
public int read() throws IOException Overrides java. Returns the next character in the filtered stream, replacing tokens from the original stream.
|
setBeginToken | back to summary |
---|---|
public void setBeginToken(final String beginToken) Sets the "begin token" character.
|
setEndToken | back to summary |
---|---|
public void setEndToken(final String endToken) Sets the "end token" character.
|
setPropertiesResource | back to summary |
---|---|
public void setPropertiesResource(Resource r) A resource containing properties, each of which is interpreted as a token/value pair.
|
setTokens | back to summary |
---|---|
private void setTokens(final Hashtable<String, String> hash) Sets the map of tokens to replace. |
Modifier and Type | Field and Description |
---|---|
private String | key
Token key |
private String | value
Token value |
Access | Constructor and Description |
---|---|
public |
Modifier and Type | Method and Description |
---|---|
public final String | |
public final String | |
public final void | |
public final void |
key | back to summary |
---|---|
private String key Token key |
value | back to summary |
---|---|
private String value Token value |
Token | back to summary |
---|---|
public Token() |
getKey | back to summary |
---|---|
public final String getKey() Returns the key for this token.
|
getValue | back to summary |
---|---|
public final String getValue() Returns the value for this token.
|
setKey | back to summary |
---|---|
public final void setKey(String key) Sets the token key
|
setValue | back to summary |
---|---|
public final void setValue(String value) Sets the token value
|