use of com.abubusoft.kripton.persistence.JacksonWrapperParser in project kripton by xcesco.
the class BindBeanSharedPreferences method parseValueLongArray.
/**
* for attribute valueLongArray parsing
*/
protected Long[] parseValueLongArray(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();
// 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.asLongArray(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 BindBeanSharedPreferences method parseValueLinkedMapStringBean.
/**
* for attribute valueLinkedMapStringBean parsing
*/
protected LinkedHashMap<String, Bean> parseValueLinkedMapStringBean(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();
// value of "element"
jacksonParser.nextValue();
LinkedHashMap<String, Bean> result = null;
if (jacksonParser.currentToken() == JsonToken.START_ARRAY) {
LinkedHashMap<String, Bean> collection = new LinkedHashMap<>();
String key = null;
Bean value = null;
while (jacksonParser.nextToken() != JsonToken.END_ARRAY) {
jacksonParser.nextValue();
key = jacksonParser.getText();
jacksonParser.nextValue();
if (jacksonParser.currentToken() == JsonToken.START_OBJECT) {
value = beanBindMap.parseOnJackson(jacksonParser);
}
collection.put(key, value);
key = null;
value = null;
jacksonParser.nextToken();
}
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 BindBeanSharedPreferences method parseValueCharTypeArray.
/**
* for attribute valueCharTypeArray parsing
*/
protected char[] parseValueCharTypeArray(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();
// value of "element"
jacksonParser.nextValue();
char[] result = null;
if (jacksonParser.currentToken() == JsonToken.START_ARRAY) {
ArrayList<Character> collection = new ArrayList<>();
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 = CollectionUtils.asCharacterTypeArray(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 BindBeanSharedPreferences method parseValueStringArray.
/**
* for attribute valueStringArray parsing
*/
protected String[] parseValueStringArray(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();
// 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 BeanDaoImpl method parser3.
/**
* for param parser3 parsing
*/
private long[] parser3(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()));
}
}
Aggregations