EMMA Coverage Report (generated Fri Apr 27 15:03:37 EDT 2012)
[all classes][org.jclouds.ec2.xml]

COVERAGE SUMMARY FOR SOURCE FILE [BlockDeviceMappingHandler.java]

nameclass, %method, %block, %line, %
BlockDeviceMappingHandler.java100% (1/1)100% (4/4)100% (130/130)100% (28/28)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class BlockDeviceMappingHandler100% (1/1)100% (4/4)100% (130/130)100% (28/28)
BlockDeviceMappingHandler (DateService): void 100% (1/1)100% (17/17)100% (6/6)
characters (char [], int, int): void 100% (1/1)100% (8/8)100% (2/2)
endElement (String, String, String): void 100% (1/1)100% (102/102)100% (19/19)
getResult (): Map 100% (1/1)100% (3/3)100% (1/1)

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;
22import java.util.Map;
23 
24import org.jclouds.date.DateService;
25import org.jclouds.ec2.domain.Attachment;
26import org.jclouds.ec2.domain.BlockDevice;
27import org.jclouds.http.functions.ParseSax;
28 
29import com.google.common.collect.Maps;
30import com.google.inject.Inject;
31 
32/**
33 *
34 * @author Adrian Cole
35 */
36public class BlockDeviceMappingHandler extends
37         ParseSax.HandlerWithResult<Map<String, BlockDevice>> {
38   private StringBuilder currentText = new StringBuilder();
39 
40   private Map<String, BlockDevice> ebsBlockDevices = Maps.newHashMap();
41   private String deviceName;
42   private String volumeId;
43   private boolean deleteOnTermination = true;// correct default is true.
44   private Attachment.Status attachmentStatus;
45   private Date attachTime;
46 
47   protected final DateService dateService;
48 
49   @Inject 
50   public BlockDeviceMappingHandler(DateService dateService) {
51      this.dateService = dateService;
52   }
53 
54   public Map<String, BlockDevice> getResult() {
55      return ebsBlockDevices;
56   }
57 
58   public void endElement(String uri, String name, String qName) {
59      if (qName.equals("deviceName")) {
60         deviceName = currentText.toString().trim();
61      } else if (qName.equals("volumeId")) {
62         volumeId = currentText.toString().trim();
63      } else if (qName.equals("deleteOnTermination")) {
64         deleteOnTermination = Boolean.parseBoolean(currentText.toString().trim());
65      } else if (qName.equals("status")) {
66         attachmentStatus = Attachment.Status.fromValue(currentText.toString().trim());
67      } else if (qName.equals("attachTime")) {
68         attachTime = dateService.iso8601DateParse(currentText.toString().trim());
69      } else if (qName.equals("item")) {
70         ebsBlockDevices.put(deviceName, new BlockDevice(volumeId, attachmentStatus, attachTime, deleteOnTermination));
71          this.volumeId = null;
72          this.deviceName = null;
73          this.deleteOnTermination = true;
74          this.attachmentStatus = null;
75          this.attachTime = null;
76      }
77      currentText = new StringBuilder();
78   }
79 
80   public void characters(char ch[], int start, int length) {
81      currentText.append(ch, start, length);
82   }
83}

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