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:
- java.io.Closeable,- java.lang.AutoCloseable,- java.lang.Readable,- ChainableReader
 
 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 SummaryNested Classes Modifier and Type Class Description static classTokenFilter.ChainableReaderFilterAbstract class that converts derived filter classes into ChainableReaderFilter'sstatic classTokenFilter.ContainsRegexfilter to filter tokens matching regular expressions.static classTokenFilter.ContainsStringSimple filter to filter lines contains stringsstatic classTokenFilter.DeleteCharactersFilter to delete charactersstatic classTokenFilter.FileTokenizerclass to read the complete input into a stringstatic interfaceTokenFilter.Filterstring filters implement this interfacestatic classTokenFilter.IgnoreBlankFilter remove empty tokensstatic classTokenFilter.ReplaceRegexfilter to replace regex.static classTokenFilter.ReplaceStringSimple replace string filter.static classTokenFilter.StringTokenizerclass to tokenize the input as areas separated by white space, or by a specified list of delim characters.static classTokenFilter.TrimFilter to trim white space
 - 
Constructor SummaryConstructors Constructor Description TokenFilter()Constructor for "dummy" instances.TokenFilter(java.io.Reader in)Creates a new filtered reader.
 - 
Method SummaryModifier and Type Method Description voidadd(TokenFilter.Filter filter)Add an arbitrary filtervoidadd(Tokenizer tokenizer)add an arbitrary tokenizervoidaddContainsRegex(TokenFilter.ContainsRegex filter)contains regex filtervoidaddContainsString(TokenFilter.ContainsString filter)contains string filtervoidaddDeleteCharacters(TokenFilter.DeleteCharacters filter)delete charsvoidaddFileTokenizer(TokenFilter.FileTokenizer tokenizer)add a file tokenizervoidaddIgnoreBlank(TokenFilter.IgnoreBlank filter)ignore blank filtervoidaddLineTokenizer(LineTokenizer tokenizer)add a line tokenizer - this is the default.voidaddReplaceRegex(TokenFilter.ReplaceRegex filter)replace regex filtervoidaddReplaceString(TokenFilter.ReplaceString filter)replace string filtervoidaddStringTokenizer(TokenFilter.StringTokenizer tokenizer)add a string tokenizervoidaddTrim(TokenFilter.Trim filter)trim filterjava.io.Readerchain(java.io.Reader reader)Creates a new TokenFilter using the passed in Reader for instantiation.static intconvertRegexOptions(java.lang.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_SINGLELINEintread()Returns the next character in the filtered stream, only including lines from the original stream which match all of the specified regular expressions.static java.lang.StringresolveBackSlash(java.lang.String input)xml does not do "c" like interpretation of strings.voidsetDelimOutput(java.lang.String delimOutput)set the output delimiter.- 
Methods inherited from class org.apache.tools.ant.filters.BaseFilterReadergetInitialized, getProject, read, readFully, readLine, setInitialized, setProject, skip
 
- 
 
- 
- 
- 
Constructor Detail- 
TokenFilterpublic TokenFilter() Constructor for "dummy" instances.- See Also:
- BaseFilterReader()
 
 - 
TokenFilterpublic TokenFilter(java.io.Reader in) Creates a new filtered reader.- Parameters:
- in- A Reader object providing the underlying stream. Must not be- null.
 
 
- 
 - 
Method Detail- 
readpublic int read() throws java.io.IOExceptionReturns the next character in the filtered stream, only including lines from the original stream which match all of the specified regular expressions.- Overrides:
- readin class- java.io.FilterReader
- Returns:
- the next character in the resulting stream, or -1 if the end of the resulting stream has been reached
- Throws:
- java.io.IOException- if the underlying stream throws an IOException during reading
 
 - 
chainpublic final java.io.Reader chain(java.io.Reader reader) Creates a new TokenFilter using the passed in Reader for instantiation.- Specified by:
- chainin interface- ChainableReader
- Parameters:
- reader- A Reader object providing the underlying stream.
- Returns:
- a new filter based on this configuration
 
 - 
setDelimOutputpublic void setDelimOutput(java.lang.String delimOutput) set the output delimiter.- Parameters:
- delimOutput- replaces the delim string returned by the tokenizer, if present.
 
 - 
addLineTokenizerpublic void addLineTokenizer(LineTokenizer tokenizer) add a line tokenizer - this is the default.- Parameters:
- tokenizer- the line tokenizer
 
 - 
addStringTokenizerpublic void addStringTokenizer(TokenFilter.StringTokenizer tokenizer) add a string tokenizer- Parameters:
- tokenizer- the string tokenizer
 
 - 
addFileTokenizerpublic void addFileTokenizer(TokenFilter.FileTokenizer tokenizer) add a file tokenizer- Parameters:
- tokenizer- the file tokenizer
 
 - 
addpublic void add(Tokenizer tokenizer) add an arbitrary tokenizer- Parameters:
- tokenizer- the tokenizer to all, only one allowed
 
 - 
addReplaceStringpublic void addReplaceString(TokenFilter.ReplaceString filter) replace string filter- Parameters:
- filter- the replace string filter
 
 - 
addContainsStringpublic void addContainsString(TokenFilter.ContainsString filter) contains string filter- Parameters:
- filter- the contains string filter
 
 - 
addReplaceRegexpublic void addReplaceRegex(TokenFilter.ReplaceRegex filter) replace regex filter- Parameters:
- filter- the replace regex filter
 
 - 
addContainsRegexpublic void addContainsRegex(TokenFilter.ContainsRegex filter) contains regex filter- Parameters:
- filter- the contains regex filter
 
 - 
addTrimpublic void addTrim(TokenFilter.Trim filter) trim filter- Parameters:
- filter- the trim filter
 
 - 
addIgnoreBlankpublic void addIgnoreBlank(TokenFilter.IgnoreBlank filter) ignore blank filter- Parameters:
- filter- the ignore blank filter
 
 - 
addDeleteCharacterspublic void addDeleteCharacters(TokenFilter.DeleteCharacters filter) delete chars- Parameters:
- filter- the delete characters filter
 
 - 
addpublic void add(TokenFilter.Filter filter) Add an arbitrary filter- Parameters:
- filter- the filter to add
 
 - 
resolveBackSlashpublic static java.lang.String resolveBackSlash(java.lang.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 with " \n\r\t\f" a trailing '\' will be ignored- Parameters:
- input- raw string with possible embedded '\'s
- Returns:
- converted string
 
 - 
convertRegexOptionspublic static int convertRegexOptions(java.lang.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
 
 
- 
 
-