Clover coverage report - baseCode - 0.2.5 Coverage timestamp: Tue Apr 12 2005 11:31:58 EDT FRAMES NO FRAMES |
file stats: | LOC: | 93 |  | Methods: | 8
| NCLOC: | 39 |  | Classes: | 1
30 day Evaluation Version distributed via the Maven Jar Repository. Clover is not free. You have 30 days to evaluate it. Please visit http://www.thecortex.net/clover to obtain a licensed version of Clover
Source file | Conditionals | Statements | Methods | TOTAL
AbstractGraph.java | 0% | 53.8% | 75% | 52% |

1 |  |
     /*
2 |  |
      * Created on Jun 20, 2004
3 |  |
      */
4 |  |
     package baseCode.dataStructure.graph;
5 |  |
6 |  |
     import java.util.Iterator;
7 |  |
     import java.util.LinkedHashMap;
8 |  |
     import java.util.Map;
9 |  |
     import java.util.Set;
10 |  |
11 |  |
     import baseCode.common.Visitable;
12 |  |
13 |  |
     /**
14 |  |
      * <p>
15 |  |
      * Copyright (c) Columbia University
16 |  |
      *
17 |  |
      * @author Paul Pavlidis
18 |  |
      * @version $Id: AbstractGraph.java,v 1.8 2004/07/29 08:38:49 pavlidis Exp $
19 |  |
      */
20 |  |
     public abstract class AbstractGraph implements Graph {
21 |  |
        protected Map items;
22 |  |
23 | 8 |
        public AbstractGraph() {
24 | 8 |
           items = new LinkedHashMap();
25 |  |
        }
26 |  |
27 |  |
        /**
28 |  |
         * Create a new graph from a set of nodes. This allows us to easily make subtrees.
29 |  |
         *
30 |  |
         * @param nodes Set of AbstractGraphNodes.
31 |  |
         */
32 | 0 |
        public AbstractGraph( Set nodes ) {
33 | 0 |
           items = new LinkedHashMap();
34 | 0 |
           for ( Iterator it = nodes.iterator(); it.hasNext(); ) {
35 | 0 |
              GraphNode n = ( GraphNode ) it.next();
36 | 0 |
              this.addNode( n.getKey(), n.getItem() );
37 |  |
           }
38 |  |
        }
39 |  |
40 |  |
        /**
41 |  |
         * @param node GraphNode
42 |  |
         */
43 | 4 |
        public void addNode( GraphNode node ) {
44 | 4 |
           node.setGraph( this );
45 | 4 |
           items.put( node.getKey(), node );
46 |  |
        }
47 |  |
48 |  |
        /**
49 |  |
         * Retrieve a node by key. To get the contents of a node use getNodeContents(key)
50 |  |
         *
51 |  |
         * @param key Object
52 |  |
         * @see #getNodeContents(Object)
53 |  |
         * @return AbstractGraphNode referenced by the key.
54 |  |
         */
55 | 350 |
        public GraphNode get( Object key ) {
56 | 350 |
           return ( GraphNode ) items.get( key );
57 |  |
        }
58 |  |
59 |  |
        /**
60 |  |
         * @return Map
61 |  |
         */
62 | 1 |
        public Map getItems() {
63 | 1 |
           return items;
64 |  |
        }
65 |  |
66 |  |
        /**
67 |  |
         * Retrieve the contents of a node by key.
68 |  |
         *
69 |  |
         * @see #get
70 |  |
         * @param key Object
71 |  |
         * @return The object contained by a node, not the node itself.
72 |  |
         */
73 | 201 |
        public Object getNodeContents( Object key ) {
74 | 201 |
           return ( ( GraphNode ) items.get( key ) ).getItem();
75 |  |
        }
76 |  |
77 |  |
        /**
78 |  |
         * @param key Object
79 |  |
         * @return true if the graph contains an item referenced by key, false otherwise.
80 |  |
         */
81 | 78 |
        public boolean containsKey( Object key ) {
82 | 78 |
           return items.containsKey( key );
83 |  |
        }
84 |  |
85 |  |
        /**
86 |  |
         * Reset the 'visited' marks of the graph to false.
87 |  |
         */
88 | 0 |
        public void unmarkAll() {
89 | 0 |
           for ( Iterator it = items.keySet().iterator(); it.hasNext(); ) {
90 | 0 |
              ( ( Visitable ) it.next() ).unMark();
91 |  |
           }
92 |  |
        }
93 |  |
     }