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

COVERAGE SUMMARY FOR SOURCE FILE [InternetServicesHandler.java]

nameclass, %method, %block, %line, %
InternetServicesHandler.java100% (1/1)100% (5/5)94%  (92/98)98%  (23.6/24)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class InternetServicesHandler100% (1/1)100% (5/5)94%  (92/98)98%  (23.6/24)
getResult (): Set 100% (1/1)60%  (9/15)80%  (1.6/2)
InternetServicesHandler (InternetServiceHandler): void 100% (1/1)100% (9/9)100% (4/4)
characters (char [], int, int): void 100% (1/1)100% (10/10)100% (3/3)
endElement (String, String, String): void 100% (1/1)100% (35/35)100% (8/8)
startElement (String, String, String, Attributes): void 100% (1/1)100% (29/29)100% (7/7)

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.trmk.vcloud_0_8.xml;
20 
21import static org.jclouds.util.SaxUtils.equalsOrSuffix;
22 
23import java.util.Set;
24 
25import javax.inject.Inject;
26 
27import org.jclouds.http.functions.ParseSax.HandlerWithResult;
28import org.jclouds.trmk.vcloud_0_8.domain.InternetService;
29import org.xml.sax.Attributes;
30 
31import com.google.common.collect.ImmutableSet;
32import com.google.common.collect.ImmutableSet.Builder;
33 
34/**
35 * @author Adrian Cole
36 */
37public class InternetServicesHandler extends HandlerWithResult<Set<InternetService>> {
38 
39   private final InternetServiceHandler handler;
40   private Builder<InternetService> builder = ImmutableSet.<InternetService> builder();
41 
42   @Inject
43   public InternetServicesHandler(InternetServiceHandler handler) {
44      this.handler = handler;
45   }
46 
47   @Override
48   public Set<InternetService> getResult() {
49      try {
50         return builder.build();
51      } finally {
52         builder = ImmutableSet.<InternetService> builder();
53      }
54   }
55 
56   int depth;
57   private boolean inInternetService;
58 
59   @Override
60   public void startElement(String uri, String localName, String qName, Attributes attrs) {
61      depth++;
62      if (depth == 2) {
63         if (equalsOrSuffix(qName, "InternetService")) {
64            inInternetService = true;
65         }
66      } else if (inInternetService) {
67         handler.startElement(uri, localName, qName, attrs);
68      }
69   }
70 
71   public void endElement(String uri, String name, String qName) {
72      depth--;
73      if (depth == 1) {
74         if (equalsOrSuffix(qName, "InternetService")) {
75            inInternetService = false;
76            builder.add(handler.getResult());
77         }
78      } else if (inInternetService) {
79         handler.endElement(uri, name, qName);
80      }
81   }
82 
83   public void characters(char ch[], int start, int length) {
84      if (inInternetService) {
85         handler.characters(ch, start, length);
86      }
87   }
88 
89}

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