svn commit: r1857371 - /ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/conversion/MiscConverters.java

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r1857371 - /ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/conversion/MiscConverters.java

nmalin
Author: nmalin
Date: Fri Apr 12 07:17:28 2019
New Revision: 1857371

URL: http://svn.apache.org/viewvc?rev=1857371&view=rev
Log:
Fixed: Add converter for StringWrapper and StringBuffer
(OFBIZ-5028)
To escape exception on native conversion, we add converter for StringBuffer and StringWrapper on MiscConverters
Thanks to Christoph Neuroth for this issue

Modified:
    ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/conversion/MiscConverters.java

Modified: ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/conversion/MiscConverters.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/conversion/MiscConverters.java?rev=1857371&r1=1857370&r2=1857371&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/conversion/MiscConverters.java (original)
+++ ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/conversion/MiscConverters.java Fri Apr 12 07:17:28 2019
@@ -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 C
         }
     }
 
+    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);