1
2
3
4
5
6 package org.weda.converter.impl;
7
8 import java.io.InputStream;
9 import org.weda.converter.ValueTypeConverterException;
10 import org.weda.enhance.InjectHivemindObject;
11 import org.weda.store.ObjectStore;
12 import org.weda.store.ObjectStoreException;
13
14 /**
15 *
16 * @author Mikhail Titov
17 */
18 public class InputStreamToBlobConverter extends AbstractConverter{
19 @InjectHivemindObject()
20 private static ObjectStore objectStore;
21
22 public Object convert(Class toType, Object value, String pattern)
23 throws ValueTypeConverterException
24 {
25 try {
26 return objectStore.createBlob((InputStream)value);
27 } catch (ObjectStoreException ex) {
28 throw new ValueTypeConverterException(
29 "Error while converting to blob", ex);
30 }
31 }
32
33 }