1 21 22 package org.dbunit.dataset; 23 24 import org.dbunit.dataset.filter.IColumnFilter; 25 26 import java.util.ArrayList ; 27 import java.util.List ; 28 29 34 public abstract class AbstractTableMetaData implements ITableMetaData 35 { 36 private static final Column[] EMPTY_COLUMNS = new Column[0]; 37 38 protected static Column[] getPrimaryKeys(Column[] columns, String [] keyNames) 39 { 40 if (keyNames == null || keyNames.length == 0) 41 { 42 return EMPTY_COLUMNS; 43 } 44 45 List keyList = new ArrayList (); 46 for (int i = 0; i < keyNames.length; i++) 47 { 48 Column primaryKey = DataSetUtils.getColumn(keyNames[i], columns); 49 if (primaryKey != null) 50 { 51 keyList.add(primaryKey); 52 } 53 } 54 55 return (Column[])keyList.toArray(new Column[0]); 56 } 57 58 protected static Column[] getPrimaryKeys(String tableName, Column[] columns, 59 IColumnFilter columnFilter) 60 { 61 List keyList = new ArrayList (); 62 for (int i = 0; i < columns.length; i++) 63 { 64 Column column = columns[i]; 65 if (columnFilter.accept(tableName, column)) 66 { 67 keyList.add(column); 68 } 69 } 70 71 return (Column[])keyList.toArray(new Column[0]); 72 } 73 } 74 75 76 77 78 79 | Popular Tags |