Author: doogie
Date: Mon Mar 1 03:14:22 2010 New Revision: 917366 URL: http://svn.apache.org/viewvc?rev=917366&view=rev Log: BUG FIX: Add several missing Foo->List and Foo->Set converters. Modified: ofbiz/trunk/framework/base/src/org/ofbiz/base/conversion/BooleanConverters.java ofbiz/trunk/framework/base/src/org/ofbiz/base/conversion/DateTimeConverters.java ofbiz/trunk/framework/base/src/org/ofbiz/base/util/test/ObjectTypeTests.java Modified: ofbiz/trunk/framework/base/src/org/ofbiz/base/conversion/BooleanConverters.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/conversion/BooleanConverters.java?rev=917366&r1=917365&r2=917366&view=diff ============================================================================== --- ofbiz/trunk/framework/base/src/org/ofbiz/base/conversion/BooleanConverters.java (original) +++ ofbiz/trunk/framework/base/src/org/ofbiz/base/conversion/BooleanConverters.java Mon Mar 1 03:14:22 2010 @@ -18,6 +18,12 @@ *******************************************************************************/ package org.ofbiz.base.conversion; +import java.util.List; +import java.util.Set; + +import javolution.util.FastList; +import javolution.util.FastSet; + /** Boolean Converter classes. */ public class BooleanConverters implements ConverterLoader { public static class BooleanToInteger extends AbstractConverter<Boolean, Integer> { @@ -30,6 +36,30 @@ } } + public static class BooleanToList extends AbstractConverter<Boolean, List<Boolean>> { + public BooleanToList() { + super(Boolean.class, List.class); + } + + public List<Boolean> convert(Boolean obj) throws ConversionException { + List<Boolean> tempList = FastList.newInstance(); + tempList.add(obj); + return tempList; + } + } + + public static class BooleanToSet extends AbstractConverter<Boolean, Set<Boolean>> { + public BooleanToSet() { + super(Boolean.class, Set.class); + } + + public Set<Boolean> convert(Boolean obj) throws ConversionException { + Set<Boolean> tempSet = FastSet.newInstance(); + tempSet.add(obj); + return tempSet; + } + } + public static class BooleanToString extends AbstractConverter<Boolean, String> { public BooleanToString() { super(Boolean.class, String.class); Modified: ofbiz/trunk/framework/base/src/org/ofbiz/base/conversion/DateTimeConverters.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/conversion/DateTimeConverters.java?rev=917366&r1=917365&r2=917366&view=diff ============================================================================== --- ofbiz/trunk/framework/base/src/org/ofbiz/base/conversion/DateTimeConverters.java (original) +++ ofbiz/trunk/framework/base/src/org/ofbiz/base/conversion/DateTimeConverters.java Mon Mar 1 03:14:22 2010 @@ -21,9 +21,14 @@ import java.text.DateFormat; import java.text.ParseException; import java.util.Date; +import java.util.List; import java.util.Locale; +import java.util.Set; import java.util.TimeZone; +import javolution.util.FastList; +import javolution.util.FastSet; + import org.ofbiz.base.util.TimeDuration; import org.ofbiz.base.util.UtilDateTime; import org.ofbiz.base.util.UtilValidate; @@ -116,6 +121,18 @@ } } + public static class DurationToList extends AbstractConverter<TimeDuration, List<TimeDuration>> { + public DurationToList() { + super(TimeDuration.class, List.class); + } + + public List<TimeDuration> convert(TimeDuration obj) throws ConversionException { + List<TimeDuration> tempList = FastList.newInstance(); + tempList.add(obj); + return tempList; + } + } + public static class DurationToLong extends AbstractConverter<TimeDuration, Long> { public DurationToLong() { super(TimeDuration.class, Long.class); @@ -126,6 +143,18 @@ } } + public static class DurationToSet extends AbstractConverter<TimeDuration, Set<TimeDuration>> { + public DurationToSet() { + super(TimeDuration.class, Set.class); + } + + public Set<TimeDuration> convert(TimeDuration obj) throws ConversionException { + Set<TimeDuration> tempSet = FastSet.newInstance(); + tempSet.add(obj); + return tempSet; + } + } + public static class DurationToString extends AbstractConverter<TimeDuration, String> { public DurationToString() { super(TimeDuration.class, String.class); @@ -228,6 +257,30 @@ } } + public static class SqlDateToList extends AbstractConverter<java.sql.Date, List<java.sql.Date>> { + public SqlDateToList() { + super(java.sql.Date.class, List.class); + } + + public List<java.sql.Date> convert(java.sql.Date obj) throws ConversionException { + List<java.sql.Date> tempList = FastList.newInstance(); + tempList.add(obj); + return tempList; + } + } + + public static class SqlDateToSet extends AbstractConverter<java.sql.Date, Set<java.sql.Date>> { + public SqlDateToSet() { + super(java.sql.Date.class, Set.class); + } + + public Set<java.sql.Date> convert(java.sql.Date obj) throws ConversionException { + Set<java.sql.Date> tempSet = FastSet.newInstance(); + tempSet.add(obj); + return tempSet; + } + } + public static class SqlDateToString extends GenericLocalizedConverter<java.sql.Date, String> { public SqlDateToString() { super(java.sql.Date.class, String.class); @@ -249,6 +302,18 @@ } } + public static class SqlTimeToList extends AbstractConverter<java.sql.Time, List<java.sql.Time>> { + public SqlTimeToList() { + super(java.sql.Time.class, List.class); + } + + public List<java.sql.Time> convert(java.sql.Time obj) throws ConversionException { + List<java.sql.Time> tempList = FastList.newInstance(); + tempList.add(obj); + return tempList; + } + } + public static class SqlDateToTimestamp extends AbstractConverter<java.sql.Date, java.sql.Timestamp> { public SqlDateToTimestamp() { super(java.sql.Date.class, java.sql.Timestamp.class); @@ -259,6 +324,18 @@ } } + public static class SqlTimeToSet extends AbstractConverter<java.sql.Time, Set<java.sql.Time>> { + public SqlTimeToSet() { + super(java.sql.Time.class, Set.class); + } + + public Set<java.sql.Time> convert(java.sql.Time obj) throws ConversionException { + Set<java.sql.Time> tempSet = FastSet.newInstance(); + tempSet.add(obj); + return tempSet; + } + } + public static class SqlTimeToString extends GenericLocalizedConverter<java.sql.Time, String> { public SqlTimeToString() { super(java.sql.Time.class, String.class); @@ -476,6 +553,30 @@ } } + public static class TimestampToList extends AbstractConverter<java.sql.Timestamp, List<java.sql.Timestamp>> { + public TimestampToList() { + super(java.sql.Timestamp.class, List.class); + } + + public List<java.sql.Timestamp> convert(java.sql.Timestamp obj) throws ConversionException { + List<java.sql.Timestamp> tempList = FastList.newInstance(); + tempList.add(obj); + return tempList; + } + } + + public static class TimestampToSet extends AbstractConverter<java.sql.Timestamp, Set<java.sql.Timestamp>> { + public TimestampToSet() { + super(java.sql.Timestamp.class, Set.class); + } + + public Set<java.sql.Timestamp> convert(java.sql.Timestamp obj) throws ConversionException { + Set<java.sql.Timestamp> tempSet = FastSet.newInstance(); + tempSet.add(obj); + return tempSet; + } + } + public void loadConverters() { Converters.loadContainedConverters(DateTimeConverters.class); } 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=917366&r1=917365&r2=917366&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 03:14:22 2010 @@ -319,8 +319,8 @@ simpleTypeConvertTestSingleMulti("SqlDate->String", sqlDt, new String[] {"String", "java.lang.String"}, "dd-MM-yyyy", localeData, "31-12-1969"); simpleTypeConvertTestSingleMulti("SqlDate->SqlDate", sqlDt, new String[] {"Date", "java.sql.Date"}, new java.sql.Date(-129600000)); simpleTypeConvertTestSingleMulti("SqlDate->Timestamp", sqlDt, new String[] {"Timestamp", "java.sql.Timestamp"}, new Timestamp(-129600000)); - //BUG simpleTypeConvertTestSingleMulti("SqlDate->List", sqlDt, new String[] {"List", "java.util.List"}, list(sqlDt)); - //BUG simpleTypeConvertTestSingleMulti("SqlDate->Set", sqlDt, new String[] {"Set", "java.util.Set"}, set(sqlDt)); + simpleTypeConvertTestSingleMulti("SqlDate->List", sqlDt, new String[] {"List", "java.util.List"}, list(sqlDt)); + simpleTypeConvertTestSingleMulti("SqlDate->Set", sqlDt, new String[] {"Set", "java.util.Set"}, set(sqlDt)); simpleTypeConvertTestSingleMulti("SqlDate->Long", sqlDt, new String[] {"Long", "java.lang.Long"}, Long.valueOf("-129600000")); simpleTypeConvertTestError("SqlDate->error", sqlDt, new String[] {/*BUG "Time", "java.sql.Time" */}); } @@ -331,8 +331,8 @@ simpleTypeConvertTestSingleMulti("SqlTime->String", sqlTm, new String[] {"String", "java.lang.String"}, "ss:mm:HH", localeData, "56:34:12"); simpleTypeConvertTestSingleMulti("SqlTime->SqlTime", sqlTm, new String[] {"Time", "java.sql.Time"}, new java.sql.Time(2096000)); simpleTypeConvertTestSingleMulti("SqlTime->Timestamp", sqlTm, new String[] {"Timestamp", "java.sql.Timestamp"}, new Timestamp(2096000)); - //BUG simpleTypeConvertTestSingleMulti("SqlTime->List", sqlTm, new String[] {"List", "java.util.List"}, list(sqlTm)); - //BUG simpleTypeConvertTestSingleMulti("SqlTime->Set", sqlTm, new String[] {"Set", "java.util.Set"}, set(sqlTm)); + simpleTypeConvertTestSingleMulti("SqlTime->List", sqlTm, new String[] {"List", "java.util.List"}, list(sqlTm)); + simpleTypeConvertTestSingleMulti("SqlTime->Set", sqlTm, new String[] {"Set", "java.util.Set"}, set(sqlTm)); //BUG simpleTypeConvertTestError("SqlTime->error", sqlTm, new String[] {/*BUG "Date", "java.sql.Date" */}); } @@ -343,8 +343,8 @@ simpleTypeConvertTestSingleMulti("Timestamp->Date", tstmp, new String[] {"Date", "java.sql.Date"}, new java.sql.Date(781)); simpleTypeConvertTestSingleMulti("Timestamp->Time", tstmp, new String[] {"Time", "java.sql.Time"}, new java.sql.Time(781)); simpleTypeConvertTestSingleMulti("Timestamp->Timestamp", tstmp, new String[] {"Timestamp", "java.sql.Timestamp"}, new Timestamp(781)); - //BUG simpleTypeConvertTestSingleMulti("Timestamp->List", tstmp, new String[] {"List", "java.util.List"}, list(tstmp)); - //BUG simpleTypeConvertTestSingleMulti("Timestamp->Set", tstmp, new String[] {"Set", "java.util.Set"}, set(tstmp)); + simpleTypeConvertTestSingleMulti("Timestamp->List", tstmp, new String[] {"List", "java.util.List"}, list(tstmp)); + simpleTypeConvertTestSingleMulti("Timestamp->Set", tstmp, new String[] {"Set", "java.util.Set"}, set(tstmp)); simpleTypeConvertTestSingleMulti("Timestamp->Long", tstmp, new String[] {"Long", "java.lang.Long"}, Long.valueOf("781")); simpleTypeConvertTestError("Timestamp->error", tstmp, new String[] {}); } @@ -356,8 +356,8 @@ simpleTypeConvertTestSingleMulti("Boolean->String", false, new String[] {"String", "java.lang.String"}, "false"); simpleTypeConvertTestSingleMulti("Boolean->Integer", true, new String[] {"Integer", "java.lang.Integer"}, Integer.valueOf("1")); simpleTypeConvertTestSingleMulti("Boolean->Integer", false, new String[] {"Integer", "java.lang.Integer"}, Integer.valueOf("0")); - //BUG simpleTypeConvertTestSingleMulti("Boolean->List", true, new String[] {"List", "java.util.List"}, list(true)); - //BUG simpleTypeConvertTestSingleMulti("Boolean->Set", true, new String[] {"Set", "java.util.Set"}, set(true)); + simpleTypeConvertTestSingleMulti("Boolean->List", true, new String[] {"List", "java.util.List"}, list(true)); + simpleTypeConvertTestSingleMulti("Boolean->Set", true, new String[] {"Set", "java.util.Set"}, set(true)); simpleTypeConvertTestError("Boolean->error", true, new String[] {}); } @@ -407,8 +407,8 @@ //BUG simpleTypeConvertTestSingleMulti("TimeDuration->Double", duration, new String[] {"Double", "java.lang.Double"}, Double.valueOf("3661001")); //BUG simpleTypeConvertTestSingleMulti("TimeDuration->Float", duration, new String[] {"Float", "java.lang.Float"}, Float.valueOf("3661001")); simpleTypeConvertTestSingleMulti("TimeDuration->Long", duration, new String[] {"Long", "java.lang.Long"}, Long.valueOf("3661001")); - //BUG simpleTypeConvertTestSingleMulti("TimeDuration->List", duration, new String[] {"List", "java.util.List"}, list(duration)); - //BUG simpleTypeConvertTestSingleMulti("TimeDuration->Set", duration, new String[] {"Set", "java.util.Set"}, set(duration)); + simpleTypeConvertTestSingleMulti("TimeDuration->List", duration, new String[] {"List", "java.util.List"}, list(duration)); + simpleTypeConvertTestSingleMulti("TimeDuration->Set", duration, new String[] {"Set", "java.util.Set"}, set(duration)); simpleTypeConvertTestError("TimeDuration->error", duration, new String[] {}); } |
Free forum by Nabble | Edit this page |