コード例 #1
0
 public DeviceType unmarshall(JsonUnmarshallerContext context) throws Exception {
   AwsJsonReader reader = context.getReader();
   if (!reader.isContainer()) {
     reader.skipValue();
     return null;
   }
   DeviceType deviceType = new DeviceType();
   reader.beginObject();
   while (reader.hasNext()) {
     String name = reader.nextName();
     if (name.equals("DeviceKey")) {
       deviceType.setDeviceKey(StringJsonUnmarshaller.getInstance().unmarshall(context));
     } else if (name.equals("DeviceAttributes")) {
       deviceType.setDeviceAttributes(
           new ListUnmarshaller<AttributeType>(AttributeTypeJsonUnmarshaller.getInstance())
               .unmarshall(context));
     } else if (name.equals("DeviceCreateDate")) {
       deviceType.setDeviceCreateDate(DateJsonUnmarshaller.getInstance().unmarshall(context));
     } else if (name.equals("DeviceLastModifiedDate")) {
       deviceType.setDeviceLastModifiedDate(
           DateJsonUnmarshaller.getInstance().unmarshall(context));
     } else if (name.equals("DeviceLastAuthenticatedDate")) {
       deviceType.setDeviceLastAuthenticatedDate(
           DateJsonUnmarshaller.getInstance().unmarshall(context));
     } else {
       reader.skipValue();
     }
   }
   reader.endObject();
   return deviceType;
 }
コード例 #2
0
  public UserType unmarshall(JsonUnmarshallerContext context) throws Exception {
    UserType userType = new UserType();

    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("Username", targetDepth)) {
          context.nextToken();
          userType.setUsername(context.getUnmarshaller(String.class).unmarshall(context));
        }
        if (context.testExpression("Attributes", targetDepth)) {
          context.nextToken();
          userType.setAttributes(
              new ListUnmarshaller<AttributeType>(AttributeTypeJsonUnmarshaller.getInstance())
                  .unmarshall(context));
        }
        if (context.testExpression("UserCreateDate", targetDepth)) {
          context.nextToken();
          userType.setUserCreateDate(
              context.getUnmarshaller(java.util.Date.class).unmarshall(context));
        }
        if (context.testExpression("UserLastModifiedDate", targetDepth)) {
          context.nextToken();
          userType.setUserLastModifiedDate(
              context.getUnmarshaller(java.util.Date.class).unmarshall(context));
        }
        if (context.testExpression("Enabled", targetDepth)) {
          context.nextToken();
          userType.setEnabled(context.getUnmarshaller(Boolean.class).unmarshall(context));
        }
        if (context.testExpression("UserStatus", targetDepth)) {
          context.nextToken();
          userType.setUserStatus(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 userType;
  }