Author: adrianc
Date: Tue Nov 17 21:02:57 2009
New Revision: 881515
URL:
http://svn.apache.org/viewvc?rev=881515&view=revLog:
More Java object type converters.
Modified:
ofbiz/trunk/framework/base/src/org/ofbiz/base/conversion/DateTimeConverters.java
ofbiz/trunk/framework/base/src/org/ofbiz/base/conversion/MiscConverters.java
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=881515&r1=881514&r2=881515&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 Tue Nov 17 21:02:57 2009
@@ -99,6 +99,26 @@
}
}
+ public static class DurationToBigDecimal extends AbstractConverter<TimeDuration, java.math.BigDecimal> {
+ public DurationToBigDecimal() {
+ super(TimeDuration.class, java.math.BigDecimal.class);
+ }
+
+ public java.math.BigDecimal convert(TimeDuration obj) throws ConversionException {
+ return new java.math.BigDecimal(TimeDuration.toLong(obj));
+ }
+ }
+
+ public static class DurationToLong extends AbstractConverter<TimeDuration, Long> {
+ public DurationToLong() {
+ super(TimeDuration.class, Long.class);
+ }
+
+ public Long convert(TimeDuration obj) throws ConversionException {
+ return TimeDuration.toLong(obj);
+ }
+ }
+
public static class DurationToString extends AbstractConverter<TimeDuration, String> {
public DurationToString() {
super(TimeDuration.class, String.class);
Modified: ofbiz/trunk/framework/base/src/org/ofbiz/base/conversion/MiscConverters.java
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/conversion/MiscConverters.java?rev=881515&r1=881514&r2=881515&view=diff==============================================================================
--- ofbiz/trunk/framework/base/src/org/ofbiz/base/conversion/MiscConverters.java (original)
+++ ofbiz/trunk/framework/base/src/org/ofbiz/base/conversion/MiscConverters.java Tue Nov 17 21:02:57 2009
@@ -27,6 +27,7 @@
/** Miscellaneous Converter classes. */
public class MiscConverters implements ConverterLoader {
+
public static final int CHAR_BUFFER_SIZE = 4096;
public static class ClobToString extends AbstractConverter<Clob, String> {
@@ -68,6 +69,20 @@
}
}
+ public static class StringToClob extends AbstractConverter<String, Clob> {
+ public StringToClob() {
+ super(String.class, Clob.class);
+ }
+
+ public Clob convert(String obj) throws ConversionException {
+ try {
+ return new javax.sql.rowset.serial.SerialClob(obj.toCharArray());
+ } catch (Exception e) {
+ throw new ConversionException(e);
+ }
+ }
+ }
+
public static class StringToLocale extends AbstractConverter<String, Locale> {
public StringToLocale() {
super(String.class, Locale.class);