1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 package org.dbunit.dataset;
22
23 import org.slf4j.Logger;
24 import org.slf4j.LoggerFactory;
25
26
27
28
29
30
31 public abstract class AbstractTable implements ITable {
32
33
34
35
36 private static final Logger logger =
37 LoggerFactory.getLogger(AbstractTable.class);
38
39 protected void assertValidRowIndex(int row) throws DataSetException {
40 if (logger.isDebugEnabled()) {
41 logger.debug("assertValidRowIndex(row={}) - start", Integer
42 .toString(row));
43 }
44
45 assertValidRowIndex(row, getRowCount());
46 }
47
48 protected void assertValidRowIndex(int row, int rowCount)
49 throws DataSetException {
50 if (logger.isDebugEnabled()) {
51 logger.debug("assertValidRowIndex(row={}, rowCount={}) - start",
52 Integer.toString(row), Integer.toString(rowCount));
53 }
54
55 if (row < 0) {
56 throw new RowOutOfBoundsException(row + " < 0");
57 }
58
59 if (row >= rowCount) {
60 throw new RowOutOfBoundsException(row + " >= " + rowCount);
61 }
62 }
63
64 protected void assertValidColumn(String columnName) throws DataSetException {
65 logger.debug("assertValidColumn(columnName={}) - start", columnName);
66
67 ITableMetaData metaData = getTableMetaData();
68
69
70 Columns.getColumnValidated(columnName, metaData.getColumns(), metaData
71 .getTableName());
72 }
73
74 protected int getColumnIndex(String columnName) throws DataSetException {
75 logger.debug("getColumnIndex(columnName={}) - start", columnName);
76
77 ITableMetaData metaData = getTableMetaData();
78 return metaData.getColumnIndex(columnName);
79 }
80 }