Added Blob<->byte[] converters.
git-svn-id: https://svn.apache.org/repos/asf/ofbiz/trunk@883529 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
@@ -20,6 +20,7 @@ package org.ofbiz.base.conversion;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.Reader;
|
||||
import java.sql.Blob;
|
||||
import java.sql.Clob;
|
||||
import java.util.Locale;
|
||||
|
||||
@@ -30,6 +31,34 @@ public class MiscConverters implements ConverterLoader {
|
||||
|
||||
public static final int CHAR_BUFFER_SIZE = 4096;
|
||||
|
||||
public static class BlobToByteArray extends AbstractConverter<Blob, byte[]> {
|
||||
public BlobToByteArray() {
|
||||
super(Blob.class, byte[].class);
|
||||
}
|
||||
|
||||
public byte[] convert(Blob obj) throws ConversionException {
|
||||
try {
|
||||
return obj.getBytes(1, Integer.MAX_VALUE);
|
||||
} catch (Exception e) {
|
||||
throw new ConversionException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class ByteArrayToBlob extends AbstractConverter<byte[], Blob> {
|
||||
public ByteArrayToBlob() {
|
||||
super(byte[].class, Blob.class);
|
||||
}
|
||||
|
||||
public Blob convert(byte[] obj) throws ConversionException {
|
||||
try {
|
||||
return new javax.sql.rowset.serial.SerialBlob(obj);
|
||||
} catch (Exception e) {
|
||||
throw new ConversionException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class ClobToString extends AbstractConverter<Clob, String> {
|
||||
public ClobToString() {
|
||||
super(Clob.class, String.class);
|
||||
|
||||
Reference in New Issue
Block a user