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 [NetworkHandler.java]

nameclass, %method, %block, %line, %
NetworkHandler.java100% (1/1)100% (5/5)95%  (122/128)96%  (24/25)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class NetworkHandler100% (1/1)100% (5/5)95%  (122/128)96%  (24/25)
endElement (String, String, String): void 100% (1/1)87%  (40/46)90%  (9/10)
NetworkHandler (): void 100% (1/1)100% (11/11)100% (3/3)
characters (char [], int, int): void 100% (1/1)100% (8/8)100% (2/2)
getResult (): Network 100% (1/1)100% (25/25)100% (1/1)
startElement (String, String, String, Attributes): void 100% (1/1)100% (38/38)100% (9/9)

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.trmk.vcloud_0_8.util.Utils.newReferenceType;
22import static org.jclouds.util.SaxUtils.cleanseAttributes;
23import static org.jclouds.util.SaxUtils.currentOrNull;
24 
25import java.util.Map;
26 
27import javax.annotation.Resource;
28 
29import org.jclouds.http.functions.ParseSax;
30import org.jclouds.logging.Logger;
31import org.jclouds.trmk.vcloud_0_8.domain.FenceMode;
32import org.jclouds.trmk.vcloud_0_8.domain.Network;
33import org.jclouds.trmk.vcloud_0_8.domain.ReferenceType;
34import org.jclouds.trmk.vcloud_0_8.domain.internal.NetworkImpl;
35import org.xml.sax.Attributes;
36import org.xml.sax.SAXException;
37 
38/**
39 * @author Adrian Cole
40 */
41public class NetworkHandler extends ParseSax.HandlerWithResult<Network> {
42 
43   @Resource
44   protected Logger logger = Logger.NULL;
45 
46   protected StringBuilder currentText = new StringBuilder();
47 
48   protected ReferenceType network;
49 
50   protected String description;
51 
52   protected String gateway;
53   protected String netmask;
54   protected FenceMode fenceMode;
55 
56   private ReferenceType ips;
57   private ReferenceType extension;
58 
59   public Network getResult() {
60      return new NetworkImpl(network.getName(), network.getType(), network.getHref(), description, gateway, netmask,
61            fenceMode, extension, ips);
62   }
63 
64   @Override
65   public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException {
66      Map<String, String> attributes = cleanseAttributes(attrs);
67      if (qName.equals("Network")) {
68         network = newReferenceType(attributes);
69      } else if (qName.equals("Link")) {
70         if ("IP Addresses".equals(attributes.get("name"))) {
71            ips = newReferenceType(attributes);
72         } else if ("down".equals(attributes.get("rel"))) {
73            extension = newReferenceType(attributes);
74         }
75      }
76   }
77 
78   public void endElement(String uri, String name, String qName) {
79      if (qName.equals("Description")) {
80         description = currentOrNull(currentText);
81      } else if (qName.equals("Gateway")) {
82         gateway = currentOrNull(currentText);
83      } else if (qName.equals("Netmask")) {
84         netmask = currentOrNull(currentText);
85      } else if (qName.equals("FenceMode")) {
86         fenceMode = (FenceMode.fromValue(currentOrNull(currentText)));
87      }
88      currentText = new StringBuilder();
89   }
90 
91   public void characters(char ch[], int start, int length) {
92      currentText.append(ch, start, length);
93   }
94 
95}

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