1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 package org.dbunit;
23
24 import java.util.*;
25
26
27
28
29
30
31 public class DatabaseProfile
32 {
33 private static final String[] EMPTY_ARRAY = new String[0];
34
35 public static final String DATABASE_PROFILE = "dbunit.profile";
36 private static final String PROFILE_DRIVER_CLASS =
37 "dbunit.profile.driverClass";
38 private static final String PROFILE_URL = "dbunit.profile.url";
39 private static final String PROFILE_SCHEMA = "dbunit.profile.schema";
40 private static final String PROFILE_USER = "dbunit.profile.user";
41 private static final String PROFILE_PASSWORD = "dbunit.profile.password";
42 private static final String PROFILE_UNSUPPORTED_FEATURES =
43 "dbunit.profile.unsupportedFeatures";
44 private static final String PROFILE_DDL = "dbunit.profile.ddl";
45 private static final String PROFILE_MULTILINE_SUPPORT =
46 "dbunit.profile.multiLineSupport";
47
48 private final Properties _properties;
49
50 public DatabaseProfile(Properties properties)
51 {
52 _properties = properties;
53
54
55
56
57
58
59 }
60
61 public String getActiveProfile()
62 {
63 return _properties.getProperty(DATABASE_PROFILE);
64 }
65
66 public String getDriverClass()
67 {
68 return _properties.getProperty(PROFILE_DRIVER_CLASS);
69 }
70
71 public String getConnectionUrl()
72 {
73 return _properties.getProperty(PROFILE_URL);
74 }
75
76 public String getSchema()
77 {
78 return _properties.getProperty(PROFILE_SCHEMA, null);
79 }
80
81 public String getUser()
82 {
83 return _properties.getProperty(PROFILE_USER);
84 }
85
86 public String getPassword()
87 {
88 return _properties.getProperty(PROFILE_PASSWORD);
89 }
90
91 public String getProfileDdl()
92 {
93 return _properties.getProperty(PROFILE_DDL);
94 }
95
96 public boolean getProfileMultilineSupport()
97 {
98 return Boolean
99 .valueOf(_properties.getProperty(PROFILE_MULTILINE_SUPPORT));
100 }
101
102 public String[] getUnsupportedFeatures()
103 {
104 String property = _properties.getProperty(PROFILE_UNSUPPORTED_FEATURES);
105
106
107 if (property == null)
108 {
109 return EMPTY_ARRAY;
110 }
111
112 List<String> stringList = new ArrayList<String>();
113 for (final String token : property.split(","))
114 {
115 final String trimmed = token.trim();
116 if (!trimmed.isEmpty())
117 {
118 stringList.add(trimmed);
119 }
120 }
121 return stringList.toArray(new String[stringList.size()]);
122 }
123
124 }