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

public final Class TabsToSpaces

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

Converts tabs to spaces. Example:
<tabstospaces tablength="8"/>
Or:
<filterreader classname="org.apache.tools.ant.filters.TabsToSpaces">
  <param name="tablength" value="8"/>
</filterreader>

Field Summary

Modifier and TypeField and Description
private static final int
DEFAULT_TAB_LENGTH

The default tab length.

private int
spacesRemaining

The number of spaces still to be read to represent the last-read tab.

private static final String
TAB_LENGTH_KEY

Parameter name for the length of a tab.

private int
tabLength

Tab length in this filter.

Constructor Summary

AccessConstructor and Description
public
TabsToSpaces()

Constructor for "dummy" instances.

public
TabsToSpaces(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 TabsToSpaces using the passed in Reader for instantiation.
private int

Returns:

the number of spaces used when converting a tab
getTablength
()

Returns the tab length.

private void
initialize()

Parses the parameters to set the tab length.

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, converting tabs to the specified number of spaces.
public void
setTablength(final int
the number of spaces to be used when converting a tab.
tabLength
)

Sets the tab length.

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

Field Detail

DEFAULT_TAB_LENGTHback to summary
private static final int DEFAULT_TAB_LENGTH

The default tab length.

spacesRemainingback to summary
private int spacesRemaining

The number of spaces still to be read to represent the last-read tab.

TAB_LENGTH_KEYback to summary
private static final String TAB_LENGTH_KEY

Parameter name for the length of a tab.

tabLengthback to summary
private int tabLength

Tab length in this filter.

Constructor Detail

TabsToSpacesback to summary
public TabsToSpaces()

Constructor for "dummy" instances.

See Also
BaseFilterReader#BaseFilterReader()
TabsToSpacesback to summary
public TabsToSpaces(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 TabsToSpaces 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

getTablengthback to summary
private int getTablength()

Returns the tab length.

Returns:int

the number of spaces used when converting a tab

initializeback to summary
private void initialize()

Parses the parameters to set the tab length.

readback to summary
public int read() throws IOException

Overrides java.io.FilterReader.read.

Returns the next character in the filtered stream, converting tabs to the specified number of spaces.

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
setTablengthback to summary
public void setTablength(final int tabLength)

Sets the tab length.

Parameters
tabLength:int

the number of spaces to be used when converting a tab.