1 11 package org.eclipse.help.internal.toc; 12 13 import java.util.ArrayList ; 14 import java.util.Collections ; 15 import java.util.Iterator ; 16 import java.util.List ; 17 18 import org.eclipse.help.internal.FilterableHelpElement; 19 20 23 abstract class TocNode extends FilterableHelpElement implements ITocNode { 24 protected List children; 25 protected List parents; 26 27 31 public void addChild(ITocNode child) { 32 if (children == null) 33 children = new ArrayList (); 34 children.add(child); 35 if (child instanceof TocNode) 36 ((TocNode) child).addParent(this); 37 } 38 41 protected void addParent(ITocNode parent) { 42 if (parents == null) 43 parents = new ArrayList (); 44 parents.add(parent); 45 } 46 47 52 public List getChildren() { 53 if (children == null) 54 return Collections.EMPTY_LIST; 55 return children; 56 } 57 62 protected List getParents() { 63 if (parents == null) 64 return Collections.EMPTY_LIST; 65 return parents; 66 } 67 68 71 public List getChildTopics() { 72 if (children == null) 73 return Collections.EMPTY_LIST; 74 List childTopics = new ArrayList (children.size()); 75 for (Iterator childrenIt = children.iterator(); childrenIt.hasNext();) { 76 TocNode c = (TocNode) childrenIt.next(); 77 if ((c instanceof Topic)) { 78 childTopics.add(c); 79 } else { 80 childTopics.addAll(c.getChildTopics()); 83 } 84 } 85 return childTopics; 86 } 87 } 88 | Popular Tags |