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;
}
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;
}
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;
}
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(), '