Clover coverage report - brownies library - 1.0-beta-1
Coverage timestamp: 月 8 16 2004 17:14:42 GMT+09:00
file stats: LOC: 123   Methods: 12
NCLOC: 76   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
AbstractMapMatrix.java 0% 0% 0% 0%
coverage
 1   
 /*
 2   
  * Joey and its relative products are published under the terms
 3   
  * of the Apache Software License.
 4   
  */
 5   
 package org.asyrinx.brownie.core.collection.matrix;
 6   
 
 7   
 import java.util.Iterator;
 8   
 import java.util.Map;
 9   
 import java.util.Set;
 10   
 
 11   
 /**
 12   
  * @author Akima
 13   
  */
 14   
 public abstract class AbstractMapMatrix implements MapMatrix {
 15   
 
 16   
     /**
 17   
      * Constructor for AbstractMapMatrix.
 18   
      */
 19  0
     public AbstractMapMatrix() {
 20  0
         super();
 21   
     }
 22   
 
 23   
     /**
 24   
      * @see java.lang.Object#toString()
 25   
      */
 26  0
     public String toString() {
 27  0
         return String.valueOf(baseRows);
 28   
     }
 29   
 
 30   
     private Map baseRows = newBaseRowsMap();
 31   
 
 32  0
     private Map findByRow(Object row) {
 33  0
         return (Map) baseRows.get(row);
 34   
     }
 35   
 
 36   
     abstract protected Map newRowMap();
 37   
 
 38   
     abstract protected Map newBaseRowsMap();
 39   
 
 40   
     abstract protected Map newGetColResult();
 41   
 
 42   
     abstract protected Map newGetRowResult(Map source);
 43   
 
 44   
     abstract protected Set newColKeySet();
 45   
 
 46   
     abstract protected Set newRowKeySet(Set source);
 47   
 
 48  0
     private Map needByRow(Object row) {
 49  0
         Map result = findByRow(row);
 50  0
         if (result == null) {
 51  0
             result = newRowMap();
 52  0
             baseRows.put(row, result);
 53   
         }
 54  0
         return result;
 55   
     }
 56   
 
 57  0
     public Object get(Object col, Object row) {
 58  0
         Map source = findByRow(row);
 59  0
         if (source == null)
 60  0
             return null;
 61  0
         return source.get(col);
 62   
     }
 63   
 
 64  0
     public void put(Object col, Object row, Object value) {
 65  0
         Map dest = needByRow(row);
 66  0
         dest.put(col, value);
 67   
     }
 68   
 
 69  0
     public void remove(Object col, Object row) {
 70  0
         Map source = findByRow(row);
 71  0
         if (source == null)
 72  0
             return;
 73  0
         source.remove(col);
 74   
     }
 75   
 
 76  0
     public void clear() {
 77  0
         baseRows.clear();
 78   
     }
 79   
 
 80   
     /**
 81   
      *  
 82   
      */
 83  0
     public Set colKeySet() {
 84  0
         Set result = newColKeySet();
 85  0
         Iterator iter = baseRows.keySet().iterator();
 86  0
         while (iter.hasNext()) {
 87  0
             Map row = (Map) baseRows.get(iter.next());
 88  0
             result.addAll(row.keySet());
 89   
         }
 90  0
         return result;
 91   
     }
 92   
 
 93   
     /**
 94   
      *  
 95   
      */
 96  0
     public Set rowKeySet() {
 97  0
         Set result = newRowKeySet(baseRows.keySet());
 98  0
         return result;
 99   
     }
 100   
 
 101   
     /**
 102   
      *  
 103   
      */
 104  0
     public Map getCol(Object colKey) {
 105  0
         Map result = newGetColResult();
 106  0
         Iterator iter = baseRows.keySet().iterator();
 107  0
         while (iter.hasNext()) {
 108  0
             Object rowKey = iter.next();
 109  0
             Map row = (Map) baseRows.get(rowKey);
 110  0
             Object val = row.get(colKey);
 111  0
             if (val != null)
 112  0
                 result.put(rowKey, val);
 113   
         }
 114  0
         return result;
 115   
     }
 116   
 
 117   
     /**
 118   
      *  
 119   
      */
 120  0
     public Map getRow(Object rowKey) {
 121  0
         return newGetRowResult(findByRow(rowKey));
 122   
     }
 123   
 }