|
From: <mla...@us...> - 2002-08-04 01:07:15
|
Update of /cvsroot/dbunit/dbunit/src/java/org/dbunit/dataset
In directory usw-pr-cvs1:/tmp/cvs-serv24183/dbunit/src/java/org/dbunit/dataset
Modified Files:
DataSetUtils.java
Log Message:
I added a system property that allows schema, table and column names escaping.
The property value is an escape pattern where the ? is replaced by the name.
For example, the pattern "[?]" is expanded as "[MY_NAME]" for a table named
"MY_TABLE".
Attention this feature is not compatible with the qualified names name feature!
Index: DataSetUtils.java
===================================================================
RCS file: /cvsroot/dbunit/dbunit/src/java/org/dbunit/dataset/DataSetUtils.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -C2 -d -r1.12 -r1.13
*** DataSetUtils.java 3 Aug 2002 02:26:40 -0000 1.12
--- DataSetUtils.java 4 Aug 2002 01:07:13 -0000 1.13
***************
*** 86,89 ****
--- 86,102 ----
public static String getQualifiedName(String prefix, String name)
{
+ return getQualifiedName(prefix, name, false);
+ }
+
+ public static String getQualifiedName(String prefix, String name,
+ boolean escape)
+ {
+ if (escape)
+ {
+ String pattern = System.getProperty("dbunit.name.escapePattern");
+ prefix = getEscapedName(prefix, pattern);
+ name = getEscapedName(name, pattern);
+ }
+
if (prefix == null || prefix.equals("") || name.indexOf(".") >= 0)
{
***************
*** 92,95 ****
--- 105,126 ----
return prefix + "." + name;
+ }
+
+ public static String getEscapedName(String name, String pattern)
+ {
+ if (name == null || pattern == null)
+ {
+ return name;
+ }
+
+ int index = pattern.indexOf("?");
+ if (index >=0 )
+ {
+ String prefix = pattern.substring(0, index);
+ String suffix = pattern.substring(index + 1);
+
+ return prefix + name + suffix;
+ }
+ return name;
}
|