コード例 #1
0
  public Route unmarshall(StaxUnmarshallerContext context) throws Exception {
    Route route = new Route();
    int originalDepth = context.getCurrentDepth();
    int targetDepth = originalDepth + 1;

    if (context.isStartOfDocument()) targetDepth += 1;

    while (true) {
      XMLEvent xmlEvent = context.nextEvent();
      if (xmlEvent.isEndDocument()) return route;

      if (xmlEvent.isAttribute() || xmlEvent.isStartElement()) {

        if (context.testExpression("destinationCidrBlock", targetDepth)) {
          route.setDestinationCidrBlock(StringStaxUnmarshaller.getInstance().unmarshall(context));
          continue;
        }

        if (context.testExpression("destinationPrefixListId", targetDepth)) {
          route.setDestinationPrefixListId(
              StringStaxUnmarshaller.getInstance().unmarshall(context));
          continue;
        }

        if (context.testExpression("gatewayId", targetDepth)) {
          route.setGatewayId(StringStaxUnmarshaller.getInstance().unmarshall(context));
          continue;
        }

        if (context.testExpression("instanceId", targetDepth)) {
          route.setInstanceId(StringStaxUnmarshaller.getInstance().unmarshall(context));
          continue;
        }

        if (context.testExpression("instanceOwnerId", targetDepth)) {
          route.setInstanceOwnerId(StringStaxUnmarshaller.getInstance().unmarshall(context));
          continue;
        }

        if (context.testExpression("networkInterfaceId", targetDepth)) {
          route.setNetworkInterfaceId(StringStaxUnmarshaller.getInstance().unmarshall(context));
          continue;
        }

        if (context.testExpression("vpcPeeringConnectionId", targetDepth)) {
          route.setVpcPeeringConnectionId(StringStaxUnmarshaller.getInstance().unmarshall(context));
          continue;
        }

        if (context.testExpression("natGatewayId", targetDepth)) {
          route.setNatGatewayId(StringStaxUnmarshaller.getInstance().unmarshall(context));
          continue;
        }

        if (context.testExpression("state", targetDepth)) {
          route.setState(StringStaxUnmarshaller.getInstance().unmarshall(context));
          continue;
        }

        if (context.testExpression("origin", targetDepth)) {
          route.setOrigin(StringStaxUnmarshaller.getInstance().unmarshall(context));
          continue;
        }
      } else if (xmlEvent.isEndElement()) {
        if (context.getCurrentDepth() < originalDepth) {
          return route;
        }
      }
    }
  }