EMMA Coverage Report (generated Wed Aug 10 12:30:04 EDT 2011)
[all classes][org.jclouds.ec2.xml]

COVERAGE SUMMARY FOR SOURCE FILE [DescribeAddressesResponseHandler.java]

nameclass, %method, %block, %line, %
DescribeAddressesResponseHandler.java100% (1/1)100% (5/5)98%  (91/93)99%  (21.8/22)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class DescribeAddressesResponseHandler100% (1/1)100% (5/5)98%  (91/93)99%  (21.8/22)
currentOrNull (): String 100% (1/1)85%  (11/13)92%  (1.8/2)
DescribeAddressesResponseHandler (): void 100% (1/1)100% (14/14)100% (4/4)
characters (char [], int, int): void 100% (1/1)100% (8/8)100% (2/2)
endElement (String, String, String): void 100% (1/1)100% (55/55)100% (13/13)
getResult (): Set 100% (1/1)100% (3/3)100% (1/1)

1/**
2 *
3 * Copyright (C) 2011 Cloud Conscious, LLC. <info@cloudconscious.com>
4 *
5 * ====================================================================
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * 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, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 * ====================================================================
18 */
19package org.jclouds.ec2.xml;
20 
21import java.util.Set;
22 
23import javax.annotation.Resource;
24import javax.inject.Inject;
25 
26import org.jclouds.aws.util.AWSUtils;
27import org.jclouds.ec2.domain.PublicIpInstanceIdPair;
28import org.jclouds.http.functions.ParseSax.HandlerForGeneratedRequestWithResult;
29import org.jclouds.location.Region;
30import org.jclouds.logging.Logger;
31 
32import com.google.common.collect.Sets;
33 
34/**
35 * 
36 * @author Adrian Cole
37 */
38public class DescribeAddressesResponseHandler extends
39         HandlerForGeneratedRequestWithResult<Set<PublicIpInstanceIdPair>> {
40 
41   @Resource
42   protected Logger logger = Logger.NULL;
43   private Set<PublicIpInstanceIdPair> pairs = Sets.newLinkedHashSet();
44   private String ipAddress;
45   private StringBuilder currentText = new StringBuilder();
46   @Inject
47   @Region
48   String defaultRegion;
49   private String instanceId;
50 
51   protected String currentOrNull() {
52      String returnVal = currentText.toString().trim();
53      return returnVal.equals("") ? null : returnVal;
54   }
55 
56   public void endElement(String uri, String name, String qName) {
57      if (qName.equals("publicIp")) {
58         ipAddress = currentOrNull();
59      } else if (qName.equals("instanceId")) {
60         instanceId = currentOrNull();
61      } else if (qName.equals("item")) {
62         String region = AWSUtils.findRegionInArgsOrNull(getRequest());
63         if (region == null)
64            region = defaultRegion;
65         pairs.add(new PublicIpInstanceIdPair(region, ipAddress, instanceId));
66         ipAddress = null;
67         instanceId = null;
68      }
69      currentText = new StringBuilder();
70   }
71 
72   public void characters(char ch[], int start, int length) {
73      currentText.append(ch, start, length);
74   }
75 
76   @Override
77   public Set<PublicIpInstanceIdPair> getResult() {
78      return pairs;
79   }
80 
81}

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