01: // Copyright (C) 2003,2004,2005 by Object Mentor, Inc. All rights reserved.
02: // Released under the terms of the GNU General Public License version 2 or later.
03: package fitnesse.wiki;
04:
05: import java.util.*;
06:
07: public abstract class InheritedItemBuilder {
08: protected List getInheritedItems(WikiPage page, Set visitedPages)
09: throws Exception {
10: List items = new ArrayList();
11: addItemsFromPage(page, items);
12:
13: List ancestors = WikiPageUtil.getAncestorsOf(page);
14: for (Iterator iterator = ancestors.iterator(); iterator
15: .hasNext();) {
16: WikiPage ancestor = (WikiPage) iterator.next();
17: if (!visitedPages.contains(ancestor)) {
18: visitedPages.add(ancestor);
19: addItemsFromPage(ancestor, items);
20: }
21:
22: }
23: return items;
24: }
25:
26: private void addItemsFromPage(WikiPage itemPage, List items)
27: throws Exception {
28: List itemsOnThisPage = getItemsFromPage(itemPage);
29: items.addAll(itemsOnThisPage);
30: }
31:
32: protected abstract List getItemsFromPage(WikiPage page)
33: throws Exception;
34: }
|