01: package org.drools.brms.client.decisiontable.model;
02:
03: /*
04: * Copyright 2005 JBoss Inc
05: *
06: * Licensed under the Apache License, Version 2.0 (the "License");
07: * you may not use this file except in compliance with the License.
08: * You may obtain a copy of the License at
09: *
10: * http://www.apache.org/licenses/LICENSE-2.0
11: *
12: * Unless required by applicable law or agreed to in writing, software
13: * distributed under the License is distributed on an "AS IS" BASIS,
14: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15: * See the License for the specific language governing permissions and
16: * limitations under the License.
17: */
18:
19: import java.util.HashMap;
20: import java.util.Iterator;
21: import java.util.Map;
22:
23: public class Row {
24: private Map cells = new HashMap();
25: private DecisionTable parent;
26:
27: Row(DecisionTable dt) {
28: this .parent = dt;
29: }
30:
31: void addCell(final Cell cell) {
32: cells.put(cell.getColumn(), cell);
33: }
34:
35: int getIndex() {
36: return parent.getRowIndex(this );
37: }
38:
39: public Cell getCell(Column column) {
40: return (Cell) cells.get(column);
41: }
42:
43: public Cell getCell(int col) {
44: Iterator columns = parent.getColumns().iterator();
45: int i = 0;
46: Column column = null;
47: while (i <= col) {
48: column = (Column) columns.next();
49: Cell cell = (Cell) cells.get(column);
50: if (cell != null) {
51: i++;
52: }
53: }
54: return getCell(column);
55: }
56:
57: public void removeColumn(Column nextColumn) {
58: cells.remove(nextColumn);
59: }
60: }
|