use of com.abubusoft.kripton.persistence.JacksonWrapperSerializer in project kripton by xcesco.
the class BindBeanSharedPreferences method serializeValueBean.
/**
* for attribute valueBean serialization
*/
protected String serializeValueBean(Bean value) {
if (value == null) {
return null;
}
KriptonJsonContext context = KriptonBinder.jsonBind();
try (KriptonByteArrayOutputStream stream = new KriptonByteArrayOutputStream();
JacksonWrapperSerializer wrapper = context.createSerializer(stream)) {
JsonGenerator jacksonSerializer = wrapper.jacksonGenerator;
int fieldCount = 0;
if (value != null) {
fieldCount++;
beanBindMap.serializeOnJackson(value, jacksonSerializer);
}
jacksonSerializer.flush();
return stream.toString();
} catch (Exception e) {
throw (new KriptonRuntimeException(e.getMessage()));
}
}
use of com.abubusoft.kripton.persistence.JacksonWrapperSerializer in project kripton by xcesco.
the class BindBeanSharedPreferences method serializeValueCharList.
/**
* for attribute valueCharList serialization
*/
protected String serializeValueCharList(LinkedList<Character> value) {
if (value == null) {
return null;
}
KriptonJsonContext context = KriptonBinder.jsonBind();
try (KriptonByteArrayOutputStream stream = new KriptonByteArrayOutputStream();
JacksonWrapperSerializer wrapper = context.createSerializer(stream)) {
JsonGenerator jacksonSerializer = wrapper.jacksonGenerator;
jacksonSerializer.writeStartObject();
int fieldCount = 0;
if (value != null) {
fieldCount++;
int n = value.size();
Character item;
// write wrapper tag
jacksonSerializer.writeFieldName("valueCharList");
jacksonSerializer.writeStartArray();
for (int i = 0; i < n; i++) {
item = value.get(i);
if (item == null) {
jacksonSerializer.writeNull();
} else {
jacksonSerializer.writeNumber(item);
}
}
jacksonSerializer.writeEndArray();
}
jacksonSerializer.writeEndObject();
jacksonSerializer.flush();
return stream.toString();
} catch (Exception e) {
throw (new KriptonRuntimeException(e.getMessage()));
}
}
use of com.abubusoft.kripton.persistence.JacksonWrapperSerializer in project kripton by xcesco.
the class BeanDaoImpl method serializer4.
/**
* for param serializer4 serialization
*/
private byte[] serializer4(LinkedList<Long> value) {
if (value == null) {
return null;
}
KriptonJsonContext context = KriptonBinder.jsonBind();
try (KriptonByteArrayOutputStream stream = new KriptonByteArrayOutputStream();
JacksonWrapperSerializer wrapper = context.createSerializer(stream)) {
JsonGenerator jacksonSerializer = wrapper.jacksonGenerator;
int fieldCount = 0;
jacksonSerializer.writeStartObject();
if (value != null) {
int n = value.size();
Long item;
// write wrapper tag
jacksonSerializer.writeFieldName("element");
jacksonSerializer.writeStartArray();
for (int i = 0; i < n; i++) {
item = value.get(i);
if (item == null) {
jacksonSerializer.writeNull();
} else {
jacksonSerializer.writeNumber(item);
}
}
jacksonSerializer.writeEndArray();
}
jacksonSerializer.writeEndObject();
jacksonSerializer.flush();
return stream.toByteArray();
} catch (Exception e) {
throw (new KriptonRuntimeException(e.getMessage()));
}
}
use of com.abubusoft.kripton.persistence.JacksonWrapperSerializer in project kripton by xcesco.
the class BeanDaoImpl method serializer1.
/**
* for param serializer1 serialization
*/
private byte[] serializer1(HashSet<BigDecimal> value) {
if (value == null) {
return null;
}
KriptonJsonContext context = KriptonBinder.jsonBind();
try (KriptonByteArrayOutputStream stream = new KriptonByteArrayOutputStream();
JacksonWrapperSerializer wrapper = context.createSerializer(stream)) {
JsonGenerator jacksonSerializer = wrapper.jacksonGenerator;
int fieldCount = 0;
jacksonSerializer.writeStartObject();
if (value != null) {
// write wrapper tag
jacksonSerializer.writeFieldName("element");
jacksonSerializer.writeStartArray();
for (BigDecimal item : value) {
if (item == null) {
jacksonSerializer.writeNull();
} else {
jacksonSerializer.writeString(BigDecimalUtils.write(item));
}
}
jacksonSerializer.writeEndArray();
}
jacksonSerializer.writeEndObject();
jacksonSerializer.flush();
return stream.toByteArray();
} catch (Exception e) {
throw (new KriptonRuntimeException(e.getMessage()));
}
}
use of com.abubusoft.kripton.persistence.JacksonWrapperSerializer in project kripton by xcesco.
the class BeanTable method serializeValueBigDecimalSet.
/**
* for attribute valueBigDecimalSet serialization
*/
public static byte[] serializeValueBigDecimalSet(HashSet<BigDecimal> value) {
if (value == null) {
return null;
}
KriptonJsonContext context = KriptonBinder.jsonBind();
try (KriptonByteArrayOutputStream stream = new KriptonByteArrayOutputStream();
JacksonWrapperSerializer wrapper = context.createSerializer(stream)) {
JsonGenerator jacksonSerializer = wrapper.jacksonGenerator;
jacksonSerializer.writeStartObject();
int fieldCount = 0;
if (value != null) {
fieldCount++;
// write wrapper tag
jacksonSerializer.writeFieldName("element");
jacksonSerializer.writeStartArray();
for (BigDecimal item : value) {
if (item == null) {
jacksonSerializer.writeNull();
} else {
jacksonSerializer.writeString(BigDecimalUtils.write(item));
}
}
jacksonSerializer.writeEndArray();
}
jacksonSerializer.writeEndObject();
jacksonSerializer.flush();
return stream.toByteArray();
} catch (Exception e) {
throw (new KriptonRuntimeException(e.getMessage()));
}
}
Aggregations