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

public final Class LineContains

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

Filter which includes only those lines that contain the user-specified strings. Example:
<linecontains>
  <contains value="foo">
  <contains value="bar">
</linecontains>
Or:
<filterreader classname="org.apache.tools.ant.filters.LineContains">
   <param type="contains" value="foo"/>
   <param type="contains" value="bar"/>
</filterreader>
This will include only those lines that contain foo and bar. Starting Ant 1.10.4, the matchAny attribute can be used to control whether any one of the user-specified strings is expected to be contained in the line or all of them are expected to be contained. For example:
<linecontains matchAny="true">
 *   <contains value="foo">
 *   <contains value="bar">
 * </linecontains>
This will include only those lines that contain either foo or bar.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
LineContains.Contains

Holds a contains element

Field Summary

Modifier and TypeField and Description
private Vector<String>
contains

Vector that holds the strings that input lines must contain.

private static final String
CONTAINS_KEY

Parameter name for the words to filter on.

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 boolean
private static final String
NEGATE_KEY

Parameter name for the words to filter on.

Constructor Summary

AccessConstructor and Description
public
LineContains()

Constructor for "dummy" instances.

public
LineContains(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
addConfiguredContains(final LineContains.Contains
The contains element to add. Must not be null.
contains
)

Adds a contains 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 LineContains using the passed in Reader for instantiation.
private Vector<String>

Returns:

the vector of words 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.
getContains
()

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

private void
initialize()

Parses the parameters to add user-defined contains strings.

public boolean

Returns:

Returns true if this LineContains is considered a match, if any of the contains value match. False if all of the contains value are expected to match
isMatchAny
()

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 contain all of the specified words.
private void
setContains(final Vector<String>
A vector of words which must be contained within a line in order for it to match in this filter. Must not be null.
contains
)

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

public void
setMatchAny(final boolean
True if this LineContains is considered a match, if any of the contains value match. False if all of the contains value are expected to match
matchAny
)

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

Set the negation mode.

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

Field Detail

containsback to summary
private Vector<String> contains

Vector that holds the strings that input lines must contain.

CONTAINS_KEYback to summary
private static final String CONTAINS_KEY

Parameter name for the words to filter on.

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.

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

Parameter name for the words to filter on.

Constructor Detail

LineContainsback to summary
public LineContains()

Constructor for "dummy" instances.

See Also
BaseFilterReader#BaseFilterReader()
LineContainsback to summary
public LineContains(final Reader in)

Creates a new filtered reader.

Parameters
in:Reader

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

Method Detail

addConfiguredContainsback to summary
public void addConfiguredContains(final LineContains.Contains contains)

Adds a contains element.

Parameters
contains:LineContains.Contains

The contains 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 LineContains 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

getContainsback to summary
private Vector<String> getContains()

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

Returns:Vector<String>

the vector of words 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 the parameters to add user-defined contains strings.

isMatchAnyback to summary
public boolean isMatchAny()
Returns:boolean

Returns true if this LineContains is considered a match, if any of the contains value match. False if all of the contains value are expected to match

Since
Ant 1.10.4
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 contain all of the specified words.

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
setContainsback to summary
private void setContains(final Vector<String> contains)

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

Parameters
contains:Vector<String>

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

setMatchAnyback to summary
public void setMatchAny(final boolean matchAny)
Parameters
matchAny:boolean

True if this LineContains is considered a match, if any of the contains value match. False if all of the contains value are expected to match

Since
Ant 1.10.4
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.

org.apache.tools.ant.filters back to summary

public Class LineContains.Contains

extends Object
Class Inheritance

Holds a contains element

Field Summary

Modifier and TypeField and Description
private String
value

User defined contains string

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public final String

Returns:

the contains string for this element
getValue
()

Returns the contains string.

public final void
setValue(String
The contains string to set. Must not be null.
contains
)

Sets the contains string

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

valueback to summary
private String value

User defined contains string

Constructor Detail

Containsback to summary
public Contains()

Method Detail

getValueback to summary
public final String getValue()

Returns the contains string.

Returns:String

the contains string for this element

setValueback to summary
public final void setValue(String contains)

Sets the contains string

Parameters
contains:String

The contains string to set. Must not be null.