Re: [Simple-support] Controlling Depth of Serialization
Brought to you by:
niallg
|
From: Niall G. <gal...@ya...> - 2008-07-17 12:05:28
|
Hi,
If you don't annotate the reference to C then it wont be serialized. There is another way also. If you implement a Strategy you can return a Type such that the Type.isReference == true then it wont serialize it. For instance in your strategy implementation if you return the following.
public Type setElement(....) {
if(depth++ > 2) {
return new EmptyType();
}
}
To see exactly what is involved in this look at the cycle strategy. However, I think what you are looking for is a reference to C in B that is not annotated. For example
@Root
public class A {
@Element
private B b;
}
@Root
public class B {
private C c;
}
public class C {
}
Here if you serialize A, only reference to b will be serialized. B's reference to C will not be serialized as it is not annotated.
Niall
--- On Wed, 7/16/08, Karl Garske <kar...@gm...> wrote:
> From: Karl Garske <kar...@gm...>
> Subject: [Simple-support] Controlling Depth of Serialization
> To: sim...@li...
> Date: Wednesday, July 16, 2008, 2:54 PM
> Hello, Is there any way to control the depth of
> serialization through
> something like the Persister? For example, my object graph
> might look
> something like A->B->C where A,B,C are objects and
> -> is the direction of
> reference. Is there a way to specify depth=2 and have it
> only serialize A
> and B, but not C? My apologies if this is documented
> somewhere, but I didn't
> see it in the tutorial.
>
> Thanks!-------------------------------------------------------------------------
> This SF.Net email is sponsored by the Moblin Your Move
> Developer's challenge
> Build the coolest Linux based applications with Moblin SDK
> & win great prizes
> Grand prize is a trip for two to an Open Source event
> anywhere in the world
> http://moblin-contest.org/redirect.php?banner_id=100&url=/_______________________________________________
> Simple-support mailing list
> Sim...@li...
> https://lists.sourceforge.net/lists/listinfo/simple-support
|