Hi Jörg,

Re "This should make it immediately obvious, why the value of your
deserialized IncomeLevel instances is null."

Maybe to you but I'm still missing it. Note that the deserialized
IncomeLevel instances is not actually null. The class is created, the id is
set correctly -- it's the value which is null.

If I move the converter and the value property to the IncomeLevel and
likewise remove the converter and value property from the IdValuePair, then
the XML that is serialized appears to be correct (I've pasted the classes
below) -- however this is not where I want this to be.

Here's the XML that is generated after the change below:

<wb:IncomeLevels>
  <wb:incomeLevel id="foo">bar</wb:incomeLevel>
</wb:IncomeLevels>

So, what am I not seeing?

Tom

@XStreamAlias(DefaultObject.WB_INCOME_LEVEL)
@XStreamConverter(value=ToAttributedValueConverter.class, strings={"value"})
public class *IncomeLevel* extends IdValuePair {

    private static final long serialVersionUID = -8487721255922835678L;

    private String value = null;

    public String getValue() {
        return value;
    }

    public void setValue(String value) {
        this.value = value;
    }
}

public class *IdValuePair* extends IdentityObject {

    private static final long serialVersionUID = -5821168050440557783L;

}


On Thu, May 16, 2013 at 2:17 PM, Jörg Schaible <[email protected]>wrote:

> Hi Thomas,
>
> Thomas Fuller wrote:
>
> > Hi Jörg,
> >
> > Apologies for any inconvenience. Please see the attached zip file --
> > specifically src/test/Main.java. The is severely cut down and includes
> > everything needed to reproduce the problem.
> >
> > The unit test is a simple if/then in the main method:
> >
> > if (!"High income".equals(value)) // This will fail.
> >         throw new RuntimeException ("Failed: the value is wrong: " +
> >         value);
> >
> > I've tried getting this to work several ways and don't see why the value
> > is not being set.
>
> Well, if I create a IncomesLevel with one IncomeLevel of id 'HIC' and value
> "High Income" manually and marshal that to XML, I get:
>
>  ==================== %< ========================
>  <wb:IncomeLevels>
>    <wb:incomeLevel id="HIC">
>      <value>High income</value>
>    </wb:incomeLevel>
>  </wb:IncomeLevels>
>  ==================== %< ========================
>
> This should make it immediately obvious, why the value of your deserialized
> IncomeLevel instances is null.
>
> Cheers,
> Jörg
>
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>     http://xircles.codehaus.org/manage_email
>
>
>

Reply via email to