use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.core.JsonToken in project geode by apache.
the class JSONFormatter method getList.
private PdxListHelper getList(JsonParser jp, states currentState, PdxListHelper currentPdxList) throws JsonParseException, IOException {
String currentFieldName = null;
currentPdxList = new PdxListHelper(currentPdxList, null);
while (true) {
JsonToken nt = jp.nextToken();
if (nt == null) {
return currentPdxList;
}
switch(nt) {
case START_OBJECT:
{
objectStarts(currentState);
currentState = states.OBJECT_START;
// need to create new PdxInstance
// root object will not name, so create classname lazily from all members.
// child object will have name; but create this as well lazily from all members
JSONToPdxMapper tmp = getPdxInstance(jp, currentState, null);
currentPdxList.addObjectField(currentFieldName, tmp);
currentState = states.OBJECT_ENDS;
break;
}
case END_OBJECT:
{
// pdxinstnce ends
throw new IllegalStateException("getList got token END_OBJECT while current state is " + currentState);
}
case FIELD_NAME:
{
throw new IllegalStateException("getList got token FIELD_NAME while current state is " + currentState);
}
case NOT_AVAILABLE:
{
throw new IllegalStateException("NOT_AVAILABLE token found in getList current state is " + currentState);
// break;
}
case START_ARRAY:
{
// need to create array; fieldname may be there; will it case it not there
arrayStarts(currentState);
PdxListHelper tmp = currentPdxList.addListField();
currentPdxList = tmp;
currentState = states.LIST_FOUND;
break;
}
case END_ARRAY:
{
// array is end
arrayEnds(currentState);
currentState = states.LIST_ENDS;
if (currentPdxList.getParent() == null) {
return currentPdxList;
}
currentPdxList = currentPdxList.getParent();
break;
}
case VALUE_EMBEDDED_OBJECT:
{
throw new IllegalStateException("VALUE_EMBEDDED_OBJECT token found");
}
case VALUE_FALSE:
{
// write boolen
boolFound(currentState);
currentState = states.SCALAR_FOUND;
currentPdxList.addBooleanField(jp.getBooleanValue());
break;
}
case VALUE_NULL:
{
// write null
nullFound(currentState);
currentState = states.SCALAR_FOUND;
currentPdxList.addNullField(null);
break;
}
case VALUE_NUMBER_FLOAT:
{
// write double/float
doubleFound(currentState);
currentState = states.SCALAR_FOUND;
// currentPdxList.addDoubleField(jp.getDoubleValue());
setNumberField(jp, currentPdxList);
break;
}
case VALUE_NUMBER_INT:
{
// write int
intFound(currentState);
currentState = states.SCALAR_FOUND;
// currentPdxList.addIntField(jp.getIntValue());
setNumberField(jp, currentPdxList);
break;
}
case VALUE_STRING:
{
// write string
stringFound(currentState);
currentState = states.SCALAR_FOUND;
currentPdxList.addStringField(jp.getText());
currentFieldName = null;
break;
}
case VALUE_TRUE:
{
// write bool
boolFound(currentState);
currentState = states.SCALAR_FOUND;
currentPdxList.addBooleanField(jp.getBooleanValue());
break;
}
default:
{
throw new IllegalStateException("Token not handled in getlist" + nt);
}
}
}
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.core.JsonToken in project atlasmap by atlasmap.
the class ActionsJsonDeserializer method processReplaceAllJsonToken.
protected ReplaceAll processReplaceAllJsonToken(JsonParser jsonToken) throws IOException {
ReplaceAll action = new ReplaceAll();
if (JsonToken.END_ARRAY.equals(jsonToken.currentToken()) || JsonToken.END_OBJECT.equals(jsonToken.currentToken())) {
return action;
}
JsonToken nextToken = null;
do {
if (JsonToken.START_OBJECT.equals(jsonToken.currentToken())) {
jsonToken.nextToken();
}
switch(jsonToken.getCurrentName()) {
case ActionsJsonSerializer.MATCH:
jsonToken.nextToken();
action.setMatch(jsonToken.getValueAsString());
break;
case ActionsJsonSerializer.NEW_STRING:
jsonToken.nextToken();
action.setNewString(jsonToken.getValueAsString());
break;
default:
break;
}
nextToken = jsonToken.nextToken();
} while (!JsonToken.END_ARRAY.equals(nextToken) && !JsonToken.END_OBJECT.equals(nextToken));
return action;
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.core.JsonToken in project atlasmap by atlasmap.
the class ActionsJsonDeserializer method processConcatenateJsonToken.
protected Concatenate processConcatenateJsonToken(JsonParser jsonToken) throws IOException {
Concatenate action = new Concatenate();
if (JsonToken.END_ARRAY.equals(jsonToken.currentToken()) || JsonToken.END_OBJECT.equals(jsonToken.currentToken())) {
return action;
}
JsonToken nextToken = null;
do {
if (JsonToken.START_OBJECT.equals(jsonToken.currentToken())) {
jsonToken.nextToken();
}
switch(jsonToken.getCurrentName()) {
case ActionsJsonSerializer.DELIMITER:
jsonToken.nextToken();
action.setDelimiter(jsonToken.getValueAsString());
break;
default:
break;
}
nextToken = jsonToken.nextToken();
} while (!JsonToken.END_ARRAY.equals(nextToken) && !JsonToken.END_OBJECT.equals(nextToken));
return action;
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.core.JsonToken in project atlasmap by atlasmap.
the class ActionsJsonDeserializer method processSubStringJsonToken.
protected SubString processSubStringJsonToken(JsonParser jsonToken) throws IOException {
SubString action = new SubString();
if (JsonToken.END_ARRAY.equals(jsonToken.currentToken()) || JsonToken.END_OBJECT.equals(jsonToken.currentToken())) {
return action;
}
JsonToken nextToken = null;
do {
if (JsonToken.START_OBJECT.equals(jsonToken.currentToken())) {
jsonToken.nextToken();
}
switch(jsonToken.getCurrentName()) {
case ActionsJsonSerializer.START_INDEX:
jsonToken.nextToken();
action.setStartIndex(jsonToken.getIntValue());
break;
case ActionsJsonSerializer.END_INDEX:
jsonToken.nextToken();
action.setEndIndex(jsonToken.getIntValue());
break;
default:
break;
}
nextToken = jsonToken.nextToken();
} while (!JsonToken.END_ARRAY.equals(nextToken) && !JsonToken.END_OBJECT.equals(nextToken));
return action;
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.core.JsonToken in project atlasmap by atlasmap.
the class ActionsJsonDeserializer method processConvertAreaUnitJsonToken.
protected ConvertAreaUnit processConvertAreaUnitJsonToken(JsonParser jsonToken) throws IOException {
ConvertAreaUnit action = new ConvertAreaUnit();
if (JsonToken.END_ARRAY.equals(jsonToken.currentToken()) || JsonToken.END_OBJECT.equals(jsonToken.currentToken())) {
return action;
}
JsonToken nextToken = null;
do {
if (JsonToken.START_OBJECT.equals(jsonToken.currentToken())) {
jsonToken.nextToken();
}
switch(jsonToken.getCurrentName()) {
case ActionsJsonSerializer.FROM_UNIT:
jsonToken.nextToken();
action.setFromUnit(AreaUnitType.fromValue(jsonToken.getValueAsString()));
break;
case ActionsJsonSerializer.TO_UNIT:
jsonToken.nextToken();
action.setToUnit(AreaUnitType.fromValue(jsonToken.getValueAsString()));
break;
default:
break;
}
nextToken = jsonToken.nextToken();
} while (!JsonToken.END_ARRAY.equals(nextToken) && !JsonToken.END_OBJECT.equals(nextToken));
return action;
}
Aggregations