Coverage Report - net.sourceforge.combean.graph.containers.MapAsNodeNumbering
 
Classes in this File Line Coverage Branch Coverage Complexity
MapAsNodeNumbering
33%
5/15
0%
0/2
0
 
 1  
 /*
 2  
     This file is part of Combean.
 3  
 
 4  
     Combean is free software; you can redistribute it and/or modify
 5  
     it under the terms of the GNU General Public License as published by
 6  
     the Free Software Foundation; either version 2 of the License, or
 7  
     (at your option) any later version.
 8  
 
 9  
     Combean is distributed in the hope that it will be useful,
 10  
     but WITHOUT ANY WARRANTY; without even the implied warranty of
 11  
     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 12  
     GNU General Public License for more details.
 13  
 
 14  
     You should have received a copy of the GNU General Public License
 15  
     along with Combean; if not, write to the Free Software
 16  
     Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 17  
 */
 18  
 /*
 19  
  * Created on 17.04.2005
 20  
  *
 21  
  */
 22  
 package net.sourceforge.combean.graph.containers;
 23  
 
 24  
 import java.util.HashMap;
 25  
 import java.util.Map;
 26  
 
 27  
 import net.sourceforge.combean.interfaces.graph.Graph;
 28  
 import net.sourceforge.combean.interfaces.graph.Node;
 29  
 import net.sourceforge.combean.interfaces.graph.containers.NodeNumbering;
 30  
 
 31  
 /**
 32  
  * @author schickin
 33  
  *
 34  
  */
 35  
 public class MapAsNodeNumbering implements NodeNumbering {
 36  
     
 37  3
     private Map<Node, Integer> jMap = null;
 38  3
     private int defaultValue = 0;
 39  
 
 40  
     /**
 41  
      * Constructor. Use a HashMap internally
 42  
      */
 43  
     public MapAsNodeNumbering() {
 44  3
         super();
 45  
         
 46  3
         this.jMap = new HashMap<Node, Integer>();
 47  3
     }
 48  
 
 49  
     /* (non-Javadoc)
 50  
      * @see net.sourceforge.combean.interfaces.graph.containers.NodeNumbering#init(net.sourceforge.combean.interfaces.graph.Graph)
 51  
      */
 52  
     public void init(Graph g) {
 53  0
         this.jMap.clear();
 54  0
     }
 55  
 
 56  
     /* (non-Javadoc)
 57  
      * @see net.sourceforge.combean.interfaces.graph.containers.NodeNumbering#fill(int)
 58  
      */
 59  
     public void fill(int num) {
 60  0
         this.defaultValue = num;
 61  0
     }
 62  
 
 63  
     /* (non-Javadoc)
 64  
      * @see net.sourceforge.combean.interfaces.graph.containers.NodeNumbering#setNumber(net.sourceforge.combean.interfaces.graph.Node, int)
 65  
      */
 66  
     public void setNumber(Node v, int num) {
 67  0
         this.jMap.put(v, new Integer(num));
 68  0
     }
 69  
 
 70  
     /* (non-Javadoc)
 71  
      * @see net.sourceforge.combean.interfaces.graph.containers.NodeNumbering#getNumber(net.sourceforge.combean.interfaces.graph.Node)
 72  
      */
 73  
     public int getNumber(Node v) {
 74  0
         Object entryInMap = this.jMap.get(v);
 75  0
         if (entryInMap == null) {
 76  0
             return this.defaultValue;
 77  
         }
 78  0
         return ((Number) entryInMap).intValue();
 79  
     }
 80  
 
 81  
 }