Hi Eva,
[EMAIL PROTECTED] wrote:
>
> I have inherited a big bunch of existing classes with one getter and a lot
> of public fields without any getters like the one below:
>
> public class TestClass {
> public String a1 ="A1";
> public int a2 = 1;
> public boolean a3 = true;
>
> public boolean getA3() {
> return a3;
> }
> }
>
> Unfortunately, CASTOR default introspection does not work on the fields any
> more because of the one getter.
Right. If the introspector finds any getter/setter methods it will not
directly access any fields, especially since it doesn't understand the
relationship between the fields and methods.
> It seems that CASTOR was not designed for this.
The introspector, no...but you can always use a mapping file and specify
direct="true" for the field such as:
<class name="TestClass">
<field name="a1" type="string" direct="true"/>
...
</class>
You can even use the auto-complete with this as such:
<class name="TestClass" auto-complete="true">
<field name="a1" type="string" direct="true"/>
...
<!-- field a3 will be found automatically via introspection -->
</class>
>
> I would still like to use CASTOR default introspection for these classes.
Unfortanately default introspection is no longer an option.
You'll need to use a mapping file.
> Are there any plans to enhance CASTOR in a way that it can default inspect
> attributes of existing classes in spite of existing getters?
No. It was a design decision to not use direct field access by default
if any getter/setters exist. This is because Castor doesn't know what
the relationship to the fields may be.
> Or is it fairly easy for a possible outside contributor (like me :-)) to
> enhance the existing code with an option to default inspect attributes of
> existing classes in spite of existing getters?
Feel free to change the code to your liking, you can even contribute
your changes back to us as we often encourage users to do so, however
this one particular change might not make it into our CVS if the current
committers don't agree on it's usefulness.
I wrote the default Introspection code. Feel free to look at
org.exolab.castor.xml.Introspector.java.
Thanks,
--Keith
-----------------------------------------------------------
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
unsubscribe castor-dev