Java Code Examples for com.amazonaws.transform.JsonUnmarshallerContext#testExpression()

The following examples show how to use com.amazonaws.transform.JsonUnmarshallerContext#testExpression() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ApplicationListJsonUnmarshaller.java    From realworld-serverless-application with Apache License 2.0 5 votes vote down vote up
public ApplicationList unmarshall(JsonUnmarshallerContext context) throws Exception {
  ApplicationList applicationList = new ApplicationList();

  int originalDepth = context.getCurrentDepth();
  String currentParentElement = context.getCurrentParentElement();
  int targetDepth = originalDepth + 1;

  JsonToken token = context.getCurrentToken();
  if (token == null)
    token = context.nextToken();
  if (token == VALUE_NULL) {
    return null;
  }

  while (true) {
    if (token == null)
      break;

    if (token == FIELD_NAME || token == START_OBJECT) {
      if (context.testExpression("applications", targetDepth)) {
        context.nextToken();
        applicationList.setApplications(new ListUnmarshaller<ApplicationSummary>(ApplicationSummaryJsonUnmarshaller.getInstance())
                .unmarshall(context));
      }
      if (context.testExpression("nextToken", targetDepth)) {
        context.nextToken();
        applicationList.setNextToken(context.getUnmarshaller(String.class).unmarshall(context));
      }
    } else if (token == END_ARRAY || token == END_OBJECT) {
      if (context.getLastParsedParentElement() == null || context.getLastParsedParentElement().equals(currentParentElement)) {
        if (context.getCurrentDepth() <= originalDepth)
          break;
      }
    }
    token = context.nextToken();
  }

  return applicationList;
}
 
Example 2
Source File: ListLexiconsResultJsonUnmarshaller.java    From ivona-speechcloud-sdk-java with Apache License 2.0 5 votes vote down vote up
public ListLexiconsResult unmarshall(JsonUnmarshallerContext context) throws Exception {
    ListLexiconsResult listLexiconsResult = new ListLexiconsResult();

    int originalDepth = context.getCurrentDepth();
    String currentParentElement = context.getCurrentParentElement();
    int targetDepth = originalDepth + 1;

    JsonToken token = context.getCurrentToken();
    if (token == null) {
        token = context.nextToken();
    }
    if (token == VALUE_NULL) {
        return null;
    }

    while (true) {
        if (token == null) {
            break;
        }

        if (token == FIELD_NAME || token == START_OBJECT) {
            if (context.testExpression(JSON_KEY_LEXICONS, targetDepth)) {
                listLexiconsResult.setLexiconNames(new ListUnmarshaller<String>(
                        SimpleTypeJsonUnmarshallers.StringJsonUnmarshaller.getInstance()).unmarshall(context));
            }
        } else if (token == END_ARRAY || token == END_OBJECT) {
            if (context.getLastParsedParentElement() == null
                    || context.getLastParsedParentElement().equals(currentParentElement)) {
                if (context.getCurrentDepth() <= originalDepth) {
                    break;
                }
            }
        }

        token = context.nextToken();
    }

    return listLexiconsResult;
}
 
Example 3
Source File: GetLexiconResultJsonUnmarshaller.java    From ivona-speechcloud-sdk-java with Apache License 2.0 5 votes vote down vote up
public GetLexiconResult unmarshall(JsonUnmarshallerContext context) throws Exception {
    GetLexiconResult getLexiconResult = new GetLexiconResult();

    int originalDepth = context.getCurrentDepth();
    String currentParentElement = context.getCurrentParentElement();
    int targetDepth = originalDepth + 1;

    JsonToken token = context.getCurrentToken();
    if (token == null) {
        token = context.nextToken();
    }
    if (token == VALUE_NULL) {
        return null;
    }

    while (true) {
        if (token == null) {
            break;
        }

        if (token == FIELD_NAME || token == START_OBJECT) {
            if (context.testExpression(JSON_KEY_LEXICON, targetDepth)) {
                context.nextToken();
                getLexiconResult.setLexicon(LexiconJsonUnmarshaller.getInstance().unmarshall(context));
            }
        } else if (token == END_ARRAY || token == END_OBJECT) {
            if (context.getLastParsedParentElement() == null
                    || context.getLastParsedParentElement().equals(currentParentElement)) {
                if (context.getCurrentDepth() <= originalDepth) {
                    break;
                }
            }
        }

        token = context.nextToken();
    }

    return getLexiconResult;
}
 
Example 4
Source File: ListVoicesResultJsonUnmarshaller.java    From ivona-speechcloud-sdk-java with Apache License 2.0 5 votes vote down vote up
public ListVoicesResult unmarshall(JsonUnmarshallerContext context) throws Exception {
    ListVoicesResult listVoicesResult = new ListVoicesResult();

    int originalDepth = context.getCurrentDepth();
    String currentParentElement = context.getCurrentParentElement();
    int targetDepth = originalDepth + 1;

    JsonToken token = context.getCurrentToken();
    if (token == null) {
        token = context.nextToken();
    }
    if (token == VALUE_NULL) {
        return null;
    }

    while (true) {
        if (token == null) {
            break;
        }

        if (token == FIELD_NAME || token == START_OBJECT) {
            if (context.testExpression(JSON_KEY_VOICES, targetDepth)) {
                listVoicesResult.setVoices(new ListUnmarshaller<Voice>(VoiceJsonUnmarshaller.getInstance())
                        .unmarshall(context));
            }
        } else if (token == END_ARRAY || token == END_OBJECT) {
            if (context.getLastParsedParentElement() == null
                    || context.getLastParsedParentElement().equals(currentParentElement)) {
                if (context.getCurrentDepth() <= originalDepth) {
                    break;
                }
            }
        }

        token = context.nextToken();
    }

    return listVoicesResult;
}
 
Example 5
Source File: ApplicationJsonUnmarshaller.java    From realworld-serverless-application with Apache License 2.0 4 votes vote down vote up
public Application unmarshall(JsonUnmarshallerContext context) throws Exception {
  Application application = new Application();

  int originalDepth = context.getCurrentDepth();
  String currentParentElement = context.getCurrentParentElement();
  int targetDepth = originalDepth + 1;

  JsonToken token = context.getCurrentToken();
  if (token == null)
    token = context.nextToken();
  if (token == VALUE_NULL) {
    return null;
  }

  while (true) {
    if (token == null)
      break;

    if (token == FIELD_NAME || token == START_OBJECT) {
      if (context.testExpression("applicationId", targetDepth)) {
        context.nextToken();
        application.setApplicationId(context.getUnmarshaller(String.class).unmarshall(context));
      }
      if (context.testExpression("author", targetDepth)) {
        context.nextToken();
        application.setAuthor(context.getUnmarshaller(String.class).unmarshall(context));
      }
      if (context.testExpression("creationTime", targetDepth)) {
        context.nextToken();
        application.setCreationTime(context.getUnmarshaller(String.class).unmarshall(context));
      }
      if (context.testExpression("description", targetDepth)) {
        context.nextToken();
        application.setDescription(context.getUnmarshaller(String.class).unmarshall(context));
      }
      if (context.testExpression("homePageUrl", targetDepth)) {
        context.nextToken();
        application.setHomePageUrl(context.getUnmarshaller(String.class).unmarshall(context));
      }
    } else if (token == END_ARRAY || token == END_OBJECT) {
      if (context.getLastParsedParentElement() == null || context.getLastParsedParentElement().equals(currentParentElement)) {
        if (context.getCurrentDepth() <= originalDepth)
          break;
      }
    }
    token = context.nextToken();
  }

  return application;
}
 
Example 6
Source File: ApplicationSummaryJsonUnmarshaller.java    From realworld-serverless-application with Apache License 2.0 4 votes vote down vote up
public ApplicationSummary unmarshall(JsonUnmarshallerContext context) throws Exception {
  ApplicationSummary applicationSummary = new ApplicationSummary();

  int originalDepth = context.getCurrentDepth();
  String currentParentElement = context.getCurrentParentElement();
  int targetDepth = originalDepth + 1;

  JsonToken token = context.getCurrentToken();
  if (token == null)
    token = context.nextToken();
  if (token == VALUE_NULL) {
    return null;
  }

  while (true) {
    if (token == null)
      break;

    if (token == FIELD_NAME || token == START_OBJECT) {
      if (context.testExpression("applicationId", targetDepth)) {
        context.nextToken();
        applicationSummary.setApplicationId(context.getUnmarshaller(String.class).unmarshall(context));
      }
      if (context.testExpression("creationTime", targetDepth)) {
        context.nextToken();
        applicationSummary.setCreationTime(context.getUnmarshaller(String.class).unmarshall(context));
      }
      if (context.testExpression("description", targetDepth)) {
        context.nextToken();
        applicationSummary.setDescription(context.getUnmarshaller(String.class).unmarshall(context));
      }
    } else if (token == END_ARRAY || token == END_OBJECT) {
      if (context.getLastParsedParentElement() == null || context.getLastParsedParentElement().equals(currentParentElement)) {
        if (context.getCurrentDepth() <= originalDepth)
          break;
      }
    }
    token = context.nextToken();
  }

  return applicationSummary;
}
 
Example 7
Source File: CreateApplicationInputJsonUnmarshaller.java    From realworld-serverless-application with Apache License 2.0 4 votes vote down vote up
public CreateApplicationInput unmarshall(JsonUnmarshallerContext context) throws Exception {
  CreateApplicationInput createApplicationInput = new CreateApplicationInput();

  int originalDepth = context.getCurrentDepth();
  String currentParentElement = context.getCurrentParentElement();
  int targetDepth = originalDepth + 1;

  JsonToken token = context.getCurrentToken();
  if (token == null)
    token = context.nextToken();
  if (token == VALUE_NULL) {
    return null;
  }

  while (true) {
    if (token == null)
      break;

    if (token == FIELD_NAME || token == START_OBJECT) {
      if (context.testExpression("applicationId", targetDepth)) {
        context.nextToken();
        createApplicationInput.setApplicationId(context.getUnmarshaller(String.class).unmarshall(context));
      }
      if (context.testExpression("author", targetDepth)) {
        context.nextToken();
        createApplicationInput.setAuthor(context.getUnmarshaller(String.class).unmarshall(context));
      }
      if (context.testExpression("description", targetDepth)) {
        context.nextToken();
        createApplicationInput.setDescription(context.getUnmarshaller(String.class).unmarshall(context));
      }
      if (context.testExpression("homePageUrl", targetDepth)) {
        context.nextToken();
        createApplicationInput.setHomePageUrl(context.getUnmarshaller(String.class).unmarshall(context));
      }
    } else if (token == END_ARRAY || token == END_OBJECT) {
      if (context.getLastParsedParentElement() == null || context.getLastParsedParentElement().equals(currentParentElement)) {
        if (context.getCurrentDepth() <= originalDepth)
          break;
      }
    }
    token = context.nextToken();
  }

  return createApplicationInput;
}
 
Example 8
Source File: UpdateApplicationInputJsonUnmarshaller.java    From realworld-serverless-application with Apache License 2.0 4 votes vote down vote up
public UpdateApplicationInput unmarshall(JsonUnmarshallerContext context) throws Exception {
  UpdateApplicationInput updateApplicationInput = new UpdateApplicationInput();

  int originalDepth = context.getCurrentDepth();
  String currentParentElement = context.getCurrentParentElement();
  int targetDepth = originalDepth + 1;

  JsonToken token = context.getCurrentToken();
  if (token == null)
    token = context.nextToken();
  if (token == VALUE_NULL) {
    return null;
  }

  while (true) {
    if (token == null)
      break;

    if (token == FIELD_NAME || token == START_OBJECT) {
      if (context.testExpression("author", targetDepth)) {
        context.nextToken();
        updateApplicationInput.setAuthor(context.getUnmarshaller(String.class).unmarshall(context));
      }
      if (context.testExpression("description", targetDepth)) {
        context.nextToken();
        updateApplicationInput.setDescription(context.getUnmarshaller(String.class).unmarshall(context));
      }
      if (context.testExpression("homePageUrl", targetDepth)) {
        context.nextToken();
        updateApplicationInput.setHomePageUrl(context.getUnmarshaller(String.class).unmarshall(context));
      }
    } else if (token == END_ARRAY || token == END_OBJECT) {
      if (context.getLastParsedParentElement() == null || context.getLastParsedParentElement().equals(currentParentElement)) {
        if (context.getCurrentDepth() <= originalDepth)
          break;
      }
    }
    token = context.nextToken();
  }

  return updateApplicationInput;
}
 
Example 9
Source File: LexiconJsonUnmarshaller.java    From ivona-speechcloud-sdk-java with Apache License 2.0 4 votes vote down vote up
public Lexicon unmarshall(JsonUnmarshallerContext context) throws Exception {
    Lexicon lexicon = new Lexicon();

    int originalDepth = context.getCurrentDepth();
    String currentParentElement = context.getCurrentParentElement();
    int targetDepth = originalDepth + 1;

    JsonToken token = context.getCurrentToken();
    if (token == null) {
        token = context.nextToken();
    }
    if (token == VALUE_NULL) {
        return null;
    }

    while (true) {
        if (token == null) {
            break;
        }

        if (token == FIELD_NAME || token == START_OBJECT) {
            if (context.testExpression(JSON_KEY_NAME, targetDepth)) {
                context.nextToken();
                lexicon.setName(
                        SimpleTypeJsonUnmarshallers.StringJsonUnmarshaller.getInstance().unmarshall(context));
            }
            if (context.testExpression(JSON_KEY_CONTENTS, targetDepth)) {
                context.nextToken();
                lexicon.setContents(
                        SimpleTypeJsonUnmarshallers.StringJsonUnmarshaller.getInstance().unmarshall(context));
            }
        } else if (token == END_ARRAY || token == END_OBJECT) {
            if (context.getLastParsedParentElement() == null
                    || context.getLastParsedParentElement().equals(currentParentElement)) {
                if (context.getCurrentDepth() <= originalDepth) {
                    break;
                }
            }
        }

        token = context.nextToken();
    }

    return lexicon;
}
 
Example 10
Source File: VoiceJsonUnmarshaller.java    From ivona-speechcloud-sdk-java with Apache License 2.0 4 votes vote down vote up
public Voice unmarshall(JsonUnmarshallerContext context) throws Exception {

        Voice voice = new Voice();

        int originalDepth = context.getCurrentDepth();
        String currentParentElement = context.getCurrentParentElement();
        int targetDepth = originalDepth + 1;

        JsonToken token = context.getCurrentToken();
        if (token == null) {
            token = context.nextToken();
        }
        if (token == VALUE_NULL) {
            return null;
        }

        while (true) {
            if (token == null) {
                break;
            }

            if (token == FIELD_NAME || token == START_OBJECT) {
                if (context.testExpression(JSON_KEY_NAME, targetDepth)) {
                    context.nextToken();
                    voice.setName(
                            SimpleTypeJsonUnmarshallers.StringJsonUnmarshaller.getInstance().unmarshall(context));
                }
                if (context.testExpression(JSON_KEY_LANGUAGE, targetDepth)) {
                    context.nextToken();
                    voice.setLanguage(
                            SimpleTypeJsonUnmarshallers.StringJsonUnmarshaller.getInstance().unmarshall(context));
                }
                if (context.testExpression(JSON_KEY_GENDER, targetDepth)) {
                    context.nextToken();
                    voice.setGender(
                            SimpleTypeJsonUnmarshallers.StringJsonUnmarshaller.getInstance().unmarshall(context));
                }
            } else if (token == END_ARRAY || token == END_OBJECT) {
                if (context.getLastParsedParentElement() == null
                        || context.getLastParsedParentElement().equals(currentParentElement)) {
                    if (context.getCurrentDepth() <= originalDepth) {
                        break;
                    }
                }
            }

            token = context.nextToken();
        }

        return voice;
    }