Dan-

Have you tried using set-method="%1" (Castor XML Mapping page)?  Since
you're access the fields via a another object, I'm skeptical it would
work, but it might.  Another option might be to use a valueOf method
to create your Wrapper class (see the last tip on the Castor XML
Mapping page), and finally I think the brute force method would be to
use a custom handler (also documented at the Castor website). 
Unfortunately I don't have direct experience with this situation, but
those were the few thoughts I had.

Stephen


On 3/27/06, Daniel Dyer <[EMAIL PROTECTED]> wrote:
> I have an immutable wrapper class for two primitive longs, like this:
>
> public class Wrapper
> {
>      private long field1;
>      private long field2;
>
>      public Wrapper(long value1, long value2)
>      {
>          field1 = value1;
>          field2 = value2;
>      }
>
>      public long getField1()
>      {
>          return field1;
>      }
>
>      public long getField2()
>      {
>          return field2;
>      }
> }
>
> I have another class, that has a field of type Wrapper:
>
> public class MyClass
> {
>      public Wrapper getWrapper()
>      {
>         ...
>      }
> }
>
> I would like to map the two longs to attributes of the XML element that
> represents that class, using the indirect field name "wrapper.field1",
> like this:
>
> <field name="wrapper.field1">
>
> So that I get XML like this:
>
> <MyClass field1="value1" field2="value2" />
>
> This works for marshalling, and it works for unmarshalling if I make the
> wrapper class mutable with setter methods, but I'd rather not.  I can't
> seem to specify that the Wrapper instance should be created using the
> constructor.  Is there any way around this (other than having to map the
> Wrapper class to a <Wrapper> element?
>
> Thanks,
>
> Dan.
>
> --
> Daniel Dyer
> http://www.dandyer.co.uk
>
> -------------------------------------------------
> If you wish to unsubscribe from this list, please
> send an empty message to the following address:
>
> [EMAIL PROTECTED]
> -------------------------------------------------
>
>

Reply via email to