use of com.abubusoft.kripton.persistence.JacksonWrapperParser in project kripton by xcesco.
the class BindBeanSharedPreferences method parseValueEnumTypeSet.
/**
* for attribute valueEnumTypeSet parsing
*/
protected HashSet<EnumType> parseValueEnumTypeSet(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();
HashSet<EnumType> result = null;
if (jacksonParser.currentToken() == JsonToken.START_ARRAY) {
HashSet<EnumType> collection = new HashSet<>();
EnumType item = null;
while (jacksonParser.nextToken() != JsonToken.END_ARRAY) {
if (jacksonParser.currentToken() == JsonToken.VALUE_NULL) {
item = null;
} else {
{
String tempEnum = jacksonParser.getText();
item = StringUtils.hasText(tempEnum) ? EnumType.valueOf(tempEnum) : null;
}
}
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 BindBeanSharedPreferences method parseValueBeanSet.
/**
* for attribute valueBeanSet parsing
*/
protected LinkedHashSet<Bean> parseValueBeanSet(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();
LinkedHashSet<Bean> result = null;
if (jacksonParser.currentToken() == JsonToken.START_ARRAY) {
LinkedHashSet<Bean> collection = new LinkedHashSet<>();
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 = 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 Bean63Table method parseValueMapEnumByte.
/**
* for attribute valueMapEnumByte parsing
*/
public static HashMap<EnumType, Byte> parseValueMapEnumByte(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();
HashMap<EnumType, Byte> result = null;
if (jacksonParser.currentToken() == JsonToken.START_ARRAY) {
HashMap<EnumType, Byte> collection = new HashMap<>();
EnumType key = null;
Byte value = null;
while (jacksonParser.nextToken() != JsonToken.END_ARRAY) {
jacksonParser.nextValue();
{
String tempEnum = jacksonParser.getText();
key = StringUtils.hasText(tempEnum) ? EnumType.valueOf(tempEnum) : null;
}
jacksonParser.nextValue();
if (jacksonParser.currentToken() != JsonToken.VALUE_NULL) {
value = jacksonParser.getByteValue();
}
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 Bean63Table method parseValueMapStringByte.
/**
* for attribute valueMapStringByte parsing
*/
public static Map<String, Byte> parseValueMapStringByte(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();
Map<String, Byte> result = null;
if (jacksonParser.currentToken() == JsonToken.START_ARRAY) {
HashMap<String, Byte> collection = new HashMap<>();
String key = null;
Byte value = null;
while (jacksonParser.nextToken() != JsonToken.END_ARRAY) {
jacksonParser.nextValue();
key = jacksonParser.getText();
jacksonParser.nextValue();
if (jacksonParser.currentToken() != JsonToken.VALUE_NULL) {
value = jacksonParser.getByteValue();
}
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 Bean64BTable method parseValueSetString.
/**
* for attribute valueSetString parsing
*/
public static Set<String> parseValueSetString(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<String> result = null;
if (jacksonParser.currentToken() == JsonToken.START_ARRAY) {
HashSet<String> collection = new HashSet<>();
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()));
}
}
Aggregations