I have foggy notion about what you're after,
so take this advice with a grain of salt.
If I were you, here's what I'd do:

Just for this example, create a basic XML schema and
use the SourceGenerator to generate some .java files.
Some of the files generated will have names that match
the pattern '*Descriptor.java'.
Open up one of these.  Look for an inner class of type
XMLFieldHandler.

Here is a sample inside a Descriptor I generated:
<CODE>
            public void setValue( Object object, Object value) 
                throws IllegalStateException, IllegalArgumentException
            {
                try {
                    AccountKeyType target = (AccountKeyType) object;
                    target.setAccountId( (java.lang.String) value);
                }
                catch (Exception ex) {
                    throw new IllegalStateException(ex.toString());
                }
            }
</CODE>

So, you might want to change this to be

        target.setDataItem( "AccoundId", (java.lang.String) value);

instead of 

        target.setAccountId( (java.lang.String) value);

The class org.exolab.castor.builder.DescriptorSourceFactory geneartes
this class.
The actual name of the 'set' method is retrieved from 
org.exolab.castor.builder.FieldInfo#getWriteMethodName().

You might be able to extend the FieldInfo class and override.
Perhaps someone else on the list can give instructions on how
to get Castor to load your subclass.


-----Original Message-----
From: bikehead [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, July 17, 2002 1:56 AM
To: [EMAIL PROTECTED]
Subject: [castor-dev] Controlling the get and set invocation...


Hello,
    A couple days back I asked a question about using Castor for dynamic

object.  After getting no response I realize that my question was 
probably a bit too abstract.  After digging around in Castor, perhaps I 
can reform the question in more concrete terms....


I have found examples of JDO mapping where the get-method and set-method

attributes are specified in order to change the name of the get/set 
methods called during marshal and unmarshal.  However, for dynamic 
properties my get and set take an argument that is the name of the field

being accessed.  Is there a way to control exactly how the getter and 
setter in invoked including the arguments passed?  Are there any 
examples of how this could be done?

To be more specific,  instead of invoking 'object.getFoo()' in order to 
access field 'foo', I need to get Castor to invoke 'object.get("foo")'.

Thanks for any help you can provide,

-- 
   __o 
 _-\<,_   Brian
(_)/ (_)  [EMAIL PROTECTED]  x503
 

----------------------------------------------------------- 
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
        unsubscribe castor-dev

----------------------------------------------------------- 
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
        unsubscribe castor-dev

Reply via email to