users@jaxb.java.net

Visiting all elements of the object tree

From: Wolfgang Laun <wolfgang.laun_at_gmail.com>
Date: Mon, 4 Jul 2011 09:01:12 +0200

Given the top-level object of an unmarshalling operation, the task is to
write a method for visiting all elements in the object tree using
reflection, not code for some specific set of object classes. The simple
case (assuming a minimal subset of possibilities) is easy to solve, but the
full general case is a little trickier.

Does anybody know of such a general solution?

(I realize that there might be two approaches: an iterator walking the tree
or by listen to the unmarshaller. I'd prefer the first as it should permit
visiting the objects in document order.)

-W