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