EMMA Coverage Report (generated Mon Oct 17 05:41:20 EDT 2011)
[all classes][org.jclouds.aws.ec2.xml]

COVERAGE SUMMARY FOR SOURCE FILE [ReservedInstancesOfferingHandler.java]

nameclass, %method, %block, %line, %
ReservedInstancesOfferingHandler.java100% (1/1)100% (4/4)100% (161/161)100% (35/35)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class ReservedInstancesOfferingHandler100% (1/1)100% (4/4)100% (161/161)100% (35/35)
ReservedInstancesOfferingHandler (): void 100% (1/1)100% (17/17)100% (5/5)
characters (char [], int, int): void 100% (1/1)100% (8/8)100% (2/2)
endElement (String, String, String): void 100% (1/1)100% (85/85)100% (16/16)
getResult (): ReservedInstancesOffering 100% (1/1)100% (51/51)100% (12/12)

1/**
2 * Licensed to jclouds, Inc. (jclouds) under one or more
3 * contributor license agreements.  See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership.  jclouds licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License.  You may obtain a copy of the License at
9 *
10 *   http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied.  See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 */
19package org.jclouds.aws.ec2.xml;
20 
21import javax.inject.Inject;
22 
23import org.jclouds.aws.util.AWSUtils;
24import org.jclouds.ec2.domain.ReservedInstancesOffering;
25import org.jclouds.http.functions.ParseSax;
26import org.jclouds.location.Region;
27 
28/**
29 * 
30 * @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/index.html?ApiReference-query-DescribeReservedInstancesOfferingsResponseSetItemType.html"
31 *      />
32 * @author Adrian Cole
33 */
34public class ReservedInstancesOfferingHandler extends
35      ParseSax.HandlerForGeneratedRequestWithResult<ReservedInstancesOffering> {
36   @Inject
37   @Region
38   String defaultRegion;
39 
40   private StringBuilder currentText = new StringBuilder();
41 
42   private String availabilityZone;
43   private long duration = 0;
44   private float fixedPrice = 0;
45   private String instanceType;
46   private String productDescription;
47   private String id;
48   private float usagePrice = 0;
49 
50   public ReservedInstancesOffering getResult() {
51      String region = AWSUtils.findRegionInArgsOrNull(getRequest());
52      if (region == null)
53         region = defaultRegion;
54 
55      ReservedInstancesOffering returnVal = new ReservedInstancesOffering(region, availabilityZone, duration,
56            fixedPrice, instanceType, productDescription, id, usagePrice);
57      this.availabilityZone = null;
58      this.duration = 0;
59      this.fixedPrice = 0;
60      this.instanceType = null;
61      this.productDescription = null;
62      this.id = null;
63      this.usagePrice = 0;
64      return returnVal;
65   }
66 
67   public void endElement(String uri, String name, String qName) {
68 
69      if (qName.equalsIgnoreCase("reservedInstancesOfferingId")) {
70         this.id = currentText.toString().trim();
71      } else if (qName.equalsIgnoreCase("availabilityZone")) {
72         this.availabilityZone = currentText.toString().trim();
73      } else if (qName.equalsIgnoreCase("duration")) {
74         this.duration = Long.parseLong(currentText.toString().trim());
75      } else if (qName.equalsIgnoreCase("fixedPrice")) {
76         this.fixedPrice = Float.parseFloat(currentText.toString().trim());
77      } else if (qName.equalsIgnoreCase("instanceType")) {
78         this.instanceType = currentText.toString().trim();
79      } else if (qName.equalsIgnoreCase("productDescription")) {
80         this.productDescription = currentText.toString().trim();
81      } else if (qName.equalsIgnoreCase("usagePrice")) {
82         this.usagePrice = Float.parseFloat(currentText.toString().trim());
83      }
84      currentText = new StringBuilder();
85   }
86 
87   public void characters(char ch[], int start, int length) {
88      currentText.append(ch, start, length);
89   }
90}

[all classes][org.jclouds.aws.ec2.xml]
EMMA 2.0.5312 (C) Vladimir Roubtsov