Re: [Simple-support] Simple @Replace (how to fit an "Element" in an Attribute)
Brought to you by:
niallg
|
From: Fabian K. <fab...@we...> - 2009-03-15 14:13:08
|
Niall Gallagher schrieb:
> Hi,
>
> Make the field java.lang.Object then it should work. Simple is very strict on types and does not allow a Data to be written as a double. But should allow a java.lang.Object to be represented as a java.lang.Double.
>
> Niall
>
Hi,
actualliy, it does not. :(
@Root
public class Data {
@Attribute
public double value;
@Transient
int stuff;
@Replace
Object replace() {
System.out.println("replace called");
return Double.valueOf(this.value);
}
}
public class RootClass {
@Attribute
Object data;
// ...
}
But maybe this is not the right way... I think I understand now, that
replace is not meant for this.
However, using Transform, i can achieve the desired xml.
There is just one little problem:
I need to define a custom Matcher for the Persister (to map
DataTransform to Data), I think it would be better if I could annotate
Data with the information about the Transformer.
Fabian
|