EMMA Coverage Report (generated Fri Aug 26 14:14:05 EDT 2011)
[all classes][org.jclouds.vcloud.xml.ovf]

COVERAGE SUMMARY FOR SOURCE FILE [VCloudOperatingSystemHandler.java]

nameclass, %method, %block, %line, %
VCloudOperatingSystemHandler.java100% (1/1)100% (5/5)100% (122/122)100% (27/27)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class VCloudOperatingSystemHandler100% (1/1)100% (5/5)100% (122/122)100% (27/27)
VCloudOperatingSystemHandler (): void 100% (1/1)100% (8/8)100% (2/2)
characters (char [], int, int): void 100% (1/1)100% (8/8)100% (2/2)
endElement (String, String, String): void 100% (1/1)100% (27/27)100% (6/6)
getResult (): VCloudOperatingSystemSection 100% (1/1)100% (40/40)100% (8/8)
startElement (String, String, String, Attributes): void 100% (1/1)100% (39/39)100% (9/9)

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.vcloud.xml.ovf;
20 
21import static org.jclouds.vcloud.util.Utils.newReferenceType;
22 
23import java.util.Map;
24 
25import org.jclouds.http.functions.ParseSax;
26import org.jclouds.util.SaxUtils;
27import org.jclouds.vcloud.domain.ReferenceType;
28import org.jclouds.vcloud.domain.ovf.VCloudOperatingSystemSection;
29import org.jclouds.vcloud.util.Utils;
30import org.xml.sax.Attributes;
31 
32/**
33 * @author Adrian Cole
34 */
35public class VCloudOperatingSystemHandler extends ParseSax.HandlerWithResult<VCloudOperatingSystemSection> {
36   private StringBuilder currentText = new StringBuilder();
37 
38   protected ReferenceType os;
39   protected Integer id;
40   protected String info;
41   protected String vmwOsType;
42   protected String description;
43   protected ReferenceType edit;
44 
45   public VCloudOperatingSystemSection getResult() {
46      VCloudOperatingSystemSection system = new VCloudOperatingSystemSection(id, info, description, os.getType(), os.getHref(),
47               vmwOsType, edit);
48      os = null;
49      id = null;
50      info = null;
51      vmwOsType = null;
52      description = null;
53      edit = null;
54      return system;
55   }
56 
57   @Override
58   public void startElement(String uri, String localName, String qName, Attributes attrs) {
59      Map<String, String> attributes = SaxUtils.cleanseAttributes(attrs);
60      if (qName.endsWith("Link")) {
61         this.edit = Utils.newReferenceType(attributes);
62      } else if (qName.endsWith("OperatingSystemSection")) {
63         os = newReferenceType(attributes);
64         vmwOsType = attributes.get("osType");
65         if (attributes.containsKey("id"))
66            this.id = Integer.parseInt(attributes.get("id"));
67      }
68   }
69 
70   @Override
71   public void endElement(String uri, String localName, String qName) {
72      if (qName.endsWith("Info")) {
73         this.info = currentText.toString().trim();
74      } else if (qName.endsWith("Description")) {
75         this.description = currentText.toString().trim();
76      }
77      currentText = new StringBuilder();
78   }
79 
80   public void characters(char ch[], int start, int length) {
81      currentText.append(ch, start, length);
82   }
83}

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