dmitri 2004/06/29 14:50:02
Modified: jxpath/src/java/org/apache/commons/jxpath/util
BasicTypeConverter.java
jxpath/src/test/org/apache/commons/jxpath/util
BasicTypeConverterTest.java
Log:
Integrated with BeanUtils ConverterUtils
Revision Changes Path
1.14 +8 -3 jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/util/BasicTypeConverter.java
Index: BasicTypeConverter.java
===================================================================
RCS file: /home/cvs/jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/util/BasicTypeConverter.java,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- BasicTypeConverter.java 25 Mar 2004 05:42:01 -0000 1.13
+++ BasicTypeConverter.java 29 Jun 2004 21:50:02 -0000 1.14
@@ -25,9 +25,10 @@
import java.util.List;
import java.util.Set;
+import org.apache.commons.beanutils.ConvertUtils;
import org.apache.commons.jxpath.JXPathException;
-import org.apache.commons.jxpath.Pointer;
import org.apache.commons.jxpath.NodeSet;
+import org.apache.commons.jxpath.Pointer;
/**
* The default implementation of TypeConverter.
@@ -160,7 +161,7 @@
else if (object instanceof Pointer) {
return canConvert(((Pointer) object).getValue(), toType);
}
- return false;
+ return ConvertUtils.lookup(toType) != null;
}
/**
@@ -292,6 +293,10 @@
}
}
+ if (ConvertUtils.lookup(toType) != null) {
+ return ConvertUtils.convert(object.toString(), toType);
+ }
+
throw new RuntimeException(
"Cannot convert " + object.getClass() + " to " + toType);
}
1.7 +6 -1 jakarta-commons/jxpath/src/test/org/apache/commons/jxpath/util/BasicTypeConverterTest.java
Index: BasicTypeConverterTest.java
===================================================================
RCS file: /home/cvs/jakarta-commons/jxpath/src/test/org/apache/commons/jxpath/util/BasicTypeConverterTest.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- BasicTypeConverterTest.java 29 Feb 2004 14:17:46 -0000 1.6
+++ BasicTypeConverterTest.java 29 Jun 2004 21:50:02 -0000 1.7
@@ -16,6 +16,7 @@
package org.apache.commons.jxpath.util;
import java.lang.reflect.Array;
+import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
@@ -166,4 +167,8 @@
}
}, Integer.class, new Integer(9));
}
+
+ public void testBeanUtilsConverter() {
+ assertConversion("12", BigDecimal.class, new BigDecimal(12));
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
|