[Simple-support] Complex Object Limited Cycle Strategy
Brought to you by:
niallg
|
From: Nhat N. <phu...@gm...> - 2012-10-31 06:30:15
|
Hi all,
Let's say I got the following objects:
*Sector.java*
@Root
public class Sector {
@Attribute
String name;
@Element
Int value;
@ElementList(entry="neighbor")
List<Sector> neighbours;
public Sector(@Attribute name,
@Element value) {
...
}
public addNeighbour(sector) {
...
}
}
*Sectors.java*
public class Sectors {
@ElementList
List<Sector> sectors;
...
}
How would I serialize and deserialize the above objects into the following
sample xml:
<Sectors>
<Sector name = "one">
<value>5</value>
<neighbours class=...>
<neighbour name="two" />
</neighbours>
</Sector>
<Sector name = "two">
<value>2</value>
<neighbours class=...>
<neighbour name="one" />
<neighbour name="three" />
</neighbours>
</Sector>
...
</Sectors>
Where the Neighbours are referred by designated name and not referring to
the whole object. I've tried CycleStrategy but it seems to refer to every
element in object and not simply a specific one I needed.
Nhat
|