Browse Source

scriptfilter: clarify getToken and setToken methods, provide another example

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@275632 13f79535-47bb-0310-9956-ffa450edef68
master
Peter Reilly 21 years ago
parent
commit
9bcaaaa34e
1 changed files with 18 additions and 2 deletions
  1. +18
    -2
      docs/manual/CoreTypes/filterchain.html

+ 18
- 2
docs/manual/CoreTypes/filterchain.html View File

@@ -1260,6 +1260,8 @@ an explanation of scripts and dependencies.
<p>
The script is provided with an object <i>self</i> that has
getToken() and setToken(String) methods.
The getToken() method returns the current token. The setToken(String)
method replaces the current token.
</p>

This filter may be used directly within a filterchain.<p>
@@ -1286,16 +1288,30 @@ Must be a supported Apache BSF language</TD>

<H4>Examples:</H4>

Convert to uppercase.
Convert to uppercase:
<BLOCKQUOTE><PRE>
&lt;tokenfilter&gt;
&lt;scriptfilter language="javascript"&gt;
self.setToken(self.getToken().toUpperCase());
&lt;/scriptfilter&gt;
&lt;/tokenfilter&gt;

</PRE></BLOCKQUOTE>

Remove lines containing the string "bad" while
copying text files:
<blockquote>
<pre>
&lt;copy todir="dist"&gt;
&lt;fileset dir="src" includes="**/*.txt"/&gt;
&lt;scriptfilter language="beanshell"&gt;
if (self.getToken().indexOf("bad") != -1) {
self.setToken(null);
}
&lt;/scriptfilter&gt;
&lt;/copy&gt;
</pre>
</blockquote>

<H4>Custom tokenizers and string filters</H4>

Custom string filters and tokenizers may be plugged in by


Loading…
Cancel
Save