use of com.abubusoft.kripton.persistence.JacksonWrapperParser in project kripton by xcesco.
the class BeanDaoImpl method parser1.
/**
* for param parser1 parsing
*/
private Bean[] parser1(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();
Bean[] result = null;
if (jacksonParser.currentToken() == JsonToken.START_ARRAY) {
ArrayList<Bean> collection = new ArrayList<>();
Bean item = null;
while (jacksonParser.nextToken() != JsonToken.END_ARRAY) {
if (jacksonParser.currentToken() == JsonToken.VALUE_NULL) {
item = null;
} else {
item = beanBindMap.parseOnJackson(jacksonParser);
}
collection.add(item);
}
result = CollectionUtils.asArray(collection, new Bean[collection.size()]);
}
return result;
} catch (Exception e) {
throw (new KriptonRuntimeException(e.getMessage()));
}
}
use of com.abubusoft.kripton.persistence.JacksonWrapperParser in project kripton by xcesco.
the class BeanTable method parseValueStrinList.
/**
* for attribute valueStrinList parsing
*/
public static LinkedList<String> parseValueStrinList(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();
LinkedList<String> result = null;
if (jacksonParser.currentToken() == JsonToken.START_ARRAY) {
LinkedList<String> collection = new LinkedList<>();
String item = null;
while (jacksonParser.nextToken() != JsonToken.END_ARRAY) {
if (jacksonParser.currentToken() == JsonToken.VALUE_NULL) {
item = null;
} else {
item = jacksonParser.getText();
}
collection.add(item);
}
result = collection;
}
return result;
} catch (Exception e) {
throw (new KriptonRuntimeException(e.getMessage()));
}
}
use of com.abubusoft.kripton.persistence.JacksonWrapperParser in project kripton by xcesco.
the class BeanTable method parseValueLongTypeArray.
/**
* for attribute valueLongTypeArray parsing
*/
public static long[] parseValueLongTypeArray(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();
long[] result = null;
if (jacksonParser.currentToken() == JsonToken.START_ARRAY) {
ArrayList<Long> collection = new ArrayList<>();
Long item = null;
while (jacksonParser.nextToken() != JsonToken.END_ARRAY) {
if (jacksonParser.currentToken() == JsonToken.VALUE_NULL) {
item = null;
} else {
item = jacksonParser.getLongValue();
}
collection.add(item);
}
result = CollectionUtils.asLongTypeArray(collection);
}
return result;
} catch (Exception e) {
throw (new KriptonRuntimeException(e.getMessage()));
}
}
use of com.abubusoft.kripton.persistence.JacksonWrapperParser in project kripton by xcesco.
the class BeanTable method parseValueStringArray.
/**
* for attribute valueStringArray parsing
*/
public static String[] parseValueStringArray(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();
String[] result = null;
if (jacksonParser.currentToken() == JsonToken.START_ARRAY) {
ArrayList<String> collection = new ArrayList<>();
String item = null;
while (jacksonParser.nextToken() != JsonToken.END_ARRAY) {
if (jacksonParser.currentToken() == JsonToken.VALUE_NULL) {
item = null;
} else {
item = jacksonParser.getText();
}
collection.add(item);
}
result = CollectionUtils.asArray(collection, new String[collection.size()]);
}
return result;
} catch (Exception e) {
throw (new KriptonRuntimeException(e.getMessage()));
}
}
use of com.abubusoft.kripton.persistence.JacksonWrapperParser in project kripton by xcesco.
the class BindBeanSharedPreferences method parseValueBean.
/**
* for attribute valueBean parsing
*/
protected Bean parseValueBean(String input) {
if (input == null) {
return null;
}
KriptonJsonContext context = KriptonBinder.jsonBind();
try (JacksonWrapperParser wrapper = context.createParser(input)) {
JsonParser jacksonParser = wrapper.jacksonParser;
// START_OBJECT
jacksonParser.nextToken();
Bean result = null;
if (jacksonParser.currentToken() == JsonToken.START_OBJECT) {
result = beanBindMap.parseOnJackson(jacksonParser);
}
return result;
} catch (Exception e) {
throw (new KriptonRuntimeException(e.getMessage()));
}
}
Aggregations