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

COVERAGE SUMMARY FOR SOURCE FILE [BundleTaskHandler.java]

nameclass, %method, %block, %line, %
BundleTaskHandler.java100% (1/1)100% (4/4)90%  (205/227)94%  (44/47)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class BundleTaskHandler100% (1/1)100% (4/4)90%  (205/227)94%  (44/47)
endElement (String, String, String): void 100% (1/1)89%  (118/132)92%  (22/24)
getResult (): BundleTask 100% (1/1)89%  (68/76)94%  (17/18)
BundleTaskHandler (): void 100% (1/1)100% (11/11)100% (3/3)
characters (char [], int, int): void 100% (1/1)100% (8/8)100% (2/2)

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.ec2.xml;
20 
21import java.util.Date;
22 
23import javax.inject.Inject;
24 
25import org.jclouds.ec2.domain.BundleTask;
26import org.jclouds.aws.util.AWSUtils;
27import org.jclouds.date.DateService;
28import org.jclouds.http.functions.ParseSax;
29import org.jclouds.location.Region;
30 
31/**
32 * 
33 * @author Adrian Cole
34 */
35public class BundleTaskHandler extends ParseSax.HandlerForGeneratedRequestWithResult<BundleTask> {
36   private StringBuilder currentText = new StringBuilder();
37 
38   @Inject
39   protected DateService dateService;
40   @Inject
41   @Region
42   String defaultRegion;
43 
44   private String bundleId;
45   private String code;
46   private String message;
47   private String instanceId;
48   private int progress = 0;
49   private Date startTime;
50   private String state;
51   private String bucket;
52   private String prefix;
53   private Date updateTime;
54 
55   public BundleTask getResult() {
56      String region = AWSUtils.findRegionInArgsOrNull(getRequest());
57      if (region == null)
58         region = defaultRegion;
59      BundleTask.Error error = null;
60      if (code != null)
61         error = new BundleTask.Error(code, message);
62      BundleTask returnVal = new BundleTask(region, bundleId, error, instanceId, progress, startTime,
63            state, bucket, prefix, updateTime);
64      this.bundleId = null;
65      this.code = null;
66      this.message = null;
67      this.instanceId = null;
68      this.progress = 0;
69      this.startTime = null;
70      this.state = null;
71      this.bucket = null;
72      this.prefix = null;
73      this.updateTime = null;
74      return returnVal;
75   }
76 
77   public void endElement(String uri, String name, String qName) {
78      if (qName.equals("bundleId")) {
79         bundleId = currentText.toString().trim();
80      } else if (qName.equals("code")) {
81         code = currentText.toString().trim();
82      } else if (qName.equals("message")) {
83         message = currentText.toString().trim();
84      } else if (qName.equals("instanceId")) {
85         instanceId = currentText.toString().trim();
86      } else if (qName.equals("progress")) {
87         String temp = currentText.toString().trim();
88         temp = temp.substring(0, temp.length() - 1);
89         progress = Integer.parseInt(temp);
90      } else if (qName.equals("startTime")) {
91         startTime = dateService.iso8601DateParse(currentText.toString().trim());
92      } else if (qName.equals("state")) {
93         state = currentText.toString().trim();
94      } else if (qName.equals("bucket")) {
95         bucket = currentText.toString().trim();
96      } else if (qName.equals("prefix")) {
97         prefix = currentText.toString().trim();
98      } else if (qName.equals("updateTime")) {
99         updateTime = dateService.iso8601DateParse(currentText.toString().trim());
100      }
101      currentText = new StringBuilder();
102   }
103 
104   public void characters(char ch[], int start, int length) {
105      currentText.append(ch, start, length);
106   }
107}

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