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

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

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

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

        if (context.testExpression("NodeGroupId", targetDepth)) {
          nodeGroup.setNodeGroupId(StringStaxUnmarshaller.getInstance().unmarshall(context));
          continue;
        }

        if (context.testExpression("Status", targetDepth)) {
          nodeGroup.setStatus(StringStaxUnmarshaller.getInstance().unmarshall(context));
          continue;
        }

        if (context.testExpression("PrimaryEndpoint", targetDepth)) {
          nodeGroup.setPrimaryEndpoint(EndpointStaxUnmarshaller.getInstance().unmarshall(context));
          continue;
        }

        if (context.testExpression("NodeGroupMembers/NodeGroupMember", targetDepth)) {
          nodeGroup.withNodeGroupMembers(
              NodeGroupMemberStaxUnmarshaller.getInstance().unmarshall(context));
          continue;
        }

      } else if (xmlEvent.isEndElement()) {
        if (context.getCurrentDepth() < originalDepth) {
          return nodeGroup;
        }
      }
    }
  }