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

public final Class ClassConstants

extends BaseFilterReader
implements ChainableReader
Class Inheritance
All Implemented Interfaces
org.apache.tools.ant.filters.ChainableReader
Imports
java.io.IOException, .Reader, java.lang.reflect.InvocationTargetException, .Method, java.nio.charset.StandardCharsets, org.apache.tools.ant.BuildException

Assembles the constants declared in a Java class in key1=value1(line separator)key2=value2 format.

Notes:

  1. This filter uses the BCEL external toolkit.
  2. This assembles only those constants that are not created using the syntax new whatever()
  3. This assembles constants declared using the basic datatypes and String only.
  4. The access modifiers of the declared constants do not matter.

Example:

<classconstants/>
Or:
<filterreader
    classname="org.apache.tools.ant.filters.ClassConstants"/>

Field Summary

Modifier and TypeField and Description
private static final String
JAVA_CLASS_HELPER

Helper Class to be invoked via reflection.

private String
queuedData

Data that must be read from, if not null.

Constructor Summary

AccessConstructor and Description
public
ClassConstants()

Constructor for "dummy" instances.

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

Returns:

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

Overrides java.io.FilterReader.read.

Reads and assembles the constants declared in a class file.
Inherited from org.apache.tools.ant.filters.BaseFilterReader:
getInitializedgetProjectreadreadFullyreadLinesetInitializedsetProjectskip

Field Detail

JAVA_CLASS_HELPERback to summary
private static final String JAVA_CLASS_HELPER

Helper Class to be invoked via reflection.

queuedDataback to summary
private String queuedData

Data that must be read from, if not null.

Constructor Detail

ClassConstantsback to summary
public ClassConstants()

Constructor for "dummy" instances.

See Also
BaseFilterReader#BaseFilterReader()
ClassConstantsback to summary
public ClassConstants(final Reader in)

Creates a new filtered reader. The contents of the passed-in reader are expected to be the name of the class from which to produce a list of constants.

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 ClassConstants 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

readback to summary
public int read() throws IOException

Overrides java.io.FilterReader.read.

Reads and assembles the constants declared in a class file.

Returns:int

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

Exceptions
IOException:
if the underlying stream throws an IOException during reading, or if the constants for the specified class cannot be read (for example due to the class not being found).