org.apache.tools.ant.filters

Class TokenFilter

public class TokenFilter extends BaseFilterReader implements ChainableReader

This splits up input into tokens and passes the tokens to a sequence of filters.

Since: Ant 1.6

See Also: BaseFilterReader ChainableReader DynamicConfigurator

Nested Class Summary
abstract static classTokenFilter.ChainableReaderFilter
Abstract class that converts derived filter classes into ChainableReaderFilter's
static classTokenFilter.ContainsRegex
filter to filter tokens matching regular expressions.
static classTokenFilter.ContainsString
Simple filter to filter lines contains strings
static classTokenFilter.DeleteCharacters
Filter to delete characters
static classTokenFilter.FileTokenizer
class to read the complete input into a string
interfaceTokenFilter.Filter
string filters implement this interface
static classTokenFilter.IgnoreBlank
Filter remove empty tokens
static classTokenFilter.ReplaceRegex
filter to replace regex.
static classTokenFilter.ReplaceString
Simple replace string filter.
static classTokenFilter.StringTokenizer
class to tokenize the input as areas separated by white space, or by a specified list of delim characters.
static classTokenFilter.Trim
Filter to trim white space
Constructor Summary
TokenFilter()
Constructor for "dummy" instances.
TokenFilter(Reader in)
Creates a new filtered reader.
Method Summary
voidadd(Tokenizer tokenizer)
add an arbitrary tokenizer
voidadd(TokenFilter.Filter filter)
Add an arbitrary filter
voidaddContainsRegex(TokenFilter.ContainsRegex filter)
contains regex filter
voidaddContainsString(TokenFilter.ContainsString filter)
contains string filter
voidaddDeleteCharacters(TokenFilter.DeleteCharacters filter)
delete chars
voidaddFileTokenizer(TokenFilter.FileTokenizer tokenizer)
add a file tokenizer
voidaddIgnoreBlank(TokenFilter.IgnoreBlank filter)
ignore blank filter
voidaddLineTokenizer(LineTokenizer tokenizer)
add a line tokenizer - this is the default.
voidaddReplaceRegex(TokenFilter.ReplaceRegex filter)
replace regex filter
voidaddReplaceString(TokenFilter.ReplaceString filter)
replace string filter
voidaddStringTokenizer(TokenFilter.StringTokenizer tokenizer)
add a string tokenizer
voidaddTrim(TokenFilter.Trim filter)
trim filter
Readerchain(Reader reader)
Creates a new TokenFilter using the passed in Reader for instantiation.
static intconvertRegexOptions(String flags)
convert regex option flag characters to regex options
  • g - Regexp.REPLACE_ALL
  • i - Regexp.MATCH_CASE_INSENSITIVE
  • m - Regexp.MATCH_MULTILINE
  • s - Regexp.MATCH_SINGLELINE
  • intread()
    Returns the next character in the filtered stream, only including lines from the original stream which match all of the specified regular expressions.
    static StringresolveBackSlash(String input)
    xml does not do "c" like interpretation of strings. i.e.
    voidsetDelimOutput(String delimOutput)
    set the output delimiter.

    Constructor Detail

    TokenFilter

    public TokenFilter()
    Constructor for "dummy" instances.

    See Also: BaseFilterReader

    TokenFilter

    public TokenFilter(Reader in)
    Creates a new filtered reader.

    Parameters: in A Reader object providing the underlying stream. Must not be null.

    Method Detail

    add

    public void add(Tokenizer tokenizer)
    add an arbitrary tokenizer

    Parameters: tokenizer the tokenizer to all, only one allowed

    add

    public void add(TokenFilter.Filter filter)
    Add an arbitrary filter

    Parameters: filter the filter to add

    addContainsRegex

    public void addContainsRegex(TokenFilter.ContainsRegex filter)
    contains regex filter

    Parameters: filter the contains regex filter

    addContainsString

    public void addContainsString(TokenFilter.ContainsString filter)
    contains string filter

    Parameters: filter the contains string filter

    addDeleteCharacters

    public void addDeleteCharacters(TokenFilter.DeleteCharacters filter)
    delete chars

    Parameters: filter the delete characters filter

    addFileTokenizer

    public void addFileTokenizer(TokenFilter.FileTokenizer tokenizer)
    add a file tokenizer

    Parameters: tokenizer the file tokenizer

    addIgnoreBlank

    public void addIgnoreBlank(TokenFilter.IgnoreBlank filter)
    ignore blank filter

    Parameters: filter the ignore blank filter

    addLineTokenizer

    public void addLineTokenizer(LineTokenizer tokenizer)
    add a line tokenizer - this is the default.

    Parameters: tokenizer the line tokenizer

    addReplaceRegex

    public void addReplaceRegex(TokenFilter.ReplaceRegex filter)
    replace regex filter

    Parameters: filter the replace regex filter

    addReplaceString

    public void addReplaceString(TokenFilter.ReplaceString filter)
    replace string filter

    Parameters: filter the replace string filter

    addStringTokenizer

    public void addStringTokenizer(TokenFilter.StringTokenizer tokenizer)
    add a string tokenizer

    Parameters: tokenizer the string tokenizer

    addTrim

    public void addTrim(TokenFilter.Trim filter)
    trim filter

    Parameters: filter the trim filter

    chain

    public final Reader chain(Reader reader)
    Creates a new TokenFilter using the passed in Reader for instantiation.

    Parameters: reader A Reader object providing the underlying stream.

    Returns: a new filter based on this configuration

    convertRegexOptions

    public static int convertRegexOptions(String flags)
    convert regex option flag characters to regex options
  • g - Regexp.REPLACE_ALL
  • i - Regexp.MATCH_CASE_INSENSITIVE
  • m - Regexp.MATCH_MULTILINE
  • s - Regexp.MATCH_SINGLELINE
  • Parameters: flags the string containing the flags

    Returns: the Regexp option bits

    read

    public int read()
    Returns the next character in the filtered stream, only including lines from the original stream which match all of the specified regular expressions.

    Returns: the next character in the resulting stream, or -1 if the end of the resulting stream has been reached

    Throws: IOException if the underlying stream throws an IOException during reading

    resolveBackSlash

    public static String resolveBackSlash(String input)
    xml does not do "c" like interpretation of strings. i.e. \n\r\t etc. this method processes \n, \r, \t, \f, \\ also subs \s -> " \n\r\t\f" a trailing '\' will be ignored

    Parameters: input raw string with possible embedded '\'s

    Returns: converted string

    setDelimOutput

    public void setDelimOutput(String delimOutput)
    set the output delimiter.

    Parameters: delimOutput replaces the delim string returned by the tokenizer, if present.

    Copyright