Пример #1
0
 // Creates Volume
 public static String createVolume() {
   System.out.println("Create a volume");
   CreateVolumeRequest cvr = new CreateVolumeRequest();
   cvr.setAvailabilityZone("us-east-1a");
   cvr.setSize(10); // size = 10 gigabytes
   CreateVolumeResult volumeResult = ec2.createVolume(cvr);
   String createdVolumeId = volumeResult.getVolume().getVolumeId();
   return createdVolumeId;
 }
  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;
        }
      }
    }
  }