View Javadoc

1   package cz.cuni.amis.pogamut.shady;
2   
3   import cz.cuni.amis.pogamut.sposh.exceptions.MissingRootException;
4   import java.util.Collections;
5   import java.util.List;
6   
7   /**
8    * This class contains all nodes of one shade plan.
9    * @author Honza
10   */
11  public class ShadeTree {
12      public final static String ROOT = "root";
13      private final List<ShadeNode> nodesUm;
14  
15      /**
16       * Create new tree containing all nodes.
17       * @param nodes
18       */
19      ShadeTree(List<ShadeNode> nodes) {
20          this.nodesUm = Collections.unmodifiableList(nodes);
21      }
22  
23      /**
24       * Find root of the plan.
25       * @return the root. If no root is found, throw {@link MissingRootException}
26       */
27      public ShadeNode getRoot() {
28          for (ShadeNode node : nodesUm)
29              if (ROOT.equals(node.getName()))
30                  return node;
31          throw new MissingRootException(ROOT);
32      }
33  
34      /**
35       * Find the node of this plan with specified name and return it.
36       * @param name name of the node we are looking for.
37       * @return found node or null if no such node exists.
38       */
39      public ShadeNode findNode(String name) {
40          throw new UnsupportedOperationException("Not yet implemented");
41      }
42  }