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

public final Class StripLineComments

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.types.Parameter

This filter strips line comments. Example:
<striplinecomments>
  <comment value="#"/>
  <comment value="--"/>
  <comment value="REM "/>
  <comment value="rem "/>
  <comment value="//"/>
</striplinecomments>
Or:
<filterreader
     classname="org.apache.tools.ant.filters.StripLineComments">
  <param type="comment" value="#"/>
  <param type="comment" value="--"/>
  <param type="comment" value="REM "/>
  <param type="comment" value="rem "/>
  <param type="comment" value="//"/>
</filterreader>

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
StripLineComments.Comment

The class that holds a comment representation.

Field Summary

Modifier and TypeField and Description
private Vector<String>
comments

Vector that holds the comment prefixes.

private static final String
COMMENTS_KEY

Parameter name for the comment prefix.

private String
line

The line that has been read ahead.

Constructor Summary

AccessConstructor and Description
public
StripLineComments()

Constructor for "dummy" instances.

public
StripLineComments(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
addConfiguredComment(final StripLineComments.Comment
The comment element to add to the list of comment prefixes to strip. Must not be null.
comment
)

Adds a comment element to the list of prefixes.

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 StripLineComments using the passed in Reader for instantiation.
private Vector<String>

Returns:

the list of comment prefixes to strip.
getComments
()

Returns the list of comment prefixes to strip.

private void
initialize()

Parses the parameters to set the comment prefixes.

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 don't start with any of the specified comment prefixes.
private void
setComments(final Vector<String>
A list of strings, each of which is a prefix for a comment line. Must not be null.
comments
)

Sets the list of comment prefixes to strip.

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

Field Detail

commentsback to summary
private Vector<String> comments

Vector that holds the comment prefixes.

COMMENTS_KEYback to summary
private static final String COMMENTS_KEY

Parameter name for the comment prefix.

lineback to summary
private String line

The line that has been read ahead.

Constructor Detail

StripLineCommentsback to summary
public StripLineComments()

Constructor for "dummy" instances.

See Also
BaseFilterReader#BaseFilterReader()
StripLineCommentsback to summary
public StripLineComments(final Reader in)

Creates a new filtered reader.

Parameters
in:Reader

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

Method Detail

addConfiguredCommentback to summary
public void addConfiguredComment(final StripLineComments.Comment comment)

Adds a comment element to the list of prefixes.

Parameters
comment:StripLineComments.Comment

The comment element to add to the list of comment prefixes to strip. Must not be null.

chainback to summary
public Reader chain(final Reader rdr)

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

Creates a new StripLineComments 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

getCommentsback to summary
private Vector<String> getComments()

Returns the list of comment prefixes to strip.

Returns:Vector<String>

the list of comment prefixes to strip.

initializeback to summary
private void initialize()

Parses the parameters to set the comment prefixes.

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 don't start with any of the specified comment prefixes.

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
setCommentsback to summary
private void setComments(final Vector<String> comments)

Sets the list of comment prefixes to strip.

Parameters
comments:Vector<String>

A list of strings, each of which is a prefix for a comment line. Must not be null.

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

public Class StripLineComments.Comment

extends Object
Class Inheritance

The class that holds a comment representation.

Field Summary

Modifier and TypeField and Description
private String
value

The prefix for a line comment.

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
addText(String
The prefix for a line comment of this type. Must not be null.
comment
)

Alt.

public final String

Returns:

the prefix for this type of line comment.
getValue
()

Returns the prefix for this type of line comment.

public final void
setValue(String
The prefix for a line comment of this type. Must not be null.
comment
)

Sets the prefix for this type of line comment.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

valueback to summary
private String value

The prefix for a line comment.

Constructor Detail

Commentback to summary
public Comment()

Method Detail

addTextback to summary
public void addText(String comment)

Alt. syntax to set the prefix for this type of line comment.

Parameters
comment:String

The prefix for a line comment of this type. Must not be null.

getValueback to summary
public final String getValue()

Returns the prefix for this type of line comment.

Returns:String

the prefix for this type of line comment.

setValueback to summary
public final void setValue(String comment)

Sets the prefix for this type of line comment.

Parameters
comment:String

The prefix for a line comment of this type. Must not be null.