1 21 package org.dbunit.dataset; 22 23 import org.dbunit.dataset.datatype.DataType; 24 25 30 public class MockTableMetaData extends AbstractTableMetaData 31 { 32 private String _tableName; 33 private Column[] _columns = new Column[0]; 34 private String [] _keyNames = new String [0]; 35 36 public MockTableMetaData() 37 { 38 } 39 40 public MockTableMetaData(String tableName, String [] columnNames) 41 { 42 _tableName = tableName; 43 setupColumns(columnNames); 44 } 45 46 public void setTableName(String tableName) 47 { 48 _tableName = tableName; 49 } 50 51 public void setupColumns(Column[] columns) 52 { 53 _columns = columns; 54 } 55 56 public void setupColumns(String [] columnNames) 57 { 58 Column[] columns = new Column[columnNames.length]; 59 for (int i = 0; i < columnNames.length; i++) 60 { 61 String columnName = columnNames[i]; 62 columns[i] = new Column(columnName, DataType.UNKNOWN); 63 } 64 _columns = columns; 65 } 66 67 public void setupPrimaryKeys(String [] keyNames) 68 { 69 _keyNames = keyNames; 70 } 71 72 75 public String getTableName() 76 { 77 return _tableName; 78 } 79 80 public Column[] getColumns() throws DataSetException 81 { 82 return _columns; 83 } 84 85 public Column[] getPrimaryKeys() throws DataSetException 86 { 87 return getPrimaryKeys(_columns, _keyNames); 88 } 89 } 90 | Popular Tags |