public void endElement()

in apis/ec2/src/main/java/org/jclouds/ec2/xml/DescribeImagesResponseHandler.java [117:223]


   public void endElement(String uri, String name, String qName) {
      if (equalsOrSuffix(qName, "tagSet")) {
         inTagSet = false;
         tags = tagSetHandler.getResult();
      } else if (inTagSet) {
         tagSetHandler.endElement(uri, name, qName);
      }
      if (qName.equals("architecture")) {
         architecture = Architecture.fromValue(currentText.toString().trim());
      // Nova Diablo uses the wrong name for this field
      } else if (qName.equals("name") || qName.equals("displayName")) {
         this.name = currentText.toString().trim();
      } else if (qName.equals("description")) {
         description = currentText.toString().trim();
      } else if (qName.equals("imageId")) {
         imageId = currentText.toString().trim();
      } else if (qName.equals("deviceName")) {
         deviceName = currentText.toString().trim();
      } else if (qName.equals("imageLocation")) {
         imageLocation = currentText.toString().trim();
      } else if (qName.equals("imageOwnerId")) {
         imageOwnerId = currentText.toString().trim();
      } else if (qName.equals("imageState")) {
         rawState = currentOrNull(currentText);
         imageState = ImageState.fromValue(rawState);
      } else if (qName.equals("imageType")) {
         imageType = ImageType.fromValue(currentText.toString().trim());
      } else if (qName.equals("isPublic")) {
         isPublic = Boolean.parseBoolean(currentText.toString().trim());
      } else if (qName.equals("kernelId")) {
         kernelId = currentText.toString().trim();
      } else if (qName.equals("platform")) {
         platform = currentText.toString().trim();
      } else if (qName.equals("productCode")) {
         productCodes.add(currentText.toString().trim());
      } else if (qName.equals("productCodes")) {
         inProductCodes = false;
      } else if (qName.equals("blockDeviceMapping")) {
         inBlockDeviceMapping = false;
      } else if (qName.equals("snapshotId")) {
         snapshotId = currentText.toString().trim();
      } else if (qName.equals("volumeSize")) {
         volumeSize = Integer.parseInt(currentText.toString().trim());
      } else if (qName.equals("deleteOnTermination")) {
         deleteOnTermination = Boolean.parseBoolean(currentText.toString().trim());
      } else if (qName.equals("encrypted")) {
         encrypted = Boolean.parseBoolean(currentText.toString().trim());
      } else if (qName.equals("iops")) {
         iops = Integer.valueOf(currentText.toString().trim());
      } else if (qName.equals("volumeType")) {
         volumeType = currentText.toString().trim();
      } else if (qName.equals("ramdiskId")) {
         ramdiskId = currentText.toString().trim();
      } else if (qName.equals("rootDeviceType")) {
         rootDeviceType = RootDeviceType.fromValue(currentText.toString().trim());
      } else if (qName.equals("rootDeviceName")) {
         rootDeviceName = currentText.toString().trim();
      } else if (qName.equals("virtualizationType")) {
         virtualizationType = VirtualizationType.fromValue(currentText.toString().trim());
      } else if (qName.equals("hypervisor")) {
         hypervisor = Hypervisor.fromValue(currentText.toString().trim());
      } else if (qName.equals("item")) {
         if (inBlockDeviceMapping) {
            ebsBlockDevices.put(deviceName, new Image.EbsBlockDevice(snapshotId, volumeSize, deleteOnTermination,
                    volumeType, iops, encrypted));
            this.deviceName = null;
            this.snapshotId = null;
            this.volumeSize = 0;
            this.deleteOnTermination = true;
            this.encrypted = false;
            this.volumeType = null;
            this.iops = null;
         } else if (!inTagSet && !inProductCodes) {
            try {
               String region = getRequest() != null ? AWSUtils.findRegionInArgsOrNull(getRequest()) : null;
               if (region == null)
                  region = defaultRegion.get();
               contents.add(new Image(region, architecture, this.name, description, imageId, imageLocation,
                        imageOwnerId, imageState, rawState, imageType, isPublic, productCodes, kernelId, platform,
                        ramdiskId, rootDeviceType, rootDeviceName, ebsBlockDevices, tags, virtualizationType, hypervisor));
            } catch (NullPointerException e) {
               logger.warn(e, "malformed image: %s", imageId);
            }
            this.name = null;
            this.description = null;
            this.architecture = null;
            this.imageId = null;
            this.imageLocation = null;
            this.imageOwnerId = null;
            this.imageState = null;
            this.rawState = null;
            this.imageType = null;
            this.isPublic = false;
            this.kernelId = null;
            this.platform = null;
            this.productCodes = Sets.newHashSet();
            this.ramdiskId = null;
            this.rootDeviceType = RootDeviceType.INSTANCE_STORE;
            this.rootDeviceName = null;
            this.ebsBlockDevices = Maps.newHashMap();
            this.virtualizationType = VirtualizationType.PARAVIRTUAL;
            this.hypervisor = Hypervisor.XEN;
         }

      }
      currentText.setLength(0);
   }