ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stefan Bodewig <>
Subject Refactoring of the reflection part in ProjectHelper
Date Thu, 06 Jul 2000 11:11:04 GMT
the following comment in ProjectHelper

        // XXX
        // instead of doing this introspection each time around, I
        // should have a helper class to keep this info around for
        // each kind of class

and two needs have lead to the appended class.

The two needs where (1) set attributes with a type other than String
and (2) accept void addElement(ObjectType) as an alternative to
createElement when searching for nested elements.

This class should be easily reusable by proxy types, if tasks get
defined on the fly.

The idea is to construct a IntrospectionHelper for each class we want
to set attributes on, add PCDATA to or create nested elements in. A
factory method getHelper ensures we are only doing that once per class
(which means once for MatchingTask.NameEntry no matter how many
include/exclude tags are there).

Nested elements can be created via IntrospectionHelper.createElement -
and it is completely transparent to ProjectHelper whether
createElement or addElement has been called.

If void addText(String) exists, PCDATA areas can be added via

Attributes are set via IntrospectionHelper.setAttribute. Nothing
changes for Strings, but a richer set of arguments is supported.

If there is a methods void setAttribute(boolean) or
setAttribute(Boolean) the value is set via Project.toBoolean. For char
and Character only the first letter is used. For all other primitive
types, the String constructors of the wrapper classes are used.

File arguments get resolved via Project.resolveFile and Class
arguments via Class.forName. Finally all classes with a String
constructor can be set.

I'm not checking in this stuff as I wanted to see some comments first.


BTW I do have a JUnit testcase for this class. Should I keep this
private, rewrite to work without JUnit or check it into CVS as is -
src/tests/... would be the proper place I guess.

View raw message