1 21 22 package org.dbunit.dataset; 23 24 25 34 public class LowerCaseDataSet extends AbstractDataSet 35 { 36 private final IDataSet _dataSet; 37 38 public LowerCaseDataSet(ITable table) throws DataSetException 39 { 40 this(new DefaultDataSet(table)); 41 } 42 43 public LowerCaseDataSet(ITable[] tables) throws DataSetException 44 { 45 this(new DefaultDataSet(tables)); 46 } 47 48 public LowerCaseDataSet(IDataSet dataSet) throws DataSetException 49 { 50 _dataSet = dataSet; 51 } 52 53 private ITable createLowerTable(ITable table) throws DataSetException 54 { 55 return new CompositeTable( 56 new LowerCaseTableMetaData(table.getTableMetaData()), table); 57 } 58 59 62 protected ITableIterator createIterator(boolean reversed) 63 throws DataSetException 64 { 65 return new LowerCaseIterator(reversed ? 66 _dataSet.reverseIterator() : _dataSet.iterator()); 67 } 68 69 72 public String [] getTableNames() throws DataSetException 73 { 74 String [] tableNames = super.getTableNames(); 75 for (int i = 0; i < tableNames.length; i++) 76 { 77 tableNames[i] = tableNames[i].toLowerCase(); 78 } 79 return tableNames; 80 } 81 82 public ITableMetaData getTableMetaData(String tableName) throws DataSetException 83 { 84 return new LowerCaseTableMetaData(super.getTableMetaData(tableName)); 85 } 86 87 public ITable getTable(String tableName) throws DataSetException 88 { 89 return createLowerTable(super.getTable(tableName)); 90 } 91 92 95 private class LowerCaseIterator implements ITableIterator 96 { 97 private final ITableIterator _iterator; 98 99 public LowerCaseIterator(ITableIterator iterator) 100 { 101 _iterator = iterator; 102 } 103 104 107 public boolean next() throws DataSetException 108 { 109 return _iterator.next(); 110 } 111 112 public ITableMetaData getTableMetaData() throws DataSetException 113 { 114 return new LowerCaseTableMetaData(_iterator.getTableMetaData()); 115 } 116 117 public ITable getTable() throws DataSetException 118 { 119 return createLowerTable(_iterator.getTable()); 120 } 121 } 122 } 123 124 125 126 127 128 129 | Popular Tags |