use of com.abubusoft.kripton.common.KriptonByteArrayOutputStream in project kripton by xcesco.
the class BindBeanSharedPreferences method serializeValueCharTypeArray.
/**
* for attribute valueCharTypeArray serialization
*/
protected String serializeValueCharTypeArray(char[] 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;
char item;
// write wrapper tag
jacksonSerializer.writeFieldName("valueCharTypeArray");
jacksonSerializer.writeStartArray();
for (int i = 0; i < n; i++) {
item = value[i];
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.common.KriptonByteArrayOutputStream in project kripton by xcesco.
the class BindBeanSharedPreferences method serializeValueLongTypeArray.
/**
* for attribute valueLongTypeArray serialization
*/
protected String serializeValueLongTypeArray(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;
jacksonSerializer.writeStartObject();
int fieldCount = 0;
if (value != null) {
fieldCount++;
int n = value.length;
long item;
// write wrapper tag
jacksonSerializer.writeFieldName("valueLongTypeArray");
jacksonSerializer.writeStartArray();
for (int i = 0; i < n; i++) {
item = value[i];
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.common.KriptonByteArrayOutputStream in project kripton by xcesco.
the class BindBeanSharedPreferences method serializeValueStrinList.
/**
* for attribute valueStrinList serialization
*/
protected String serializeValueStrinList(LinkedList<String> 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();
String item;
// write wrapper tag
jacksonSerializer.writeFieldName("valueStrinList");
jacksonSerializer.writeStartArray();
for (int i = 0; i < n; i++) {
item = value.get(i);
if (item == null) {
jacksonSerializer.writeNull();
} else {
jacksonSerializer.writeString(item);
}
}
jacksonSerializer.writeEndArray();
}
jacksonSerializer.writeEndObject();
jacksonSerializer.flush();
return stream.toString();
} catch (Exception e) {
throw (new KriptonRuntimeException(e.getMessage()));
}
}
use of com.abubusoft.kripton.common.KriptonByteArrayOutputStream in project kripton by xcesco.
the class BindBeanSharedPreferences method serializeValueLinkedMapStringBean.
/**
* for attribute valueLinkedMapStringBean serialization
*/
protected String serializeValueLinkedMapStringBean(LinkedHashMap<String, 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;
jacksonSerializer.writeStartObject();
int fieldCount = 0;
if (value != null) {
fieldCount++;
// write wrapper tag
if (value.size() > 0) {
jacksonSerializer.writeFieldName("valueLinkedMapStringBean");
jacksonSerializer.writeStartArray();
for (Map.Entry<String, Bean> item : value.entrySet()) {
jacksonSerializer.writeStartObject();
jacksonSerializer.writeStringField("key", item.getKey());
if (item.getValue() == null) {
jacksonSerializer.writeNullField("value");
} else {
jacksonSerializer.writeFieldName("value");
beanBindMap.serializeOnJackson(item.getValue(), jacksonSerializer);
}
jacksonSerializer.writeEndObject();
}
jacksonSerializer.writeEndArray();
} else {
jacksonSerializer.writeNullField("valueLinkedMapStringBean");
}
}
jacksonSerializer.writeEndObject();
jacksonSerializer.flush();
return stream.toString();
} catch (Exception e) {
throw (new KriptonRuntimeException(e.getMessage()));
}
}
use of com.abubusoft.kripton.common.KriptonByteArrayOutputStream in project kripton by xcesco.
the class BindBeanSharedPreferences method serializeValueLongList.
/**
* for attribute valueLongList serialization
*/
protected String serializeValueLongList(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;
jacksonSerializer.writeStartObject();
int fieldCount = 0;
if (value != null) {
fieldCount++;
int n = value.size();
Long item;
// write wrapper tag
jacksonSerializer.writeFieldName("valueLongList");
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()));
}
}
Aggregations