1
2
3
4
5
6
7
8
9
10
11 package de.jaret.util.ui.table.model.simple;
12
13 import de.jaret.util.ui.table.model.IRow;
14
15 /***
16 * Simple row implementation based on it's index, used as a marker in the SimpleJaretTableModel.
17 *
18 * @author kliem
19 * @version $Id: SimpleRow.java 180 2007-01-07 18:44:01Z olk $
20 */
21 public class SimpleRow implements IRow {
22 /*** index of the column. */
23 private int _index;
24
25 /***
26 * Constructor.
27 *
28 * @param idx index
29 */
30 public SimpleRow(int idx) {
31 _index = idx;
32 }
33
34 /***
35 * {@inheritDoc}
36 */
37 public String getId() {
38 return Integer.toString(_index);
39 }
40
41 /***
42 * Retrieve the index of the row.
43 *
44 * @return index of the row
45 */
46 public int getIndex() {
47 return _index;
48 }
49
50 /***
51 * {@inheritDoc} Equals based on the index of the row.
52 */
53 public boolean equals(Object obj) {
54 if (obj == null) {
55 return false;
56 }
57 if (obj instanceof SimpleRow) {
58 SimpleRow r = (SimpleRow) obj;
59 return _index == r.getIndex();
60 } else {
61 return false;
62 }
63 }
64
65 /***
66 * {@inheritDoc} hashcode based on the index of the column.
67 */
68 public int hashCode() {
69 return _index;
70 }
71
72 }