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

public final Class PrefixLines

extends BaseParamFilterReader
implements ChainableReader
Class Inheritance
All Implemented Interfaces
org.apache.tools.ant.filters.ChainableReader
Imports
java.io.IOException, .Reader, org.apache.tools.ant.types.Parameter

Attaches a prefix to every line. Example:
<prefixlines prefix="Foo"/>
Or:
<filterreader classname="org.apache.tools.ant.filters.PrefixLines">
 <param name="prefix" value="Foo"/>
</filterreader>

Field Summary

Modifier and TypeField and Description
private String
prefix

The prefix to be used.

private static final String
PREFIX_KEY

Parameter name for the prefix.

private String
queuedData

Data that must be read from, if not null.

Constructor Summary

AccessConstructor and Description
public
PrefixLines()

Constructor for "dummy" instances.

public
PrefixLines(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 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 PrefixLines filter using the passed in Reader for instantiation.
private String

Returns:

the prefix which will be added at the start of each input line
getPrefix
()

Returns the prefix which will be added at the start of each input line.

private void
initialize()

Initializes the prefix if it is available from the parameters.

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.
public void
setPrefix(final String
The prefix to add at the start of each input line. May be null, in which case no prefix is added.
prefix
)

Sets the prefix to add at the start of each input line.

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

Field Detail

prefixback to summary
private String prefix

The prefix to be used.

PREFIX_KEYback to summary
private static final String PREFIX_KEY

Parameter name for the prefix.

queuedDataback to summary
private String queuedData

Data that must be read from, if not null.

Constructor Detail

PrefixLinesback to summary
public PrefixLines()

Constructor for "dummy" instances.

See Also
BaseFilterReader#BaseFilterReader()
PrefixLinesback to summary
public PrefixLines(final Reader in)

Creates a new filtered reader.

Parameters
in:Reader

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

Method Detail

chainback to summary
public Reader chain(final Reader rdr)

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

Creates a new PrefixLines filter 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

getPrefixback to summary
private String getPrefix()

Returns the prefix which will be added at the start of each input line.

Returns:String

the prefix which will be added at the start of each input line

initializeback to summary
private void initialize()

Initializes the prefix if it is available from the parameters.

readback to summary
public int read() throws IOException

Overrides java.io.FilterReader.read.

Returns the next character in the filtered stream. One line is read from the original input, and the prefix added. The resulting line is then used until it ends, at which point the next original line is read, etc.

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
setPrefixback to summary
public void setPrefix(final String prefix)

Sets the prefix to add at the start of each input line.

Parameters
prefix:String

The prefix to add at the start of each input line. May be null, in which case no prefix is added.