Author: shawkins
Date: 2011-04-14 21:56:17 -0400 (Thu, 14 Apr 2011)
New Revision: 3092
Modified:
trunk/common-core/src/main/java/org/teiid/core/types/DataTypeManager.java
trunk/common-core/src/test/java/org/teiid/core/types/TestDataTypeManager.java
Log:
TEIID-1538 adding the catch all object to string conversion
Modified: trunk/common-core/src/main/java/org/teiid/core/types/DataTypeManager.java
===================================================================
--- trunk/common-core/src/main/java/org/teiid/core/types/DataTypeManager.java 2011-04-15
01:43:34 UTC (rev 3091)
+++ trunk/common-core/src/main/java/org/teiid/core/types/DataTypeManager.java 2011-04-15
01:56:17 UTC (rev 3092)
@@ -691,6 +691,13 @@
DataTypeManager.addTransform(new NullToAnyTransform(type));
}
}
+
+ DataTypeManager.addTransform(new AnyToStringTransform(DefaultDataClasses.OBJECT) {
+ @Override
+ public boolean isExplicit() {
+ return true;
+ }
+ });
}
Modified: trunk/common-core/src/test/java/org/teiid/core/types/TestDataTypeManager.java
===================================================================
---
trunk/common-core/src/test/java/org/teiid/core/types/TestDataTypeManager.java 2011-04-15
01:43:34 UTC (rev 3091)
+++
trunk/common-core/src/test/java/org/teiid/core/types/TestDataTypeManager.java 2011-04-15
01:56:17 UTC (rev 3092)
@@ -32,6 +32,7 @@
import org.junit.Test;
+@SuppressWarnings("nls")
public class TestDataTypeManager {
private void helpDetermineDataType(Object value, Class<?> expectedClass) {
@@ -206,9 +207,19 @@
DataTypeManager.DefaultDataTypes.OBJECT),
DataTypeManager.getImplicitConversions(DataTypeManager.DefaultDataTypes.INTEGER));
}
- @SuppressWarnings("unchecked")
@Test(expected=TransformationException.class) public void testStringToXML() throws
Exception {
DataTypeManager.transformValue("hello",
DataTypeManager.DefaultDataClasses.XML); //$NON-NLS-1$
}
+ static class Foo {
+ @Override
+ public String toString() {
+ return "hello";
+ }
+ }
+
+ @Test public void testObjectToString() throws Exception {
+ assertEquals("hello", DataTypeManager.transformValue(new Foo(),
DataTypeManager.DefaultDataClasses.STRING)); //$NON-NLS-1$
+ }
+
}
Show replies by date