EMMA Coverage Report (generated Mon Oct 17 05:41:20 EDT 2011)
[all classes][org.jclouds.savvis.vpdc.xml]

COVERAGE SUMMARY FOR SOURCE FILE [FirewallRuleHandler.java]

nameclass, %method, %block, %line, %
FirewallRuleHandler.java100% (1/1)100% (5/5)86%  (150/174)94%  (31.8/34)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class FirewallRuleHandler100% (1/1)100% (5/5)86%  (150/174)94%  (31.8/34)
getResult (): FirewallRule 100% (1/1)60%  (9/15)80%  (1.6/2)
endElement (String, String, String): void 100% (1/1)87%  (121/139)93%  (24.2/26)
FirewallRuleHandler (): void 100% (1/1)100% (11/11)100% (3/3)
characters (char [], int, int): void 100% (1/1)100% (8/8)100% (2/2)
startElement (String, String, String, Attributes): void 100% (1/1)100% (1/1)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.savvis.vpdc.xml;
20 
21import static org.jclouds.util.SaxUtils.currentOrNull;
22import static org.jclouds.util.SaxUtils.equalsOrSuffix;
23 
24import org.jclouds.http.functions.ParseSax;
25import org.jclouds.savvis.vpdc.domain.FirewallRule;
26import org.xml.sax.Attributes;
27import org.xml.sax.SAXException;
28 
29/**
30 * @author Kedar Dave
31 */
32public class FirewallRuleHandler extends ParseSax.HandlerWithResult<FirewallRule> {
33   protected StringBuilder currentText = new StringBuilder();
34   private FirewallRule.Builder builder = FirewallRule.builder();
35 
36   public FirewallRule getResult() {
37      try {
38         return builder.build();
39      } finally {
40         builder = FirewallRule.builder();
41      }
42   }
43 
44   public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException {
45 
46   }
47 
48   @Override
49   public void endElement(String uri, String localName, String qName) throws SAXException {
50      String current = currentOrNull(currentText);
51      if (current != null) {
52         if (equalsOrSuffix(qName, "Type")) {
53            builder.firewallType(current);
54         } else if (equalsOrSuffix(qName, "IsEnabled")) {
55            builder.isEnabled(Boolean.parseBoolean(current));
56         } else if (equalsOrSuffix(qName, "Source")) {
57            builder.source(current);
58         } else if (equalsOrSuffix(qName, "Destination")) {
59            builder.destination(current);
60         } else if (equalsOrSuffix(qName, "Port")) {
61            builder.port(current);
62         } else if (equalsOrSuffix(qName, "Policy")) {
63            builder.policy(current);
64         } else if (equalsOrSuffix(qName, "Description")) {
65            builder.description(current);
66         } else if (equalsOrSuffix(qName, "Log")) {
67            builder.isLogged(Boolean.parseBoolean(current));
68         } else if (equalsOrSuffix(qName, "Tcp")) {
69            builder.protocol("Tcp");
70         } else if (qName.contains("Udp") || qName.contains("udp")) {
71            builder.protocol("Udp");
72         } else if (qName.contains("Icmp") || qName.contains("icmp") || qName.contains("Ping")
73               || qName.contains("ping")) {
74            builder.protocol("Icmp-ping");
75         }
76      }
77      currentText = new StringBuilder();
78   }
79 
80   @Override
81   public void characters(char ch[], int start, int length) {
82      currentText.append(ch, start, length);
83   }
84 
85}

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