use of com.abubusoft.kripton.persistence.JacksonWrapperSerializer in project kripton by xcesco.
the class ShortDaoImpl method serializer2.
/**
* for param serializer2 serialization
*/
private byte[] serializer2(Short[] 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.length;
Short item;
// write wrapper tag
jacksonSerializer.writeFieldName("element");
jacksonSerializer.writeStartArray();
for (int i = 0; i < n; i++) {
item = value[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 FloatBeanTable method serializeValue.
/**
* for attribute value serialization
*/
public static byte[] serializeValue(float[] 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.length;
float item;
// write wrapper tag
jacksonSerializer.writeFieldName("element");
jacksonSerializer.writeStartArray();
for (int i = 0; i < n; i++) {
item = value[i];
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 FloatDaoImpl method serializer1.
/**
* for param serializer1 serialization
*/
private byte[] serializer1(float[] 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.length;
float item;
// write wrapper tag
jacksonSerializer.writeFieldName("element");
jacksonSerializer.writeStartArray();
for (int i = 0; i < n; i++) {
item = value[i];
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 IntBeanTable method serializeValue2.
/**
* for attribute value2 serialization
*/
public static byte[] serializeValue2(Integer[] 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.length;
Integer item;
// write wrapper tag
jacksonSerializer.writeFieldName("element");
jacksonSerializer.writeStartArray();
for (int i = 0; i < n; i++) {
item = value[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 IntDaoImpl method serializer1.
/**
* for param serializer1 serialization
*/
private byte[] serializer1(int[] 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.length;
int item;
// write wrapper tag
jacksonSerializer.writeFieldName("element");
jacksonSerializer.writeStartArray();
for (int i = 0; i < n; i++) {
item = value[i];
jacksonSerializer.writeNumber(item);
}
jacksonSerializer.writeEndArray();
}
jacksonSerializer.writeEndObject();
jacksonSerializer.flush();
return stream.toByteArray();
} catch (Exception e) {
throw (new KriptonRuntimeException(e.getMessage()));
}
}
Aggregations