Top Description Fields Constructors Methods
org.apache.tools.ant.filters

public final Class LineContainsRegExp

extends BaseParamFilterReader
implements ChainableReader
Class Inheritance
All Implemented Interfaces
org.apache.tools.ant.filters.ChainableReader
Imports
java.io.IOException, .Reader, java.util.Vector, org.apache.tools.ant.Project, org.apache.tools.ant.types.Parameter, .RegularExpression, org.apache.tools.ant.util.regexp.Regexp, .RegexpUtil

Filter which includes only those lines that contain the user-specified regular expression matching strings. Example:
<linecontainsregexp>
  <regexp pattern="foo*">
</linecontainsregexp>
Or:
<filterreader classname="org.apache.tools.ant.filters.LineContainsRegExp">
   <param type="regexp" value="foo*"/>
</filterreader>
This will fetch all those lines that contain the pattern foo

Field Summary

Modifier and TypeField and Description
private static final String
CS_KEY

Parameter name for the casesensitive attribute.

private String
line

Remaining line to be read from this filter, or null if the next call to read() should read the original stream to find the next matching line.

private boolean
private static final String
NEGATE_KEY

Parameter name for the negate attribute.

private static final String
REGEXP_KEY

Parameter name for the regular expression to filter on.

private int
private Vector<RegularExpression>
regexps

Vector that holds the expressions that input lines must contain.

Constructor Summary

AccessConstructor and Description
public
LineContainsRegExp()

Constructor for "dummy" instances.

public
LineContainsRegExp(final Reader
A Reader object providing the underlying stream. Must not be null.
in
)

Creates a new filtered reader.

Method Summary

Modifier and TypeMethod and Description
public void
addConfiguredRegexp(final RegularExpression
The regexp element to add. Must not be null.
regExp
)

Adds a regexp element.

public Reader

Returns:

a new filter based on this configuration, but filtering the specified reader
chain
(final Reader
A Reader object providing the underlying stream. Must not be null.
rdr
)

Implements org.apache.tools.ant.filters.ChainableReader.chain.

Creates a new LineContainsRegExp using the passed in Reader for instantiation.
private Vector<RegularExpression>

Returns:

the vector of regular expressions which must be contained within a line read from the original stream in order for it to match this filter. The returned object is "live" - in other words, changes made to the returned object are mirrored in the filter.
getRegexps
()

Returns the vector of regular expressions which must be contained within a line read from the original stream in order for it to match this filter.

private void
initialize()

Parses parameters to add user defined regular expressions.

public boolean

Returns:

boolean negation flag.
isNegated
()

Find out whether we have been negated.

public int

Returns:

the next character in the resulting stream, or -1 if the end of the resulting stream has been reached
read
()

Overrides java.io.FilterReader.read.

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

Whether to match casesensitively.

public void
setNegate(boolean
the boolean negation mode to set.
b
)

Set the negation mode.

public void
setRegexp(String
String
pattern
)

Set the regular expression as an attribute.

private void
setRegexps(final Vector<RegularExpression>
A vector of regular expressions which must be contained within a line in order for it to match in this filter. Must not be null.
regexps
)

Sets the vector of regular expressions which must be contained within a line read from the original stream in order for it to match this filter.

Inherited from org.apache.tools.ant.filters.BaseParamFilterReader:
getParameterssetParameters

Field Detail

CS_KEYback to summary
private static final String CS_KEY

Parameter name for the casesensitive attribute.

lineback to summary
private String line

Remaining line to be read from this filter, or null if the next call to read() should read the original stream to find the next matching line.

negateback to summary
private boolean negate
NEGATE_KEYback to summary
private static final String NEGATE_KEY

Parameter name for the negate attribute.

REGEXP_KEYback to summary
private static final String REGEXP_KEY

Parameter name for the regular expression to filter on.

regexpOptionsback to summary
private int regexpOptions
regexpsback to summary
private Vector<RegularExpression> regexps

Vector that holds the expressions that input lines must contain.

Constructor Detail

LineContainsRegExpback to summary
public LineContainsRegExp()

Constructor for "dummy" instances.

See Also
BaseFilterReader#BaseFilterReader()
LineContainsRegExpback to summary
public LineContainsRegExp(final Reader in)

Creates a new filtered reader.

Parameters
in:Reader

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

Method Detail

addConfiguredRegexpback to summary
public void addConfiguredRegexp(final RegularExpression regExp)

Adds a regexp element.

Parameters
regExp:RegularExpression

The regexp element to add. Must not be null.

chainback to summary
public Reader chain(final Reader rdr)

Implements org.apache.tools.ant.filters.ChainableReader.chain.

Creates a new LineContainsRegExp using the passed in Reader for instantiation.

Parameters
rdr:Reader

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

Returns:Reader

a new filter based on this configuration, but filtering the specified reader

getRegexpsback to summary
private Vector<RegularExpression> getRegexps()

Returns the vector of regular expressions which must be contained within a line read from the original stream in order for it to match this filter.

Returns:Vector<RegularExpression>

the vector of regular expressions which must be contained within a line read from the original stream in order for it to match this filter. The returned object is "live" - in other words, changes made to the returned object are mirrored in the filter.

initializeback to summary
private void initialize()

Parses parameters to add user defined regular expressions.

isNegatedback to summary
public boolean isNegated()

Find out whether we have been negated.

Returns:boolean

boolean negation flag.

readback to summary
public int read() throws IOException

Overrides java.io.FilterReader.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:int

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

Exceptions
IOException:
if the underlying stream throws an IOException during reading
setCaseSensitiveback to summary
public void setCaseSensitive(boolean b)

Whether to match casesensitively.

Parameters
b:boolean

boolean

Since
Ant 1.8.2
setNegateback to summary
public void setNegate(boolean b)

Set the negation mode. Default false (no negation).

Parameters
b:boolean

the boolean negation mode to set.

setRegexpback to summary
public void setRegexp(String pattern)

Set the regular expression as an attribute.

Parameters
pattern:String

String

Since
Ant 1.10.2
setRegexpsback to summary
private void setRegexps(final Vector<RegularExpression> regexps)

Sets the vector of regular expressions which must be contained within a line read from the original stream in order for it to match this filter.

Parameters
regexps:Vector<RegularExpression>

A vector of regular expressions which must be contained within a line in order for it to match in this filter. Must not be null.