1 21 package org.dbunit.database; 22 23 import org.dbunit.database.statement.PreparedStatementFactory; 24 import org.dbunit.dataset.datatype.DefaultDataTypeFactory; 25 26 import java.util.HashMap ; 27 import java.util.HashSet ; 28 import java.util.Map ; 29 import java.util.Set ; 30 31 37 public class DatabaseConfig 38 { 39 public static final String PROPERTY_STATEMENT_FACTORY = 40 "http://www.dbunit.org/properties/statementFactory"; 41 public static final String PROPERTY_RESULTSET_TABLE_FACTORY = 42 "http://www.dbunit.org/properties/resultSetTableFactory"; 43 public static final String PROPERTY_DATATYPE_FACTORY = 44 "http://www.dbunit.org/properties/datatypeFactory"; 45 public static final String PROPERTY_ESCAPE_PATTERN = 46 "http://www.dbunit.org/properties/escapePattern"; 47 public static final String PROPERTY_TABLE_TYPE = 48 "http://www.dbunit.org/properties/tableType"; 49 public static final String PROPERTY_PRIMARY_KEY_FILTER = 50 "http://www.dbunit.org/properties/primaryKeyFilter"; 51 52 public static final String FEATURE_QUALIFIED_TABLE_NAMES = 53 "http://www.dbunit.org/features/qualifiedTableNames"; 54 public static final String FEATURE_BATCHED_STATEMENTS = 55 "http://www.dbunit.org/features/batchedStatements"; 56 public static final String FEATURE_DATATYPE_WARNING = 57 "http://www.dbunit.org/features/datatypeWarning"; 58 59 private static final DefaultDataTypeFactory DEFAULT_DATA_TYPE_FACTORY = 60 new DefaultDataTypeFactory(); 61 private static final PreparedStatementFactory PREPARED_STATEMENT_FACTORY = 62 new PreparedStatementFactory(); 63 private static final CachedResultSetTableFactory RESULT_SET_TABLE_FACTORY = 64 new CachedResultSetTableFactory(); 65 private static final String DEFAULT_ESCAPE_PATTERN = null; 66 private static final String [] DEFAULT_TABLE_TYPE = {"TABLE"}; 67 68 private Set _featuresSet = new HashSet (); 69 private Map _propertyMap = new HashMap (); 70 71 public DatabaseConfig() 72 { 73 setFeature(FEATURE_BATCHED_STATEMENTS, false); 74 setFeature(FEATURE_QUALIFIED_TABLE_NAMES, false); 75 setFeature(FEATURE_DATATYPE_WARNING, true); 76 77 setProperty(PROPERTY_STATEMENT_FACTORY, PREPARED_STATEMENT_FACTORY); 78 setProperty(PROPERTY_RESULTSET_TABLE_FACTORY, RESULT_SET_TABLE_FACTORY); 79 setProperty(PROPERTY_DATATYPE_FACTORY, DEFAULT_DATA_TYPE_FACTORY); 80 setProperty(PROPERTY_ESCAPE_PATTERN, DEFAULT_ESCAPE_PATTERN); 81 setProperty(PROPERTY_TABLE_TYPE, DEFAULT_TABLE_TYPE); 82 } 83 84 90 public void setFeature(String name, boolean value) 91 { 92 if (value) 93 { 94 _featuresSet.add(name); 95 } 96 else 97 { 98 _featuresSet.remove(name); 99 } 100 } 101 102 108 public boolean getFeature(String name) 109 { 110 return _featuresSet.contains(name); 111 } 112 113 119 public void setProperty(String name, Object value) 120 { 121 _propertyMap.put(name, value); 122 } 123 124 130 public Object getProperty(String name) 131 { 132 return _propertyMap.get(name); 133 } 134 135 136 } 137 | Popular Tags |