Author: mvdb
Date: Fri Jun 29 15:23:25 2007
New Revision: 552049
URL: http://svn.apache.org/viewvc?view=rev&rev=552049
Log:
Fix Gump build failure and also made sure the fix runs on BeanUtils 1.7. The
only solution I could find is to copy the ConvertUtils.convert( object ) code
and call an internal method from Betwixt itself.
If people want to use beanutils in the new way, it's up to them to create a new
defaultconverter.
Sanity check by Robert would be highly appreciated..
Modified:
jakarta/commons/proper/betwixt/trunk/src/java/org/apache/commons/betwixt/strategy/ConvertUtilsObjectStringConverter.java
Modified:
jakarta/commons/proper/betwixt/trunk/src/java/org/apache/commons/betwixt/strategy/ConvertUtilsObjectStringConverter.java
URL:
http://svn.apache.org/viewvc/jakarta/commons/proper/betwixt/trunk/src/java/org/apache/commons/betwixt/strategy/ConvertUtilsObjectStringConverter.java?view=diff&rev=552049&r1=552048&r2=552049
==============================================================================
---
jakarta/commons/proper/betwixt/trunk/src/java/org/apache/commons/betwixt/strategy/ConvertUtilsObjectStringConverter.java
(original)
+++
jakarta/commons/proper/betwixt/trunk/src/java/org/apache/commons/betwixt/strategy/ConvertUtilsObjectStringConverter.java
Fri Jun 29 15:23:25 2007
@@ -16,7 +16,10 @@
*/
package org.apache.commons.betwixt.strategy;
+import java.lang.reflect.Array;
+
import org.apache.commons.beanutils.ConvertUtils;
+import org.apache.commons.beanutils.Converter;
import org.apache.commons.betwixt.expression.Context;
/**
@@ -39,12 +42,42 @@
*/
public String objectToString(Object object, Class type, String flavour,
Context context) {
if ( object != null ) {
- String text = ConvertUtils.convert( object );
+ String text = convertInternal( object );
if ( text != null ) {
return text;
}
}
return "";
+ }
+
+ /**
+ * Contains the code from the beanutils 1.7.0 ConvertUtils.convert( Object
)
+ * This is to prevent backward compatibility issues, which cannot be solved
+ * in beanutils because of evolving functionality.<br/>
+ * Since the advise here is the override the objectToString methods anyway
+ * people can choose themselves to adhere to the new beanutils
functionality.
+ *
+ * @param value the value to convert to a String
+ * @return the String representation or null.
+ */
+ private String convertInternal( Object value ) {
+ if (value == null) {
+ return ((String) null);
+ } else if (value.getClass().isArray()) {
+ if (Array.getLength(value) < 1) {
+ return (null);
+ }
+ value = Array.get(value, 0);
+ if (value == null) {
+ return ((String) null);
+ } else {
+ Converter converter = ConvertUtils.lookup(String.class);
+ return ((String) converter.convert(String.class, value));
+ }
+ } else {
+ Converter converter = ConvertUtils.lookup(String.class);
+ return ((String) converter.convert(String.class, value));
+ }
}
/**
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]