1 22 23 package org.dbunit.dataset; 24 25 26 31 public abstract class AbstractTable implements ITable 32 { 33 protected void assertValidRowIndex(int row) throws DataSetException 34 { 35 assertValidRowIndex(row, getRowCount()); 36 } 37 38 protected void assertValidRowIndex(int row, int rowCount) 39 throws DataSetException 40 { 41 if (row < 0) 42 { 43 throw new RowOutOfBoundsException(row + " < 0"); 44 } 45 46 if (row >= rowCount) 47 { 48 throw new RowOutOfBoundsException(row + " > " + rowCount); 49 } 50 } 51 52 protected void assertValidColumn(String columnName) throws DataSetException 53 { 54 ITableMetaData metaData = getTableMetaData(); 55 if (DataSetUtils.getColumn(columnName, metaData.getColumns()) == null) 56 { 57 throw new NoSuchColumnException(metaData.getTableName() + "." + columnName); 58 } 59 } 60 61 protected int getColumnIndex(String columnName) throws DataSetException 62 { 63 ITableMetaData metaData = getTableMetaData(); 64 Column[] columns = metaData.getColumns(); 65 for (int i = 0; i < columns.length; i++) 66 { 67 Column column = columns[i]; 68 if (column.getColumnName().equalsIgnoreCase(columnName)) 69 { 70 return i; 71 } 72 } 73 74 throw new NoSuchColumnException(metaData.getTableName() + "." + columnName); 75 } 76 77 80 } 98 99 100 101 102 103 104 | Popular Tags |