use of com.abubusoft.kripton.KriptonJsonContext in project kripton by xcesco.
the class BeanDao2Impl 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.KriptonJsonContext in project kripton by xcesco.
the class Bean2Table method parseValueShortSet.
/**
* for attribute valueShortSet parsing
*/
public static HashSet<Short> parseValueShortSet(byte[] input) {
if (input == null) {
return null;
}
KriptonJsonContext context = KriptonBinder.jsonBind();
try (JacksonWrapperParser wrapper = context.createParser(input)) {
JsonParser jacksonParser = wrapper.jacksonParser;
// START_OBJECT
jacksonParser.nextToken();
// value of "element"
jacksonParser.nextValue();
HashSet<Short> result = null;
if (jacksonParser.currentToken() == JsonToken.START_ARRAY) {
HashSet<Short> collection = new HashSet<>();
Short item = null;
while (jacksonParser.nextToken() != JsonToken.END_ARRAY) {
if (jacksonParser.currentToken() == JsonToken.VALUE_NULL) {
item = null;
} else {
item = jacksonParser.getShortValue();
}
collection.add(item);
}
result = collection;
}
return result;
} catch (Exception e) {
throw (new KriptonRuntimeException(e.getMessage()));
}
}
use of com.abubusoft.kripton.KriptonJsonContext in project kripton by xcesco.
the class Bean2Table method serializeValueFloatSet.
/**
* for attribute valueFloatSet serialization
*/
public static byte[] serializeValueFloatSet(HashSet<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++;
// write wrapper tag
jacksonSerializer.writeFieldName("element");
jacksonSerializer.writeStartArray();
for (Float item : value) {
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.KriptonJsonContext in project kripton by xcesco.
the class Bean2Table method parseValueCharacterSet.
/**
* for attribute valueCharacterSet parsing
*/
public static Set<Character> parseValueCharacterSet(byte[] input) {
if (input == null) {
return null;
}
KriptonJsonContext context = KriptonBinder.jsonBind();
try (JacksonWrapperParser wrapper = context.createParser(input)) {
JsonParser jacksonParser = wrapper.jacksonParser;
// START_OBJECT
jacksonParser.nextToken();
// value of "element"
jacksonParser.nextValue();
Set<Character> result = null;
if (jacksonParser.currentToken() == JsonToken.START_ARRAY) {
HashSet<Character> collection = new HashSet<>();
Character item = null;
while (jacksonParser.nextToken() != JsonToken.END_ARRAY) {
if (jacksonParser.currentToken() == JsonToken.VALUE_NULL) {
item = null;
} else {
item = Character.valueOf((char) jacksonParser.getIntValue());
}
collection.add(item);
}
result = collection;
}
return result;
} catch (Exception e) {
throw (new KriptonRuntimeException(e.getMessage()));
}
}
use of com.abubusoft.kripton.KriptonJsonContext in project kripton by xcesco.
the class Bean2Table method serializeValueShortSet.
/**
* for attribute valueShortSet serialization
*/
public static byte[] serializeValueShortSet(HashSet<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;
jacksonSerializer.writeStartObject();
int fieldCount = 0;
if (value != null) {
fieldCount++;
// write wrapper tag
jacksonSerializer.writeFieldName("element");
jacksonSerializer.writeStartArray();
for (Short item : value) {
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()));
}
}
Aggregations