Re: Dynamically Processing Nodes
"Diez B. Roggisch" <[email protected]>
| Newsgroups | gmane.comp.java.enhydra.barracuda.general |
|---|---|
| Message-ID | <[email protected]> |
Hi,
> Nah,
> I've got parent/child loops nailed.
Good to know :)
> It has more to do with using the Iterative Model and dynamically
> "growing it"...??
I still think that its basically the way I said before - what you have with
you rows is a tree. To create a flat list of rows (or RowCollections) you'll
have to traverse this tree with an vistor like this:
class RowVisitor {
List _rowList = new LinkedList();
public void visit(List rows) {
for(Iterator it = rows.iterator(); it.hasNext();) {
visit((Row)it.next());
}
}
public void visit(Row row) {
_rowList.add(row);
for(Iterator it = row.getRowCollection().iterator(); it.hasNext();) {
visit((Row)it.next());
}
}
}
This should end up with a list of rows in the correct order. Now for the
rendering - the rowspan is (1 + row.getRowCollection().size()). Maybe you
have to make the visitor tag the rows with additional information like depth
to make the rendering of the colspan easier. The colspan is (3 - depth).
Does this give you an idea?
Diez