Search in sources :

Example 71 with JsonToken

use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.core.JsonToken in project drill by axbaretto.

the class JsonReader method write.

@Override
public ReadState write(ComplexWriter writer) throws IOException {
    ReadState readState = null;
    try {
        JsonToken t = lastSeenJsonToken;
        if (t == null || t == JsonToken.END_OBJECT) {
            t = parser.nextToken();
        }
        while (!parser.hasCurrentToken() && !parser.isClosed()) {
            t = parser.nextToken();
        }
        lastSeenJsonToken = null;
        if (parser.isClosed()) {
            return ReadState.END_OF_STREAM;
        }
        readState = writeToVector(writer, t);
        switch(readState) {
            case END_OF_STREAM:
                break;
            case WRITE_SUCCEED:
                break;
            default:
                throw getExceptionWithContext(UserException.dataReadError(), currentFieldName, null).message("Failure while reading JSON. (Got an invalid read state %s )", readState.toString()).build(logger);
        }
    } catch (com.fasterxml.jackson.core.JsonParseException ex) {
        if (ignoreJSONParseError()) {
            if (processJSONException() == JsonExceptionProcessingState.END_OF_STREAM) {
                return ReadState.JSON_RECORD_PARSE_EOF_ERROR;
            } else {
                return ReadState.JSON_RECORD_PARSE_ERROR;
            }
        } else {
            throw ex;
        }
    }
    return readState;
}
Also used : JsonToken(com.fasterxml.jackson.core.JsonToken)

Example 72 with JsonToken

use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.core.JsonToken in project kripton by xcesco.

the class Bean64ABindMap method parseOnJacksonAsString.

/**
 * parse with jackson
 */
@Override
public Bean64A parseOnJacksonAsString(JsonParser jacksonParser) throws Exception {
    Bean64A instance = new Bean64A();
    String fieldName;
    if (jacksonParser.getCurrentToken() == null) {
        jacksonParser.nextToken();
    }
    if (jacksonParser.getCurrentToken() != JsonToken.START_OBJECT) {
        jacksonParser.skipChildren();
        return instance;
    }
    while (jacksonParser.nextToken() != JsonToken.END_OBJECT) {
        fieldName = jacksonParser.getCurrentName();
        jacksonParser.nextToken();
        // Parse fields:
        switch(fieldName) {
            case "id":
                // field id (mapped with "id")
                instance.id = PrimitiveUtils.readLong(jacksonParser.getText(), 0L);
                break;
            case "valueMapStringBean":
                // field valueMapStringBean (mapped with "valueMapStringBean")
                if (jacksonParser.currentToken() == JsonToken.START_ARRAY) {
                    HashMap<String, Bean64A> collection = new HashMap<>();
                    String key = null;
                    Bean64A value = null;
                    JsonToken current;
                    String tempValue = null;
                    while (jacksonParser.nextToken() != JsonToken.END_ARRAY) {
                        current = jacksonParser.currentToken();
                        for (int i = 0; i < 2; i++) {
                            while (current != JsonToken.FIELD_NAME) {
                                current = jacksonParser.nextToken();
                            }
                            jacksonParser.nextValue();
                            switch(jacksonParser.getCurrentName()) {
                                case "key":
                                    if (jacksonParser.currentToken() != JsonToken.VALUE_NULL) {
                                        key = jacksonParser.getText();
                                    }
                                    break;
                                case "value":
                                    tempValue = jacksonParser.getValueAsString();
                                    if (jacksonParser.currentToken() == JsonToken.VALUE_STRING && "null".equals(tempValue)) {
                                        value = null;
                                    } else {
                                        if (jacksonParser.currentToken() == JsonToken.START_OBJECT || jacksonParser.currentToken() == JsonToken.VALUE_STRING) {
                                            value = bean64ABindMap.parseOnJacksonAsString(jacksonParser);
                                        }
                                    }
                                    break;
                            }
                        }
                        collection.put(key, value);
                        key = null;
                        value = null;
                        jacksonParser.nextToken();
                    }
                    instance.valueMapStringBean = collection;
                }
                break;
            case "valueSetString":
                // field valueSetString (mapped with "valueSetString")
                if (jacksonParser.currentToken() == JsonToken.START_ARRAY) {
                    HashSet<String> collection = new HashSet<>();
                    String item = null;
                    String tempValue = null;
                    while (jacksonParser.nextToken() != JsonToken.END_ARRAY) {
                        tempValue = jacksonParser.getValueAsString();
                        if (jacksonParser.currentToken() == JsonToken.VALUE_STRING && "null".equals(tempValue)) {
                            item = null;
                        } else {
                            if (jacksonParser.currentToken() != JsonToken.VALUE_NULL) {
                                item = jacksonParser.getText();
                            }
                        }
                        collection.add(item);
                    }
                    instance.valueSetString = collection;
                } else if (jacksonParser.currentToken() == JsonToken.VALUE_STRING && !StringUtils.hasText(jacksonParser.getValueAsString())) {
                    HashSet<String> collection = new HashSet<>();
                    instance.valueSetString = collection;
                }
                break;
            case "valueString":
                // field valueString (mapped with "valueString")
                if (jacksonParser.currentToken() != JsonToken.VALUE_NULL) {
                    instance.valueString = jacksonParser.getText();
                }
                break;
            default:
                jacksonParser.skipChildren();
                break;
        }
    }
    return instance;
}
Also used : HashMap(java.util.HashMap) JsonToken(com.fasterxml.jackson.core.JsonToken) HashSet(java.util.HashSet)

Example 73 with JsonToken

use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.core.JsonToken in project kripton by xcesco.

the class Bean64BBindMap method parseOnJacksonAsString.

/**
 * parse with jackson
 */
@Override
public Bean64B parseOnJacksonAsString(JsonParser jacksonParser) throws Exception {
    Bean64B instance = new Bean64B();
    String fieldName;
    if (jacksonParser.getCurrentToken() == null) {
        jacksonParser.nextToken();
    }
    if (jacksonParser.getCurrentToken() != JsonToken.START_OBJECT) {
        jacksonParser.skipChildren();
        return instance;
    }
    while (jacksonParser.nextToken() != JsonToken.END_OBJECT) {
        fieldName = jacksonParser.getCurrentName();
        jacksonParser.nextToken();
        // Parse fields:
        switch(fieldName) {
            case "id":
                // field id (mapped with "id")
                instance.id = PrimitiveUtils.readLong(jacksonParser.getText(), 0L);
                break;
            case "valueMapStringBean":
                // field valueMapStringBean (mapped with "valueMapStringBean")
                if (jacksonParser.currentToken() == JsonToken.START_ARRAY) {
                    HashMap<String, Bean64B> collection = new HashMap<>();
                    String key = null;
                    Bean64B value = null;
                    JsonToken current;
                    String tempValue = null;
                    while (jacksonParser.nextToken() != JsonToken.END_ARRAY) {
                        current = jacksonParser.currentToken();
                        for (int i = 0; i < 2; i++) {
                            while (current != JsonToken.FIELD_NAME) {
                                current = jacksonParser.nextToken();
                            }
                            jacksonParser.nextValue();
                            switch(jacksonParser.getCurrentName()) {
                                case "key":
                                    if (jacksonParser.currentToken() != JsonToken.VALUE_NULL) {
                                        key = jacksonParser.getText();
                                    }
                                    break;
                                case "value":
                                    tempValue = jacksonParser.getValueAsString();
                                    if (jacksonParser.currentToken() == JsonToken.VALUE_STRING && "null".equals(tempValue)) {
                                        value = null;
                                    } else {
                                        if (jacksonParser.currentToken() == JsonToken.START_OBJECT || jacksonParser.currentToken() == JsonToken.VALUE_STRING) {
                                            value = bean64BBindMap.parseOnJacksonAsString(jacksonParser);
                                        }
                                    }
                                    break;
                            }
                        }
                        collection.put(key, value);
                        key = null;
                        value = null;
                        jacksonParser.nextToken();
                    }
                    instance.valueMapStringBean = collection;
                }
                break;
            case "valueSetString":
                // field valueSetString (mapped with "valueSetString")
                if (jacksonParser.currentToken() == JsonToken.START_ARRAY) {
                    HashSet<String> collection = new HashSet<>();
                    String item = null;
                    String tempValue = null;
                    while (jacksonParser.nextToken() != JsonToken.END_ARRAY) {
                        tempValue = jacksonParser.getValueAsString();
                        if (jacksonParser.currentToken() == JsonToken.VALUE_STRING && "null".equals(tempValue)) {
                            item = null;
                        } else {
                            if (jacksonParser.currentToken() != JsonToken.VALUE_NULL) {
                                item = jacksonParser.getText();
                            }
                        }
                        collection.add(item);
                    }
                    instance.valueSetString = collection;
                } else if (jacksonParser.currentToken() == JsonToken.VALUE_STRING && !StringUtils.hasText(jacksonParser.getValueAsString())) {
                    HashSet<String> collection = new HashSet<>();
                    instance.valueSetString = collection;
                }
                break;
            case "valueString":
                // field valueString (mapped with "valueString")
                if (jacksonParser.currentToken() != JsonToken.VALUE_NULL) {
                    instance.valueString = jacksonParser.getText();
                }
                break;
            default:
                jacksonParser.skipChildren();
                break;
        }
    }
    return instance;
}
Also used : HashMap(java.util.HashMap) JsonToken(com.fasterxml.jackson.core.JsonToken) HashSet(java.util.HashSet)

Example 74 with JsonToken

use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.core.JsonToken in project kripton by xcesco.

the class Bean64BindMap method parseOnJacksonAsString.

/**
 * parse with jackson
 */
@Override
public Bean64 parseOnJacksonAsString(JsonParser jacksonParser) throws Exception {
    Bean64 instance = new Bean64();
    String fieldName;
    if (jacksonParser.getCurrentToken() == null) {
        jacksonParser.nextToken();
    }
    if (jacksonParser.getCurrentToken() != JsonToken.START_OBJECT) {
        jacksonParser.skipChildren();
        return instance;
    }
    while (jacksonParser.nextToken() != JsonToken.END_OBJECT) {
        fieldName = jacksonParser.getCurrentName();
        jacksonParser.nextToken();
        // Parse fields:
        switch(fieldName) {
            case "id":
                // field id (mapped with "id")
                instance.id = PrimitiveUtils.readLong(jacksonParser.getText(), 0L);
                break;
            case "valueBean":
                // field valueBean (mapped with "valueBean")
                if (jacksonParser.currentToken() == JsonToken.START_OBJECT || jacksonParser.currentToken() == JsonToken.VALUE_STRING) {
                    instance.valueBean = bean64BindMap.parseOnJacksonAsString(jacksonParser);
                }
                break;
            case "valueBeanArray":
                // field valueBeanArray (mapped with "valueBeanArray")
                if (jacksonParser.currentToken() == JsonToken.START_ARRAY) {
                    ArrayList<Bean64> collection = new ArrayList<>();
                    Bean64 item = null;
                    String tempValue = null;
                    while (jacksonParser.nextToken() != JsonToken.END_ARRAY) {
                        tempValue = jacksonParser.getValueAsString();
                        if (jacksonParser.currentToken() == JsonToken.VALUE_STRING && "null".equals(tempValue)) {
                            item = null;
                        } else {
                            item = bean64BindMap.parseOnJacksonAsString(jacksonParser);
                        }
                        collection.add(item);
                    }
                    instance.valueBeanArray = CollectionUtils.asArray(collection, new Bean64[collection.size()]);
                } else if (jacksonParser.currentToken() == JsonToken.VALUE_STRING && !StringUtils.hasText(jacksonParser.getValueAsString())) {
                    ArrayList<Bean64> collection = new ArrayList<>();
                    instance.valueBeanArray = CollectionUtils.asArray(collection, new Bean64[collection.size()]);
                }
                break;
            case "valueBigDecimal":
                // field valueBigDecimal (mapped with "valueBigDecimal")
                if (jacksonParser.currentToken() != JsonToken.VALUE_NULL) {
                    instance.valueBigDecimal = BigDecimalUtils.read(jacksonParser.getText());
                }
                break;
            case "valueBigInteger":
                // field valueBigInteger (mapped with "valueBigInteger")
                if (jacksonParser.currentToken() != JsonToken.VALUE_NULL) {
                    instance.valueBigInteger = BigIntegerUtils.read(jacksonParser.getText());
                }
                break;
            case "valueBool":
                // field valueBool (mapped with "valueBool")
                if (jacksonParser.currentToken() != JsonToken.VALUE_NULL) {
                    instance.valueBool = PrimitiveUtils.readBoolean(jacksonParser.getText(), null);
                }
                break;
            case "valueBoolType":
                // field valueBoolType (mapped with "valueBoolType")
                instance.valueBoolType = PrimitiveUtils.readBoolean(jacksonParser.getText(), (boolean) false);
                break;
            case "valueByte":
                // field valueByte (mapped with "valueByte")
                if (jacksonParser.currentToken() != JsonToken.VALUE_NULL) {
                    instance.valueByte = PrimitiveUtils.readByte(jacksonParser.getText(), null);
                }
                break;
            case "valueByteArray":
                // field valueByteArray (mapped with "valueByteArray")
                if (jacksonParser.currentToken() != JsonToken.VALUE_NULL) {
                    instance.valueByteArray = Base64Utils.decode(jacksonParser.getValueAsString());
                }
                break;
            case "valueByteType":
                // field valueByteType (mapped with "valueByteType")
                instance.valueByteType = PrimitiveUtils.readByte(jacksonParser.getText(), (byte) 0);
                break;
            case "valueCalendar":
                // field valueCalendar (mapped with "valueCalendar")
                if (jacksonParser.currentToken() != JsonToken.VALUE_NULL) {
                    instance.valueCalendar = CalendarUtils.read(jacksonParser.getText());
                }
                break;
            case "valueChar":
                // field valueChar (mapped with "valueChar")
                if (jacksonParser.currentToken() != JsonToken.VALUE_NULL) {
                    instance.valueChar = PrimitiveUtils.readCharacter(jacksonParser.getText(), null);
                }
                break;
            case "valueCharArray":
                // field valueCharArray (mapped with "valueCharArray")
                if (jacksonParser.currentToken() == JsonToken.START_ARRAY) {
                    ArrayList<Character> collection = new ArrayList<>();
                    Character item = null;
                    String tempValue = null;
                    while (jacksonParser.nextToken() != JsonToken.END_ARRAY) {
                        tempValue = jacksonParser.getValueAsString();
                        if (jacksonParser.currentToken() == JsonToken.VALUE_STRING && "null".equals(tempValue)) {
                            item = null;
                        } else {
                            item = PrimitiveUtils.readCharacter(jacksonParser.getText(), null);
                        }
                        collection.add(item);
                    }
                    instance.valueCharArray = CollectionUtils.asCharacterArray(collection);
                } else if (jacksonParser.currentToken() == JsonToken.VALUE_STRING && !StringUtils.hasText(jacksonParser.getValueAsString())) {
                    ArrayList<Character> collection = new ArrayList<>();
                    instance.valueCharArray = CollectionUtils.asCharacterArray(collection);
                }
                break;
            case "valueCharList":
                // field valueCharList (mapped with "valueCharList")
                if (jacksonParser.currentToken() == JsonToken.START_ARRAY) {
                    LinkedList<Character> collection = new LinkedList<>();
                    Character item = null;
                    String tempValue = null;
                    while (jacksonParser.nextToken() != JsonToken.END_ARRAY) {
                        tempValue = jacksonParser.getValueAsString();
                        if (jacksonParser.currentToken() == JsonToken.VALUE_STRING && "null".equals(tempValue)) {
                            item = null;
                        } else {
                            item = PrimitiveUtils.readCharacter(jacksonParser.getText(), null);
                        }
                        collection.add(item);
                    }
                    instance.valueCharList = collection;
                } else if (jacksonParser.currentToken() == JsonToken.VALUE_STRING && !StringUtils.hasText(jacksonParser.getValueAsString())) {
                    LinkedList<Character> collection = new LinkedList<>();
                    instance.valueCharList = collection;
                }
                break;
            case "valueCharType":
                // field valueCharType (mapped with "valueCharType")
                instance.valueCharType = PrimitiveUtils.readCharacter(jacksonParser.getText(), '');
                break;
            case "valueCharTypeArray":
                // field valueCharTypeArray (mapped with "valueCharTypeArray")
                if (jacksonParser.currentToken() == JsonToken.START_ARRAY) {
                    ArrayList<Character> collection = new ArrayList<>();
                    Character item = null;
                    String tempValue = null;
                    while (jacksonParser.nextToken() != JsonToken.END_ARRAY) {
                        tempValue = jacksonParser.getValueAsString();
                        if (jacksonParser.currentToken() == JsonToken.VALUE_STRING && "null".equals(tempValue)) {
                            item = null;
                        } else {
                            item = PrimitiveUtils.readCharacter(jacksonParser.getText(), '');
                        }
                        collection.add(item);
                    }
                    instance.valueCharTypeArray = CollectionUtils.asCharacterTypeArray(collection);
                } else if (jacksonParser.currentToken() == JsonToken.VALUE_STRING && !StringUtils.hasText(jacksonParser.getValueAsString())) {
                    ArrayList<Character> collection = new ArrayList<>();
                    instance.valueCharTypeArray = CollectionUtils.asCharacterTypeArray(collection);
                }
                break;
            case "valueCurrency":
                // field valueCurrency (mapped with "valueCurrency")
                if (jacksonParser.currentToken() != JsonToken.VALUE_NULL) {
                    instance.valueCurrency = CurrencyUtils.read(jacksonParser.getText());
                }
                break;
            case "valueDate":
                // field valueDate (mapped with "valueDate")
                if (jacksonParser.currentToken() != JsonToken.VALUE_NULL) {
                    instance.valueDate = DateUtils.read(jacksonParser.getText());
                }
                break;
            case "valueDouble":
                // field valueDouble (mapped with "valueDouble")
                if (jacksonParser.currentToken() != JsonToken.VALUE_NULL) {
                    instance.valueDouble = PrimitiveUtils.readDouble(jacksonParser.getText(), null);
                }
                break;
            case "valueDoubleType":
                // field valueDoubleType (mapped with "valueDoubleType")
                instance.valueDoubleType = PrimitiveUtils.readDouble(jacksonParser.getText(), 0.0);
                break;
            case "valueEnumType":
                // field valueEnumType (mapped with "valueEnumType")
                if (jacksonParser.currentToken() != JsonToken.VALUE_NULL) {
                    String tempEnum = jacksonParser.getText();
                    instance.valueEnumType = StringUtils.hasText(tempEnum) ? EnumType.valueOf(tempEnum) : null;
                }
                break;
            case "valueFloat":
                // field valueFloat (mapped with "valueFloat")
                if (jacksonParser.currentToken() != JsonToken.VALUE_NULL) {
                    instance.valueFloat = PrimitiveUtils.readFloat(jacksonParser.getText(), null);
                }
                break;
            case "valueFloatType":
                // field valueFloatType (mapped with "valueFloatType")
                instance.valueFloatType = PrimitiveUtils.readFloat(jacksonParser.getText(), 0f);
                break;
            case "valueInt":
                // field valueInt (mapped with "valueInt")
                if (jacksonParser.currentToken() != JsonToken.VALUE_NULL) {
                    instance.valueInt = PrimitiveUtils.readInteger(jacksonParser.getText(), null);
                }
                break;
            case "valueIntType":
                // field valueIntType (mapped with "valueIntType")
                instance.valueIntType = PrimitiveUtils.readInteger(jacksonParser.getText(), 0);
                break;
            case "valueLinkedMapStringBean":
                // field valueLinkedMapStringBean (mapped with "valueLinkedMapStringBean")
                if (jacksonParser.currentToken() == JsonToken.START_ARRAY) {
                    LinkedHashMap<String, Bean64> collection = new LinkedHashMap<>();
                    String key = null;
                    Bean64 value = null;
                    JsonToken current;
                    String tempValue = null;
                    while (jacksonParser.nextToken() != JsonToken.END_ARRAY) {
                        current = jacksonParser.currentToken();
                        for (int i = 0; i < 2; i++) {
                            while (current != JsonToken.FIELD_NAME) {
                                current = jacksonParser.nextToken();
                            }
                            jacksonParser.nextValue();
                            switch(jacksonParser.getCurrentName()) {
                                case "key":
                                    if (jacksonParser.currentToken() != JsonToken.VALUE_NULL) {
                                        key = jacksonParser.getText();
                                    }
                                    break;
                                case "value":
                                    tempValue = jacksonParser.getValueAsString();
                                    if (jacksonParser.currentToken() == JsonToken.VALUE_STRING && "null".equals(tempValue)) {
                                        value = null;
                                    } else {
                                        if (jacksonParser.currentToken() == JsonToken.START_OBJECT || jacksonParser.currentToken() == JsonToken.VALUE_STRING) {
                                            value = bean64BindMap.parseOnJacksonAsString(jacksonParser);
                                        }
                                    }
                                    break;
                            }
                        }
                        collection.put(key, value);
                        key = null;
                        value = null;
                        jacksonParser.nextToken();
                    }
                    instance.valueLinkedMapStringBean = collection;
                }
                break;
            case "valueLocale":
                // field valueLocale (mapped with "valueLocale")
                if (jacksonParser.currentToken() != JsonToken.VALUE_NULL) {
                    instance.valueLocale = LocaleUtils.read(jacksonParser.getText());
                }
                break;
            case "valueLong":
                // field valueLong (mapped with "valueLong")
                if (jacksonParser.currentToken() != JsonToken.VALUE_NULL) {
                    instance.valueLong = PrimitiveUtils.readLong(jacksonParser.getText(), null);
                }
                break;
            case "valueLongArray":
                // field valueLongArray (mapped with "valueLongArray")
                if (jacksonParser.currentToken() == JsonToken.START_ARRAY) {
                    ArrayList<Long> collection = new ArrayList<>();
                    Long item = null;
                    String tempValue = null;
                    while (jacksonParser.nextToken() != JsonToken.END_ARRAY) {
                        tempValue = jacksonParser.getValueAsString();
                        if (jacksonParser.currentToken() == JsonToken.VALUE_STRING && "null".equals(tempValue)) {
                            item = null;
                        } else {
                            item = PrimitiveUtils.readLong(jacksonParser.getText(), null);
                        }
                        collection.add(item);
                    }
                    instance.valueLongArray = CollectionUtils.asLongArray(collection);
                } else if (jacksonParser.currentToken() == JsonToken.VALUE_STRING && !StringUtils.hasText(jacksonParser.getValueAsString())) {
                    ArrayList<Long> collection = new ArrayList<>();
                    instance.valueLongArray = CollectionUtils.asLongArray(collection);
                }
                break;
            case "valueLongList":
                // field valueLongList (mapped with "valueLongList")
                if (jacksonParser.currentToken() == JsonToken.START_ARRAY) {
                    LinkedList<Long> collection = new LinkedList<>();
                    Long item = null;
                    String tempValue = null;
                    while (jacksonParser.nextToken() != JsonToken.END_ARRAY) {
                        tempValue = jacksonParser.getValueAsString();
                        if (jacksonParser.currentToken() == JsonToken.VALUE_STRING && "null".equals(tempValue)) {
                            item = null;
                        } else {
                            item = PrimitiveUtils.readLong(jacksonParser.getText(), null);
                        }
                        collection.add(item);
                    }
                    instance.valueLongList = collection;
                } else if (jacksonParser.currentToken() == JsonToken.VALUE_STRING && !StringUtils.hasText(jacksonParser.getValueAsString())) {
                    LinkedList<Long> collection = new LinkedList<>();
                    instance.valueLongList = collection;
                }
                break;
            case "valueLongType":
                // field valueLongType (mapped with "valueLongType")
                instance.valueLongType = PrimitiveUtils.readLong(jacksonParser.getText(), 0L);
                break;
            case "valueLongTypeArray":
                // field valueLongTypeArray (mapped with "valueLongTypeArray")
                if (jacksonParser.currentToken() == JsonToken.START_ARRAY) {
                    ArrayList<Long> collection = new ArrayList<>();
                    Long item = null;
                    String tempValue = null;
                    while (jacksonParser.nextToken() != JsonToken.END_ARRAY) {
                        tempValue = jacksonParser.getValueAsString();
                        if (jacksonParser.currentToken() == JsonToken.VALUE_STRING && "null".equals(tempValue)) {
                            item = null;
                        } else {
                            item = PrimitiveUtils.readLong(jacksonParser.getText(), 0L);
                        }
                        collection.add(item);
                    }
                    instance.valueLongTypeArray = CollectionUtils.asLongTypeArray(collection);
                } else if (jacksonParser.currentToken() == JsonToken.VALUE_STRING && !StringUtils.hasText(jacksonParser.getValueAsString())) {
                    ArrayList<Long> collection = new ArrayList<>();
                    instance.valueLongTypeArray = CollectionUtils.asLongTypeArray(collection);
                }
                break;
            case "valueMapStringBean":
                // field valueMapStringBean (mapped with "valueMapStringBean")
                if (jacksonParser.currentToken() == JsonToken.START_ARRAY) {
                    HashMap<String, Bean64> collection = new HashMap<>();
                    String key = null;
                    Bean64 value = null;
                    JsonToken current;
                    String tempValue = null;
                    while (jacksonParser.nextToken() != JsonToken.END_ARRAY) {
                        current = jacksonParser.currentToken();
                        for (int i = 0; i < 2; i++) {
                            while (current != JsonToken.FIELD_NAME) {
                                current = jacksonParser.nextToken();
                            }
                            jacksonParser.nextValue();
                            switch(jacksonParser.getCurrentName()) {
                                case "key":
                                    if (jacksonParser.currentToken() != JsonToken.VALUE_NULL) {
                                        key = jacksonParser.getText();
                                    }
                                    break;
                                case "value":
                                    tempValue = jacksonParser.getValueAsString();
                                    if (jacksonParser.currentToken() == JsonToken.VALUE_STRING && "null".equals(tempValue)) {
                                        value = null;
                                    } else {
                                        if (jacksonParser.currentToken() == JsonToken.START_OBJECT || jacksonParser.currentToken() == JsonToken.VALUE_STRING) {
                                            value = bean64BindMap.parseOnJacksonAsString(jacksonParser);
                                        }
                                    }
                                    break;
                            }
                        }
                        collection.put(key, value);
                        key = null;
                        value = null;
                        jacksonParser.nextToken();
                    }
                    instance.valueMapStringBean = collection;
                }
                break;
            case "valueSetString":
                // field valueSetString (mapped with "valueSetString")
                if (jacksonParser.currentToken() == JsonToken.START_ARRAY) {
                    HashSet<String> collection = new HashSet<>();
                    String item = null;
                    String tempValue = null;
                    while (jacksonParser.nextToken() != JsonToken.END_ARRAY) {
                        tempValue = jacksonParser.getValueAsString();
                        if (jacksonParser.currentToken() == JsonToken.VALUE_STRING && "null".equals(tempValue)) {
                            item = null;
                        } else {
                            if (jacksonParser.currentToken() != JsonToken.VALUE_NULL) {
                                item = jacksonParser.getText();
                            }
                        }
                        collection.add(item);
                    }
                    instance.valueSetString = collection;
                } else if (jacksonParser.currentToken() == JsonToken.VALUE_STRING && !StringUtils.hasText(jacksonParser.getValueAsString())) {
                    HashSet<String> collection = new HashSet<>();
                    instance.valueSetString = collection;
                }
                break;
            case "valueShort":
                // field valueShort (mapped with "valueShort")
                if (jacksonParser.currentToken() != JsonToken.VALUE_NULL) {
                    instance.valueShort = PrimitiveUtils.readShort(jacksonParser.getText(), null);
                }
                break;
            case "valueShortType":
                // field valueShortType (mapped with "valueShortType")
                instance.valueShortType = PrimitiveUtils.readShort(jacksonParser.getText(), (short) 0);
                break;
            case "valueStrinList":
                // field valueStrinList (mapped with "valueStrinList")
                if (jacksonParser.currentToken() == JsonToken.START_ARRAY) {
                    LinkedList<String> collection = new LinkedList<>();
                    String item = null;
                    String tempValue = null;
                    while (jacksonParser.nextToken() != JsonToken.END_ARRAY) {
                        tempValue = jacksonParser.getValueAsString();
                        if (jacksonParser.currentToken() == JsonToken.VALUE_STRING && "null".equals(tempValue)) {
                            item = null;
                        } else {
                            if (jacksonParser.currentToken() != JsonToken.VALUE_NULL) {
                                item = jacksonParser.getText();
                            }
                        }
                        collection.add(item);
                    }
                    instance.valueStrinList = collection;
                } else if (jacksonParser.currentToken() == JsonToken.VALUE_STRING && !StringUtils.hasText(jacksonParser.getValueAsString())) {
                    LinkedList<String> collection = new LinkedList<>();
                    instance.valueStrinList = collection;
                }
                break;
            case "valueString":
                // field valueString (mapped with "valueString")
                if (jacksonParser.currentToken() != JsonToken.VALUE_NULL) {
                    instance.valueString = jacksonParser.getText();
                }
                break;
            case "valueStringArray":
                // field valueStringArray (mapped with "valueStringArray")
                if (jacksonParser.currentToken() == JsonToken.START_ARRAY) {
                    ArrayList<String> collection = new ArrayList<>();
                    String item = null;
                    String tempValue = null;
                    while (jacksonParser.nextToken() != JsonToken.END_ARRAY) {
                        tempValue = jacksonParser.getValueAsString();
                        if (jacksonParser.currentToken() == JsonToken.VALUE_STRING && "null".equals(tempValue)) {
                            item = null;
                        } else {
                            if (jacksonParser.currentToken() != JsonToken.VALUE_NULL) {
                                item = jacksonParser.getText();
                            }
                        }
                        collection.add(item);
                    }
                    instance.valueStringArray = CollectionUtils.asArray(collection, new String[collection.size()]);
                } else if (jacksonParser.currentToken() == JsonToken.VALUE_STRING && !StringUtils.hasText(jacksonParser.getValueAsString())) {
                    ArrayList<String> collection = new ArrayList<>();
                    instance.valueStringArray = CollectionUtils.asArray(collection, new String[collection.size()]);
                }
                break;
            case "valueTime":
                // field valueTime (mapped with "valueTime")
                if (jacksonParser.currentToken() != JsonToken.VALUE_NULL) {
                    instance.valueTime = SQLTimeUtils.read(jacksonParser.getText());
                }
                break;
            case "valueTimeList":
                // field valueTimeList (mapped with "valueTimeList")
                if (jacksonParser.currentToken() == JsonToken.START_ARRAY) {
                    ArrayList<Time> collection = new ArrayList<>();
                    Time item = null;
                    String tempValue = null;
                    while (jacksonParser.nextToken() != JsonToken.END_ARRAY) {
                        tempValue = jacksonParser.getValueAsString();
                        if (jacksonParser.currentToken() == JsonToken.VALUE_STRING && "null".equals(tempValue)) {
                            item = null;
                        } else {
                            item = SQLTimeUtils.read(jacksonParser.getText());
                        }
                        collection.add(item);
                    }
                    instance.valueTimeList = collection;
                } else if (jacksonParser.currentToken() == JsonToken.VALUE_STRING && !StringUtils.hasText(jacksonParser.getValueAsString())) {
                    ArrayList<Time> collection = new ArrayList<>();
                    instance.valueTimeList = collection;
                }
                break;
            case "valueTimeZone":
                // field valueTimeZone (mapped with "valueTimeZone")
                if (jacksonParser.currentToken() != JsonToken.VALUE_NULL) {
                    instance.valueTimeZone = TimeZoneUtils.read(jacksonParser.getText());
                }
                break;
            case "valueUrl":
                // field valueUrl (mapped with "valueUrl")
                if (jacksonParser.currentToken() != JsonToken.VALUE_NULL) {
                    instance.valueUrl = UrlUtils.read(jacksonParser.getText());
                }
                break;
            default:
                jacksonParser.skipChildren();
                break;
        }
    }
    return instance;
}
Also used : HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) ArrayList(java.util.ArrayList) Time(java.sql.Time) LinkedHashMap(java.util.LinkedHashMap) JsonToken(com.fasterxml.jackson.core.JsonToken) HashSet(java.util.HashSet) LinkedList(java.util.LinkedList)

Example 75 with JsonToken

use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.core.JsonToken in project kripton by xcesco.

the class BeanBindMap method parseOnJacksonAsString.

/**
 * parse with jackson
 */
@Override
public Bean parseOnJacksonAsString(JsonParser jacksonParser) throws Exception {
    Bean instance = new Bean();
    String fieldName;
    if (jacksonParser.getCurrentToken() == null) {
        jacksonParser.nextToken();
    }
    if (jacksonParser.getCurrentToken() != JsonToken.START_OBJECT) {
        jacksonParser.skipChildren();
        return instance;
    }
    while (jacksonParser.nextToken() != JsonToken.END_OBJECT) {
        fieldName = jacksonParser.getCurrentName();
        jacksonParser.nextToken();
        // Parse fields:
        switch(fieldName) {
            case "id":
                // field id (mapped with "id")
                instance.id = PrimitiveUtils.readLong(jacksonParser.getText(), 0L);
                break;
            case "valueBean":
                // field valueBean (mapped with "valueBean")
                if (jacksonParser.currentToken() == JsonToken.START_OBJECT || jacksonParser.currentToken() == JsonToken.VALUE_STRING) {
                    instance.valueBean = beanBindMap.parseOnJacksonAsString(jacksonParser);
                }
                break;
            case "valueBeanArray":
                // field valueBeanArray (mapped with "valueBeanArray")
                if (jacksonParser.currentToken() == JsonToken.START_ARRAY) {
                    ArrayList<Bean> collection = new ArrayList<>();
                    Bean item = null;
                    String tempValue = null;
                    while (jacksonParser.nextToken() != JsonToken.END_ARRAY) {
                        tempValue = jacksonParser.getValueAsString();
                        if (jacksonParser.currentToken() == JsonToken.VALUE_STRING && "null".equals(tempValue)) {
                            item = null;
                        } else {
                            item = beanBindMap.parseOnJacksonAsString(jacksonParser);
                        }
                        collection.add(item);
                    }
                    instance.valueBeanArray = CollectionUtils.asArray(collection, new Bean[collection.size()]);
                } else if (jacksonParser.currentToken() == JsonToken.VALUE_STRING && !StringUtils.hasText(jacksonParser.getValueAsString())) {
                    ArrayList<Bean> collection = new ArrayList<>();
                    instance.valueBeanArray = CollectionUtils.asArray(collection, new Bean[collection.size()]);
                }
                break;
            case "valueBigDecimal":
                // field valueBigDecimal (mapped with "valueBigDecimal")
                if (jacksonParser.currentToken() != JsonToken.VALUE_NULL) {
                    instance.valueBigDecimal = BigDecimalUtils.read(jacksonParser.getText());
                }
                break;
            case "valueBigInteger":
                // field valueBigInteger (mapped with "valueBigInteger")
                if (jacksonParser.currentToken() != JsonToken.VALUE_NULL) {
                    instance.valueBigInteger = BigIntegerUtils.read(jacksonParser.getText());
                }
                break;
            case "valueBool":
                // field valueBool (mapped with "valueBool")
                if (jacksonParser.currentToken() != JsonToken.VALUE_NULL) {
                    instance.valueBool = PrimitiveUtils.readBoolean(jacksonParser.getText(), null);
                }
                break;
            case "valueBoolType":
                // field valueBoolType (mapped with "valueBoolType")
                instance.valueBoolType = PrimitiveUtils.readBoolean(jacksonParser.getText(), (boolean) false);
                break;
            case "valueByte":
                // field valueByte (mapped with "valueByte")
                if (jacksonParser.currentToken() != JsonToken.VALUE_NULL) {
                    instance.valueByte = PrimitiveUtils.readByte(jacksonParser.getText(), null);
                }
                break;
            case "valueByteArray":
                // field valueByteArray (mapped with "valueByteArray")
                if (jacksonParser.currentToken() != JsonToken.VALUE_NULL) {
                    instance.valueByteArray = Base64Utils.decode(jacksonParser.getValueAsString());
                }
                break;
            case "valueByteType":
                // field valueByteType (mapped with "valueByteType")
                instance.valueByteType = PrimitiveUtils.readByte(jacksonParser.getText(), (byte) 0);
                break;
            case "valueCalendar":
                // field valueCalendar (mapped with "valueCalendar")
                if (jacksonParser.currentToken() != JsonToken.VALUE_NULL) {
                    instance.valueCalendar = CalendarUtils.read(jacksonParser.getText());
                }
                break;
            case "valueChar":
                // field valueChar (mapped with "valueChar")
                if (jacksonParser.currentToken() != JsonToken.VALUE_NULL) {
                    instance.valueChar = PrimitiveUtils.readCharacter(jacksonParser.getText(), null);
                }
                break;
            case "valueCharArray":
                // field valueCharArray (mapped with "valueCharArray")
                if (jacksonParser.currentToken() == JsonToken.START_ARRAY) {
                    ArrayList<Character> collection = new ArrayList<>();
                    Character item = null;
                    String tempValue = null;
                    while (jacksonParser.nextToken() != JsonToken.END_ARRAY) {
                        tempValue = jacksonParser.getValueAsString();
                        if (jacksonParser.currentToken() == JsonToken.VALUE_STRING && "null".equals(tempValue)) {
                            item = null;
                        } else {
                            item = PrimitiveUtils.readCharacter(jacksonParser.getText(), null);
                        }
                        collection.add(item);
                    }
                    instance.valueCharArray = CollectionUtils.asCharacterArray(collection);
                } else if (jacksonParser.currentToken() == JsonToken.VALUE_STRING && !StringUtils.hasText(jacksonParser.getValueAsString())) {
                    ArrayList<Character> collection = new ArrayList<>();
                    instance.valueCharArray = CollectionUtils.asCharacterArray(collection);
                }
                break;
            case "valueCharList":
                // field valueCharList (mapped with "valueCharList")
                if (jacksonParser.currentToken() == JsonToken.START_ARRAY) {
                    LinkedList<Character> collection = new LinkedList<>();
                    Character item = null;
                    String tempValue = null;
                    while (jacksonParser.nextToken() != JsonToken.END_ARRAY) {
                        tempValue = jacksonParser.getValueAsString();
                        if (jacksonParser.currentToken() == JsonToken.VALUE_STRING && "null".equals(tempValue)) {
                            item = null;
                        } else {
                            item = PrimitiveUtils.readCharacter(jacksonParser.getText(), null);
                        }
                        collection.add(item);
                    }
                    instance.valueCharList = collection;
                } else if (jacksonParser.currentToken() == JsonToken.VALUE_STRING && !StringUtils.hasText(jacksonParser.getValueAsString())) {
                    LinkedList<Character> collection = new LinkedList<>();
                    instance.valueCharList = collection;
                }
                break;
            case "valueCharType":
                // field valueCharType (mapped with "valueCharType")
                instance.valueCharType = PrimitiveUtils.readCharacter(jacksonParser.getText(), '');
                break;
            case "valueCharTypeArray":
                // field valueCharTypeArray (mapped with "valueCharTypeArray")
                if (jacksonParser.currentToken() == JsonToken.START_ARRAY) {
                    ArrayList<Character> collection = new ArrayList<>();
                    Character item = null;
                    String tempValue = null;
                    while (jacksonParser.nextToken() != JsonToken.END_ARRAY) {
                        tempValue = jacksonParser.getValueAsString();
                        if (jacksonParser.currentToken() == JsonToken.VALUE_STRING && "null".equals(tempValue)) {
                            item = null;
                        } else {
                            item = PrimitiveUtils.readCharacter(jacksonParser.getText(), '');
                        }
                        collection.add(item);
                    }
                    instance.valueCharTypeArray = CollectionUtils.asCharacterTypeArray(collection);
                } else if (jacksonParser.currentToken() == JsonToken.VALUE_STRING && !StringUtils.hasText(jacksonParser.getValueAsString())) {
                    ArrayList<Character> collection = new ArrayList<>();
                    instance.valueCharTypeArray = CollectionUtils.asCharacterTypeArray(collection);
                }
                break;
            case "valueCurrency":
                // field valueCurrency (mapped with "valueCurrency")
                if (jacksonParser.currentToken() != JsonToken.VALUE_NULL) {
                    instance.valueCurrency = CurrencyUtils.read(jacksonParser.getText());
                }
                break;
            case "valueDate":
                // field valueDate (mapped with "valueDate")
                if (jacksonParser.currentToken() != JsonToken.VALUE_NULL) {
                    instance.valueDate = DateUtils.read(jacksonParser.getText());
                }
                break;
            case "valueDouble":
                // field valueDouble (mapped with "valueDouble")
                if (jacksonParser.currentToken() != JsonToken.VALUE_NULL) {
                    instance.valueDouble = PrimitiveUtils.readDouble(jacksonParser.getText(), null);
                }
                break;
            case "valueDoubleType":
                // field valueDoubleType (mapped with "valueDoubleType")
                instance.valueDoubleType = PrimitiveUtils.readDouble(jacksonParser.getText(), 0.0);
                break;
            case "valueEnumType":
                // field valueEnumType (mapped with "valueEnumType")
                if (jacksonParser.currentToken() != JsonToken.VALUE_NULL) {
                    String tempEnum = jacksonParser.getText();
                    instance.valueEnumType = StringUtils.hasText(tempEnum) ? EnumType.valueOf(tempEnum) : null;
                }
                break;
            case "valueFloat":
                // field valueFloat (mapped with "valueFloat")
                if (jacksonParser.currentToken() != JsonToken.VALUE_NULL) {
                    instance.valueFloat = PrimitiveUtils.readFloat(jacksonParser.getText(), null);
                }
                break;
            case "valueFloatType":
                // field valueFloatType (mapped with "valueFloatType")
                instance.valueFloatType = PrimitiveUtils.readFloat(jacksonParser.getText(), 0f);
                break;
            case "valueInt":
                // field valueInt (mapped with "valueInt")
                if (jacksonParser.currentToken() != JsonToken.VALUE_NULL) {
                    instance.valueInt = PrimitiveUtils.readInteger(jacksonParser.getText(), null);
                }
                break;
            case "valueIntType":
                // field valueIntType (mapped with "valueIntType")
                instance.valueIntType = PrimitiveUtils.readInteger(jacksonParser.getText(), 0);
                break;
            case "valueLinkedMapStringBean":
                // field valueLinkedMapStringBean (mapped with "valueLinkedMapStringBean")
                if (jacksonParser.currentToken() == JsonToken.START_ARRAY) {
                    LinkedHashMap<String, Bean> collection = new LinkedHashMap<>();
                    String key = null;
                    Bean value = null;
                    JsonToken current;
                    String tempValue = null;
                    while (jacksonParser.nextToken() != JsonToken.END_ARRAY) {
                        current = jacksonParser.currentToken();
                        for (int i = 0; i < 2; i++) {
                            while (current != JsonToken.FIELD_NAME) {
                                current = jacksonParser.nextToken();
                            }
                            jacksonParser.nextValue();
                            switch(jacksonParser.getCurrentName()) {
                                case "key":
                                    if (jacksonParser.currentToken() != JsonToken.VALUE_NULL) {
                                        key = jacksonParser.getText();
                                    }
                                    break;
                                case "value":
                                    tempValue = jacksonParser.getValueAsString();
                                    if (jacksonParser.currentToken() == JsonToken.VALUE_STRING && "null".equals(tempValue)) {
                                        value = null;
                                    } else {
                                        if (jacksonParser.currentToken() == JsonToken.START_OBJECT || jacksonParser.currentToken() == JsonToken.VALUE_STRING) {
                                            value = beanBindMap.parseOnJacksonAsString(jacksonParser);
                                        }
                                    }
                                    break;
                            }
                        }
                        collection.put(key, value);
                        key = null;
                        value = null;
                        jacksonParser.nextToken();
                    }
                    instance.valueLinkedMapStringBean = collection;
                }
                break;
            case "valueLocale":
                // field valueLocale (mapped with "valueLocale")
                if (jacksonParser.currentToken() != JsonToken.VALUE_NULL) {
                    instance.valueLocale = LocaleUtils.read(jacksonParser.getText());
                }
                break;
            case "valueLong":
                // field valueLong (mapped with "valueLong")
                if (jacksonParser.currentToken() != JsonToken.VALUE_NULL) {
                    instance.valueLong = PrimitiveUtils.readLong(jacksonParser.getText(), null);
                }
                break;
            case "valueLongArray":
                // field valueLongArray (mapped with "valueLongArray")
                if (jacksonParser.currentToken() == JsonToken.START_ARRAY) {
                    ArrayList<Long> collection = new ArrayList<>();
                    Long item = null;
                    String tempValue = null;
                    while (jacksonParser.nextToken() != JsonToken.END_ARRAY) {
                        tempValue = jacksonParser.getValueAsString();
                        if (jacksonParser.currentToken() == JsonToken.VALUE_STRING && "null".equals(tempValue)) {
                            item = null;
                        } else {
                            item = PrimitiveUtils.readLong(jacksonParser.getText(), null);
                        }
                        collection.add(item);
                    }
                    instance.valueLongArray = CollectionUtils.asLongArray(collection);
                } else if (jacksonParser.currentToken() == JsonToken.VALUE_STRING && !StringUtils.hasText(jacksonParser.getValueAsString())) {
                    ArrayList<Long> collection = new ArrayList<>();
                    instance.valueLongArray = CollectionUtils.asLongArray(collection);
                }
                break;
            case "valueLongList":
                // field valueLongList (mapped with "valueLongList")
                if (jacksonParser.currentToken() == JsonToken.START_ARRAY) {
                    LinkedList<Long> collection = new LinkedList<>();
                    Long item = null;
                    String tempValue = null;
                    while (jacksonParser.nextToken() != JsonToken.END_ARRAY) {
                        tempValue = jacksonParser.getValueAsString();
                        if (jacksonParser.currentToken() == JsonToken.VALUE_STRING && "null".equals(tempValue)) {
                            item = null;
                        } else {
                            item = PrimitiveUtils.readLong(jacksonParser.getText(), null);
                        }
                        collection.add(item);
                    }
                    instance.valueLongList = collection;
                } else if (jacksonParser.currentToken() == JsonToken.VALUE_STRING && !StringUtils.hasText(jacksonParser.getValueAsString())) {
                    LinkedList<Long> collection = new LinkedList<>();
                    instance.valueLongList = collection;
                }
                break;
            case "valueLongType":
                // field valueLongType (mapped with "valueLongType")
                instance.valueLongType = PrimitiveUtils.readLong(jacksonParser.getText(), 0L);
                break;
            case "valueLongTypeArray":
                // field valueLongTypeArray (mapped with "valueLongTypeArray")
                if (jacksonParser.currentToken() == JsonToken.START_ARRAY) {
                    ArrayList<Long> collection = new ArrayList<>();
                    Long item = null;
                    String tempValue = null;
                    while (jacksonParser.nextToken() != JsonToken.END_ARRAY) {
                        tempValue = jacksonParser.getValueAsString();
                        if (jacksonParser.currentToken() == JsonToken.VALUE_STRING && "null".equals(tempValue)) {
                            item = null;
                        } else {
                            item = PrimitiveUtils.readLong(jacksonParser.getText(), 0L);
                        }
                        collection.add(item);
                    }
                    instance.valueLongTypeArray = CollectionUtils.asLongTypeArray(collection);
                } else if (jacksonParser.currentToken() == JsonToken.VALUE_STRING && !StringUtils.hasText(jacksonParser.getValueAsString())) {
                    ArrayList<Long> collection = new ArrayList<>();
                    instance.valueLongTypeArray = CollectionUtils.asLongTypeArray(collection);
                }
                break;
            case "valueMapStringBean":
                // field valueMapStringBean (mapped with "valueMapStringBean")
                if (jacksonParser.currentToken() == JsonToken.START_ARRAY) {
                    HashMap<String, Bean> collection = new HashMap<>();
                    String key = null;
                    Bean value = null;
                    JsonToken current;
                    String tempValue = null;
                    while (jacksonParser.nextToken() != JsonToken.END_ARRAY) {
                        current = jacksonParser.currentToken();
                        for (int i = 0; i < 2; i++) {
                            while (current != JsonToken.FIELD_NAME) {
                                current = jacksonParser.nextToken();
                            }
                            jacksonParser.nextValue();
                            switch(jacksonParser.getCurrentName()) {
                                case "key":
                                    if (jacksonParser.currentToken() != JsonToken.VALUE_NULL) {
                                        key = jacksonParser.getText();
                                    }
                                    break;
                                case "value":
                                    tempValue = jacksonParser.getValueAsString();
                                    if (jacksonParser.currentToken() == JsonToken.VALUE_STRING && "null".equals(tempValue)) {
                                        value = null;
                                    } else {
                                        if (jacksonParser.currentToken() == JsonToken.START_OBJECT || jacksonParser.currentToken() == JsonToken.VALUE_STRING) {
                                            value = beanBindMap.parseOnJacksonAsString(jacksonParser);
                                        }
                                    }
                                    break;
                            }
                        }
                        collection.put(key, value);
                        key = null;
                        value = null;
                        jacksonParser.nextToken();
                    }
                    instance.valueMapStringBean = collection;
                }
                break;
            case "valueSetString":
                // field valueSetString (mapped with "valueSetString")
                if (jacksonParser.currentToken() == JsonToken.START_ARRAY) {
                    HashSet<String> collection = new HashSet<>();
                    String item = null;
                    String tempValue = null;
                    while (jacksonParser.nextToken() != JsonToken.END_ARRAY) {
                        tempValue = jacksonParser.getValueAsString();
                        if (jacksonParser.currentToken() == JsonToken.VALUE_STRING && "null".equals(tempValue)) {
                            item = null;
                        } else {
                            if (jacksonParser.currentToken() != JsonToken.VALUE_NULL) {
                                item = jacksonParser.getText();
                            }
                        }
                        collection.add(item);
                    }
                    instance.valueSetString = collection;
                } else if (jacksonParser.currentToken() == JsonToken.VALUE_STRING && !StringUtils.hasText(jacksonParser.getValueAsString())) {
                    HashSet<String> collection = new HashSet<>();
                    instance.valueSetString = collection;
                }
                break;
            case "valueShort":
                // field valueShort (mapped with "valueShort")
                if (jacksonParser.currentToken() != JsonToken.VALUE_NULL) {
                    instance.valueShort = PrimitiveUtils.readShort(jacksonParser.getText(), null);
                }
                break;
            case "valueShortType":
                // field valueShortType (mapped with "valueShortType")
                instance.valueShortType = PrimitiveUtils.readShort(jacksonParser.getText(), (short) 0);
                break;
            case "valueStrinList":
                // field valueStrinList (mapped with "valueStrinList")
                if (jacksonParser.currentToken() == JsonToken.START_ARRAY) {
                    LinkedList<String> collection = new LinkedList<>();
                    String item = null;
                    String tempValue = null;
                    while (jacksonParser.nextToken() != JsonToken.END_ARRAY) {
                        tempValue = jacksonParser.getValueAsString();
                        if (jacksonParser.currentToken() == JsonToken.VALUE_STRING && "null".equals(tempValue)) {
                            item = null;
                        } else {
                            if (jacksonParser.currentToken() != JsonToken.VALUE_NULL) {
                                item = jacksonParser.getText();
                            }
                        }
                        collection.add(item);
                    }
                    instance.valueStrinList = collection;
                } else if (jacksonParser.currentToken() == JsonToken.VALUE_STRING && !StringUtils.hasText(jacksonParser.getValueAsString())) {
                    LinkedList<String> collection = new LinkedList<>();
                    instance.valueStrinList = collection;
                }
                break;
            case "valueString":
                // field valueString (mapped with "valueString")
                if (jacksonParser.currentToken() != JsonToken.VALUE_NULL) {
                    instance.valueString = jacksonParser.getText();
                }
                break;
            case "valueStringArray":
                // field valueStringArray (mapped with "valueStringArray")
                if (jacksonParser.currentToken() == JsonToken.START_ARRAY) {
                    ArrayList<String> collection = new ArrayList<>();
                    String item = null;
                    String tempValue = null;
                    while (jacksonParser.nextToken() != JsonToken.END_ARRAY) {
                        tempValue = jacksonParser.getValueAsString();
                        if (jacksonParser.currentToken() == JsonToken.VALUE_STRING && "null".equals(tempValue)) {
                            item = null;
                        } else {
                            if (jacksonParser.currentToken() != JsonToken.VALUE_NULL) {
                                item = jacksonParser.getText();
                            }
                        }
                        collection.add(item);
                    }
                    instance.valueStringArray = CollectionUtils.asArray(collection, new String[collection.size()]);
                } else if (jacksonParser.currentToken() == JsonToken.VALUE_STRING && !StringUtils.hasText(jacksonParser.getValueAsString())) {
                    ArrayList<String> collection = new ArrayList<>();
                    instance.valueStringArray = CollectionUtils.asArray(collection, new String[collection.size()]);
                }
                break;
            case "valueTime":
                // field valueTime (mapped with "valueTime")
                if (jacksonParser.currentToken() != JsonToken.VALUE_NULL) {
                    instance.valueTime = SQLTimeUtils.read(jacksonParser.getText());
                }
                break;
            case "valueTimeZone":
                // field valueTimeZone (mapped with "valueTimeZone")
                if (jacksonParser.currentToken() != JsonToken.VALUE_NULL) {
                    instance.valueTimeZone = TimeZoneUtils.read(jacksonParser.getText());
                }
                break;
            case "valueUrl":
                // field valueUrl (mapped with "valueUrl")
                if (jacksonParser.currentToken() != JsonToken.VALUE_NULL) {
                    instance.valueUrl = UrlUtils.read(jacksonParser.getText());
                }
                break;
            case "valueTimeList":
                // field valueTimeList (mapped with "valueTimeList")
                if (jacksonParser.currentToken() == JsonToken.START_ARRAY) {
                    ArrayList<Time> collection = new ArrayList<>();
                    Time item = null;
                    String tempValue = null;
                    while (jacksonParser.nextToken() != JsonToken.END_ARRAY) {
                        tempValue = jacksonParser.getValueAsString();
                        if (jacksonParser.currentToken() == JsonToken.VALUE_STRING && "null".equals(tempValue)) {
                            item = null;
                        } else {
                            item = SQLTimeUtils.read(jacksonParser.getText());
                        }
                        collection.add(item);
                    }
                    instance.valueTimeList = collection;
                } else if (jacksonParser.currentToken() == JsonToken.VALUE_STRING && !StringUtils.hasText(jacksonParser.getValueAsString())) {
                    ArrayList<Time> collection = new ArrayList<>();
                    instance.valueTimeList = collection;
                }
                break;
            default:
                jacksonParser.skipChildren();
                break;
        }
    }
    return instance;
}
Also used : HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) ArrayList(java.util.ArrayList) Time(java.sql.Time) LinkedHashMap(java.util.LinkedHashMap) JsonToken(com.fasterxml.jackson.core.JsonToken) HashSet(java.util.HashSet) LinkedList(java.util.LinkedList)

Aggregations

JsonToken (com.fasterxml.jackson.core.JsonToken)251 IOException (java.io.IOException)65 JsonParser (com.fasterxml.jackson.core.JsonParser)44 ArrayList (java.util.ArrayList)27 HashMap (java.util.HashMap)25 JsonFactory (com.fasterxml.jackson.core.JsonFactory)18 JsonParseException (com.fasterxml.jackson.core.JsonParseException)15 InvalidProtocolBufferException (com.google.protobuf.InvalidProtocolBufferException)9 ScalarFunction (com.facebook.presto.spi.function.ScalarFunction)6 SqlNullable (com.facebook.presto.spi.function.SqlNullable)6 SqlType (com.facebook.presto.spi.function.SqlType)6 JsonUtil.createJsonParser (com.facebook.presto.util.JsonUtil.createJsonParser)6 JsonParserHelper.assertExpectedJsonToken (com.alibaba.json.test.performance.JacksonPageModelParser.JsonParserHelper.assertExpectedJsonToken)5 InputStream (java.io.InputStream)5 LinkedHashMap (java.util.LinkedHashMap)5 JsonMappingException (com.fasterxml.jackson.databind.JsonMappingException)4 ByteString (com.google.protobuf.ByteString)4 HashSet (java.util.HashSet)4 MappingJsonFactory (com.fasterxml.jackson.databind.MappingJsonFactory)3 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)3