EMMA Coverage Report (generated Mon Oct 17 05:41:20 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 * 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.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