Package org.apache.tools.ant.filters
Class TokenFilter
java.lang.Object
java.io.Reader
java.io.FilterReader
org.apache.tools.ant.filters.BaseFilterReader
org.apache.tools.ant.filters.TokenFilter
- All Implemented Interfaces:
Closeable
,AutoCloseable
,Readable
,ChainableReader
This splits up input into tokens and passes
the tokens to a sequence of filters.
- Since:
- Ant 1.6
- See Also:
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Abstract class that converts derived filter classes into ChainableReaderFilter'sstatic class
filter to filter tokens matching regular expressions.static class
Simple filter to filter lines contains stringsstatic class
Filter to delete charactersstatic class
class to read the complete input into a stringstatic interface
string filters implement this interfacestatic class
Filter remove empty tokensstatic class
filter to replace regex.static class
Simple replace string filter.static class
class to tokenize the input as areas separated by white space, or by a specified list of delim characters.static class
Filter to trim white space -
Field Summary
Fields inherited from class java.io.FilterReader
in
-
Constructor Summary
ConstructorDescriptionConstructor for "dummy" instances.TokenFilter
(Reader in) Creates a new filtered reader. -
Method Summary
Modifier and TypeMethodDescriptionvoid
add
(TokenFilter.Filter filter) Add an arbitrary filtervoid
add an arbitrary tokenizervoid
contains regex filtervoid
contains string filtervoid
delete charsvoid
addFileTokenizer
(TokenFilter.FileTokenizer tokenizer) add a file tokenizervoid
ignore blank filtervoid
addLineTokenizer
(LineTokenizer tokenizer) add a line tokenizer - this is the default.void
replace regex filtervoid
replace string filtervoid
addStringTokenizer
(TokenFilter.StringTokenizer tokenizer) add a string tokenizervoid
addTrim
(TokenFilter.Trim filter) trim filterfinal Reader
Creates a new TokenFilter using the passed in Reader for instantiation.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_SINGLELINEint
read()
Returns the next character in the filtered stream, only including lines from the original stream which match all of the specified regular expressions.static String
resolveBackSlash
(String input) xml does not do "c" like interpretation of strings.void
setDelimOutput
(String delimOutput) set the output delimiter.Methods inherited from class org.apache.tools.ant.filters.BaseFilterReader
getInitialized, getProject, read, readFully, readLine, setInitialized, setProject, skip
Methods inherited from class java.io.FilterReader
close, mark, markSupported, ready, reset
Methods inherited from class java.io.Reader
nullReader, read, read, transferTo
-
Constructor Details
-
TokenFilter
public TokenFilter()Constructor for "dummy" instances.- See Also:
-
TokenFilter
Creates a new filtered reader.- Parameters:
in
- A Reader object providing the underlying stream. Must not benull
.
-
-
Method Details
-
read
Returns the next character in the filtered stream, only including lines from the original stream which match all of the specified regular expressions.- Overrides:
read
in classFilterReader
- 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
-
chain
Creates a new TokenFilter using the passed in Reader for instantiation.- Specified by:
chain
in interfaceChainableReader
- Parameters:
reader
- A Reader object providing the underlying stream.- Returns:
- a new filter based on this configuration
-
setDelimOutput
set the output delimiter.- Parameters:
delimOutput
- replaces the delim string returned by the tokenizer, if present.
-
addLineTokenizer
add a line tokenizer - this is the default.- Parameters:
tokenizer
- the line tokenizer
-
addStringTokenizer
add a string tokenizer- Parameters:
tokenizer
- the string tokenizer
-
addFileTokenizer
add a file tokenizer- Parameters:
tokenizer
- the file tokenizer
-
add
add an arbitrary tokenizer- Parameters:
tokenizer
- the tokenizer to all, only one allowed
-
addReplaceString
replace string filter- Parameters:
filter
- the replace string filter
-
addContainsString
contains string filter- Parameters:
filter
- the contains string filter
-
addReplaceRegex
replace regex filter- Parameters:
filter
- the replace regex filter
-
addContainsRegex
contains regex filter- Parameters:
filter
- the contains regex filter
-
addTrim
-
addIgnoreBlank
ignore blank filter- Parameters:
filter
- the ignore blank filter
-
addDeleteCharacters
delete chars- Parameters:
filter
- the delete characters filter
-
add
Add an arbitrary filter- Parameters:
filter
- the filter to add
-
resolveBackSlash
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 with " \n\r\t\f" a trailing '\' will be ignored- Parameters:
input
- raw string with possible embedded '\'s- Returns:
- converted string
-
convertRegexOptions
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
-