1 21 22 package org.dbunit; 23 24 import java.util.ArrayList ; 25 import java.util.List ; 26 import java.util.Properties ; 27 import java.util.StringTokenizer ; 28 29 34 public class DatabaseProfile 35 { 36 private static final String PROFILE_PREFIX = "dbunit.profile"; 37 38 private static final String DRIVER_CLASS = "driverClass"; 39 private static final String CONNECTION_URL = "connectionUrl"; 40 private static final String SCHEMA = "schema"; 41 private static final String USER = "user"; 42 private static final String PASSWORD = "password"; 43 private static final String UNSUPPORTED_FEATURES = "unsupportedFeatures"; 44 45 private final Properties _properties; 46 47 public DatabaseProfile(Properties properties) 48 { 49 _properties = properties; 50 } 51 52 private String getPropertyKey(String name) 53 { 54 return PROFILE_PREFIX + "." + getActiveProfile() + "." + name; 55 } 56 57 public String getActiveProfile() 58 { 59 return _properties.getProperty(PROFILE_PREFIX); 60 } 61 62 public String getDriverClass() 63 { 64 return _properties.getProperty(getPropertyKey(DRIVER_CLASS)); 65 } 66 67 public String getConnectionUrl() 68 { 69 return _properties.getProperty(getPropertyKey(CONNECTION_URL)); 70 } 71 72 public String getSchema() 73 { 74 return _properties.getProperty(getPropertyKey(SCHEMA), null); 75 } 76 77 public String getUser() 78 { 79 return _properties.getProperty(getPropertyKey(USER)); 80 } 81 82 public String getPassword() 83 { 84 return _properties.getProperty(getPropertyKey(PASSWORD)); 85 } 86 87 public String [] getUnsupportedFeatures() 88 { 89 String property = _properties.getProperty( 90 getPropertyKey(UNSUPPORTED_FEATURES)); 91 92 List stringList = new ArrayList (); 93 StringTokenizer tokenizer = new StringTokenizer (property, ","); 94 while(tokenizer.hasMoreTokens()) 95 { 96 stringList.add(tokenizer.nextToken().trim()); 97 } 98 return (String [])stringList.toArray(new String [0]); 99 } 100 101 } 102 103 104 105 106 107 | Popular Tags |