Author: doogie
Date: Mon Mar 1 05:07:00 2010 New Revision: 917377 URL: http://svn.apache.org/viewvc?rev=917377&view=rev Log: BUG FIX: Move node test to before the loadClass call. Modified: ofbiz/trunk/framework/base/src/org/ofbiz/base/util/ObjectType.java ofbiz/trunk/framework/base/src/org/ofbiz/base/util/test/ObjectTypeTests.java Modified: ofbiz/trunk/framework/base/src/org/ofbiz/base/util/ObjectType.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/util/ObjectType.java?rev=917377&r1=917376&r2=917377&view=diff ============================================================================== --- ofbiz/trunk/framework/base/src/org/ofbiz/base/util/ObjectType.java (original) +++ ofbiz/trunk/framework/base/src/org/ofbiz/base/util/ObjectType.java Mon Mar 1 05:07:00 2010 @@ -493,6 +493,15 @@ if (obj instanceof String && UtilValidate.isEmpty(obj)) { return null; } + if (obj instanceof Node) { + Node node = (Node) obj; + String nodeValue = node.getTextContent(); + if ("String".equals(type) || "java.lang.String".equals(type)) { + return nodeValue; + } else { + return simpleTypeConvert(nodeValue, type, format, timeZone, locale, noTypeFail); + } + } Class<?> targetClass = null; try { targetClass = loadClass(type); @@ -527,15 +536,6 @@ throw new GeneralException(e.getMessage(), e); } } - if (obj instanceof Node) { - Node node = (Node) obj; - String nodeValue = node.getTextContent(); - if (targetClass.equals(String.class)) { - return nodeValue; - } else { - return simpleTypeConvert(nodeValue, type, format, timeZone, locale, noTypeFail); - } - } // we can pretty much always do a conversion to a String, so do that here if (targetClass.equals(String.class)) { Debug.logWarning("No special conversion available for " + obj.getClass().getName() + " to String, returning object.toString().", module); Modified: ofbiz/trunk/framework/base/src/org/ofbiz/base/util/test/ObjectTypeTests.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/util/test/ObjectTypeTests.java?rev=917377&r1=917376&r2=917377&view=diff ============================================================================== --- ofbiz/trunk/framework/base/src/org/ofbiz/base/util/test/ObjectTypeTests.java (original) +++ ofbiz/trunk/framework/base/src/org/ofbiz/base/util/test/ObjectTypeTests.java Mon Mar 1 05:07:00 2010 @@ -199,7 +199,7 @@ simpleTypeConvertTest("String->String", "one", "String", "one"); simpleTypeConvertTest("String->String", "one", "java.lang.String", "one"); simpleTypeConvertTestSingleMulti("empty-String->anything", "", new String[] {"List", "Map"}, null); - //BUG simpleTypeConvertTestSingleMulti("empty-String->bad-class", "", new String[] {"no-class"}, null); + simpleTypeConvertTestSingleMulti("empty-String->bad-class", "", new String[] {"no-class"}, null); simpleTypeConvertTestError("String->error", "one", new String[] {}); simpleTypeConvertTestMultiMulti("String->Boolean(true)", new String[] {"true", " true ", " TrUe"}, new String[] {"Boolean", "java.lang.Boolean"}, Boolean.TRUE); simpleTypeConvertTestMultiMulti("String->Boolean(false)", new String[] {"false", " false ", " FaLsE"}, new String[] {"Boolean", "java.lang.Boolean"}, Boolean.FALSE); |
Free forum by Nabble | Edit this page |