Search in sources :

Example 61 with JacksonWrapperParser

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()));
    }
}
Also used : KriptonRuntimeException(com.abubusoft.kripton.exception.KriptonRuntimeException) KriptonJsonContext(com.abubusoft.kripton.KriptonJsonContext) JacksonWrapperParser(com.abubusoft.kripton.persistence.JacksonWrapperParser) KriptonRuntimeException(com.abubusoft.kripton.exception.KriptonRuntimeException) JsonParser(com.fasterxml.jackson.core.JsonParser) HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet)

Example 62 with JacksonWrapperParser

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()));
    }
}
Also used : LinkedHashSet(java.util.LinkedHashSet) KriptonRuntimeException(com.abubusoft.kripton.exception.KriptonRuntimeException) KriptonJsonContext(com.abubusoft.kripton.KriptonJsonContext) JacksonWrapperParser(com.abubusoft.kripton.persistence.JacksonWrapperParser) KriptonRuntimeException(com.abubusoft.kripton.exception.KriptonRuntimeException) JsonParser(com.fasterxml.jackson.core.JsonParser)

Example 63 with JacksonWrapperParser

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()));
    }
}
Also used : HashMap(java.util.HashMap) KriptonRuntimeException(com.abubusoft.kripton.exception.KriptonRuntimeException) KriptonJsonContext(com.abubusoft.kripton.KriptonJsonContext) JacksonWrapperParser(com.abubusoft.kripton.persistence.JacksonWrapperParser) KriptonRuntimeException(com.abubusoft.kripton.exception.KriptonRuntimeException) JsonParser(com.fasterxml.jackson.core.JsonParser)

Example 64 with JacksonWrapperParser

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()));
    }
}
Also used : HashMap(java.util.HashMap) KriptonRuntimeException(com.abubusoft.kripton.exception.KriptonRuntimeException) KriptonJsonContext(com.abubusoft.kripton.KriptonJsonContext) JacksonWrapperParser(com.abubusoft.kripton.persistence.JacksonWrapperParser) KriptonRuntimeException(com.abubusoft.kripton.exception.KriptonRuntimeException) JsonParser(com.fasterxml.jackson.core.JsonParser)

Example 65 with JacksonWrapperParser

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()));
    }
}
Also used : KriptonRuntimeException(com.abubusoft.kripton.exception.KriptonRuntimeException) KriptonJsonContext(com.abubusoft.kripton.KriptonJsonContext) JacksonWrapperParser(com.abubusoft.kripton.persistence.JacksonWrapperParser) KriptonRuntimeException(com.abubusoft.kripton.exception.KriptonRuntimeException) JsonParser(com.fasterxml.jackson.core.JsonParser) HashSet(java.util.HashSet)

Aggregations

KriptonRuntimeException (com.abubusoft.kripton.exception.KriptonRuntimeException)258 JacksonWrapperParser (com.abubusoft.kripton.persistence.JacksonWrapperParser)258 JsonParser (com.fasterxml.jackson.core.JsonParser)258 KriptonJsonContext (com.abubusoft.kripton.KriptonJsonContext)257 ArrayList (java.util.ArrayList)141 HashSet (java.util.HashSet)40 LinkedHashSet (java.util.LinkedHashSet)38 LinkedList (java.util.LinkedList)26 HashMap (java.util.HashMap)19 BeanInner (sqlite.kripton58.BeanInner)9 LinkedHashMap (java.util.LinkedHashMap)8 BigDecimal (java.math.BigDecimal)6 Time (java.sql.Time)5 Date (java.util.Date)1