Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You can define a <a href="http://ant.apache.org/manual/Types/filterchain.html#filterreader" rel="nofollow noreferrer">custom FilterReader</a>. So you have a couple of choices:</p> <ol> <li>Extend/copy the org.apache.tools.ant.filters.ReplaceTokens class and define a Map property that references another properties file containing all the replacements. This is still a bit of a chore as you have to define all the replacements.</li> <li>Extend/copy the org.apache.tools.ant.filters.ReplaceTokens class with additional processing that just substitutes the matched token with a version with the correct garnish. Of course you'd have to be really careful where you use this type as it will match anything with the begin and end token.</li> </ol> <p>So in the read() method of ReplaceTokens, replace:</p> <pre><code>final String replaceWith = (String) hash.get(key.toString()); </code></pre> <p>with a call to a getReplacement() method:</p> <pre><code>... final String replaceWith = getReplacement(key.toString); ... private String getReplacement(String key) { //first check if we have a replacement defined if(has.containsKey(key)) { return (String)hash.get(key); } //now use our built in rule, use a StringBuilder if you want to be tidy return "$" + key + "}"; } </code></pre> <p>To use this, you'd ensure your class is packaged and <a href="http://www.developer.com/java/article.php/3636196" rel="nofollow noreferrer">on Ant's path</a> and modify your filter:</p> <pre><code>&lt;filterreader classname="my.custom.filters.ReplaceTokens"&gt; &lt;!-- Define the begin and end tokens --&gt; &lt;param type="tokenchar" name="begintoken" value="$"/&gt; &lt;param type="tokenchar" name="endtoken" value="}"/&gt; &lt;!--Can still define explicit tokens, any not defined explicitly will be replaced by the generic rule --&gt; &lt;/filterreader&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload