public DescribeVolumesResult unmarshall(StaxUnmarshallerContext context) throws Exception {
    DescribeVolumesResult describeVolumesResult = new DescribeVolumesResult();
    int originalDepth = context.getCurrentDepth();
    int targetDepth = originalDepth + 1;

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

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

      if (xmlEvent.isAttribute() || xmlEvent.isStartElement()) {
        if (context.testExpression("volumeSet/item", targetDepth)) {
          describeVolumesResult
              .getVolumes()
              .add(VolumeStaxUnmarshaller.getInstance().unmarshall(context));
          continue;
        }
      } else if (xmlEvent.isEndElement()) {
        if (context.getCurrentDepth() < originalDepth) {
          return describeVolumesResult;
        }
      }
    }
  }
コード例 #2
0
  public CreateVolumeResult unmarshall(StaxUnmarshallerContext context) throws Exception {
    CreateVolumeResult createVolumeResult = new CreateVolumeResult();
    int originalDepth = context.getCurrentDepth();
    int targetDepth = originalDepth + 1;

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

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

      if (xmlEvent.isAttribute() || xmlEvent.isStartElement()) {
        if (context.testExpression(".", targetDepth)) {
          createVolumeResult.setVolume(VolumeStaxUnmarshaller.getInstance().unmarshall(context));
          continue;
        }
      } else if (xmlEvent.isEndElement()) {
        if (context.getCurrentDepth() < originalDepth) {
          return createVolumeResult;
        }
      }
    }
  }