Fixed: Add converter for StringWrapper and StringBuffer
To escape exception on native conversion, we add converter for StringBuffer and StringWrapper on MiscConverters
Thanks to Christoph Neuroth for this issue
@@ -30,6 +30,7 @@ import java.util.Locale;
import java.util.UUID;
import java.util.regex.Pattern;
+import org.apache.ofbiz.base.util.StringUtil;
import org.apache.ofbiz.base.util.UtilGenerics;
import org.apache.ofbiz.base.util.UtilMisc;
@@ -298,6 +299,26 @@ public class MiscConverters implements ConverterLoader {
}
}
+ public static class StringBufferToString extends AbstractConverter<StringBuffer, String> {
+ public StringBufferToString() {
+ super(StringBuffer.class, String.class);
+ }
+
+ public String convert(StringBuffer obj) throws ConversionException {
+ return obj.toString();
+ }
+ }
+
+ public static class StringWrapperToString extends AbstractConverter<StringUtil.StringWrapper, String> {
+ public StringWrapperToString() {
+ super(StringUtil.StringWrapper.class, String.class);
+ }
+
+ public String convert(StringUtil.StringWrapper obj) {
+ return obj.toString();
+ }
+ }
+
public static class UUIDToString extends AbstractConverter<UUID, String> {
public UUIDToString() {
super(UUID.class, String.class);
