Clover coverage report - brownies library - 1.0-beta-1 Coverage timestamp: 月 8 16 2004 17:14:42 GMT+09:00 FRAMES NO FRAMES |
file stats: | LOC: | 125 |  | Methods: | 11
| NCLOC: | 85 |  | 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
ArrayListMatrix.java | 0% | 0% | 0% | 0% |

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.ArrayList;
8 |  |
     import java.util.List;
9 |  |
10 |  |
     /**
11 |  |
      * @author Akima
12 |  |
      */
13 |  |
     public class ArrayListMatrix implements ListMatrix {
14 |  |
15 |  |
         /**
16 |  |
          * Constructor for ListMatrix.
17 |  |
          */
18 | 0 |
         public ArrayListMatrix() {
19 | 0 |
             super();
20 |  |
         }
21 |  |
22 |  |
         private ArrayList baseRows = new ArrayList();
23 |  |
24 | 0 |
         private List findByRow(int row) {
25 | 0 |
             if (row < baseRows.size()) {
26 | 0 |
                 return (List) baseRows.get(row);
27 |  |
             } else {
28 | 0 |
                 return null;
29 |  |
             }
30 |  |
         }
31 |  |
32 |  |
         /*
33 |  |
          * static private void addNullData(List dest, int reqestedIndex){ }
34 |  |
          */
35 |  |
36 | 0 |
         private List needByRow(int row) {
37 |  |
             //List result = findByRow(row);
38 | 0 |
             while (row >= baseRows.size()) {
39 | 0 |
                 baseRows.add(new ArrayList());
40 |  |
             }
41 | 0 |
             return (List) baseRows.get(row);
42 |  |
         }
43 |  |
44 | 0 |
         public Object get(int col, int row) {
45 | 0 |
             List source = findByRow(row);
46 | 0 |
             if (source == null)
47 | 0 |
                 return null;
48 | 0 |
             if (col < source.size()) {
49 | 0 |
                 return source.get(col);
50 |  |
             } else {
51 | 0 |
                 return null;
52 |  |
             }
53 |  |
         }
54 |  |
55 | 0 |
         public void put(int col, int row, Object value) {
56 | 0 |
             List dest = needByRow(row);
57 | 0 |
             while (col >= dest.size()) {
58 | 0 |
                 dest.add(null);
59 |  |
             }
60 | 0 |
             dest.set(col, value);
61 |  |
         }
62 |  |
63 | 0 |
         public void remove(int col, int row) {
64 | 0 |
             List source = findByRow(row);
65 | 0 |
             if (source == null)
66 | 0 |
                 return;
67 | 0 |
             source.remove(col);
68 |  |
         }
69 |  |
70 | 0 |
         public void clear() {
71 | 0 |
             baseRows.clear();
72 |  |
         }
73 |  |
74 |  |
         /**
75 |  |
          *
76 |  |
          */
77 | 0 |
         public int colSize() {
78 | 0 |
             int result = 0;
79 | 0 |
             for (int i = 0; i < baseRows.size(); i++) {
80 | 0 |
                 List row = (List) baseRows.get(i);
81 | 0 |
                 if (result < row.size()) {
82 | 0 |
                     result = row.size();
83 |  |
                 }
84 |  |
             }
85 | 0 |
             return result;
86 |  |
         }
87 |  |
88 |  |
         /**
89 |  |
          */
90 | 0 |
         public int rowSize() {
91 | 0 |
             return baseRows.size();
92 |  |
         }
93 |  |
94 |  |
         /**
95 |  |
          */
96 | 0 |
         public List getCol(int colKey) {
97 | 0 |
             if (colKey < colSize()) {
98 | 0 |
                 List result = new ArrayList();
99 | 0 |
                 int rowCount = rowSize();
100 | 0 |
                 for (int i = 0; i < rowCount; i++) {
101 | 0 |
                     result.add(get(colKey, i));
102 |  |
                 }
103 | 0 |
                 return result;
104 |  |
             } else {
105 | 0 |
                 return null;
106 |  |
             }
107 |  |
         }
108 |  |
109 |  |
         /**
110 |  |
          */
111 | 0 |
         public List getRow(int rowKey) {
112 | 0 |
             List source = findByRow(rowKey);
113 | 0 |
             if (source != null) {
114 | 0 |
                 List result = new ArrayList(source);
115 | 0 |
                 int colCount = colSize();
116 | 0 |
                 while (result.size() < colCount) {
117 | 0 |
                     result.add(null);
118 |  |
                 }
119 | 0 |
                 return result;
120 |  |
             } else {
121 | 0 |
                 return null;
122 |  |
             }
123 |  |
         }
124 |  |
125 |  |
     }