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

COVERAGE SUMMARY FOR SOURCE FILE [GuestCustomizationSectionHandler.java]

nameclass, %method, %block, %line, %
GuestCustomizationSectionHandler.java100% (1/1)100% (6/6)94%  (309/328)94%  (64/68)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class GuestCustomizationSectionHandler100% (1/1)100% (6/6)94%  (309/328)94%  (64/68)
endElement (String, String, String): void 100% (1/1)89%  (154/173)89%  (32/36)
GuestCustomizationSectionHandler (): void 100% (1/1)100% (8/8)100% (2/2)
characters (char [], int, int): void 100% (1/1)100% (8/8)100% (2/2)
currentOrNull (): String 100% (1/1)100% (12/12)100% (2/2)
getResult (): GuestCustomizationSection 100% (1/1)100% (95/95)100% (19/19)
startElement (String, String, String, Attributes): void 100% (1/1)100% (32/32)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.vcloud.xml;
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.GuestCustomizationSection;
28import org.jclouds.vcloud.domain.ReferenceType;
29import org.xml.sax.Attributes;
30 
31/**
32 * @author Adrian Cole
33 */
34public class GuestCustomizationSectionHandler extends ParseSax.HandlerWithResult<GuestCustomizationSection> {
35   protected StringBuilder currentText = new StringBuilder();
36   private ReferenceType guest;
37   private ReferenceType edit;
38 
39   protected String info;
40   protected String name;
41   protected Boolean enabled;
42   protected Boolean changeSid;
43   protected String virtualMachineId;
44   protected Boolean joinDomainEnabled;
45   protected Boolean useOrgSettings;
46   protected String domainName;
47   protected String domainUserName;
48   protected String domainUserPassword;
49   protected Boolean adminPasswordEnabled;
50   protected Boolean adminPasswordAuto;
51   protected String adminPassword;
52   protected Boolean resetPasswordRequired;
53   protected String customizationScript;
54   protected String computerName;
55 
56   public GuestCustomizationSection getResult() {
57      GuestCustomizationSection system = new GuestCustomizationSection(guest.getType(), guest.getHref(), info, enabled,
58            changeSid, virtualMachineId, joinDomainEnabled, useOrgSettings, domainName, domainUserName,
59            domainUserPassword, adminPasswordEnabled, adminPasswordAuto, adminPassword, resetPasswordRequired,
60            customizationScript, computerName, edit);
61      this.guest = null;
62      this.info = null;
63      this.edit = null;
64      this.enabled = null;
65      this.changeSid = null;
66      this.virtualMachineId = null;
67      this.joinDomainEnabled = null;
68      this.useOrgSettings = null;
69      this.domainName = null;
70      this.domainUserName = null;
71      this.domainUserPassword = null;
72      this.adminPasswordEnabled = null;
73      this.adminPasswordAuto = null;
74      this.adminPassword = null;
75      this.resetPasswordRequired = null;
76      this.customizationScript = null;
77      this.computerName = null;
78      return system;
79   }
80 
81   public void startElement(String uri, String localName, String qName, Attributes attrs) {
82      Map<String, String> attributes = SaxUtils.cleanseAttributes(attrs);
83      this.currentText = new StringBuilder();
84      if (qName.endsWith("GuestCustomizationSection")) {
85         guest = newReferenceType(attributes);
86      } else if (qName.endsWith("Link") && "edit".equals(attributes.get("rel"))) {
87         edit = newReferenceType(attributes);
88      }
89   }
90 
91   @Override
92   public void endElement(String uri, String localName, String qName) {
93      if (qName.endsWith("Info")) {
94         this.info = currentOrNull();
95      } else if (qName.endsWith("AdminPasswordEnabled")) {
96         this.adminPasswordEnabled = Boolean.parseBoolean(currentOrNull());
97      } else if (qName.endsWith("JoinDomainEnabled")) {
98         this.joinDomainEnabled = Boolean.parseBoolean(currentOrNull());
99      } else if (qName.endsWith("Enabled")) {
100         this.enabled = Boolean.parseBoolean(currentOrNull());
101      } else if (qName.endsWith("ChangeSid")) {
102         this.changeSid = Boolean.parseBoolean(currentOrNull());
103      } else if (qName.endsWith("VirtualMachineId")) {
104         this.virtualMachineId = currentOrNull();
105      } else if (qName.endsWith("UseOrgSettings")) {
106         this.useOrgSettings = Boolean.parseBoolean(currentOrNull());
107      } else if (qName.endsWith("DomainName")) {
108         this.domainName = currentOrNull();
109      } else if (qName.endsWith("DomainUserName")) {
110         this.domainUserName = currentOrNull();
111      } else if (qName.endsWith("DomainUserPassword")) {
112         this.domainUserPassword = currentOrNull();
113      } else if (qName.endsWith("AdminPasswordAuto")) {
114         this.adminPasswordAuto = Boolean.parseBoolean(currentOrNull());
115      } else if (qName.endsWith("AdminPassword")) {
116         this.adminPassword = currentOrNull();
117      } else if (qName.endsWith("ResetPasswordRequired")) {
118         this.resetPasswordRequired = Boolean.parseBoolean(currentOrNull());
119      } else if (qName.endsWith("CustomizationScript")) {
120         this.customizationScript = currentOrNull();
121         if (this.customizationScript != null)
122            customizationScript = customizationScript.replace("&gt;", ">");
123      } else if (qName.endsWith("ComputerName")) {
124         this.computerName = currentOrNull();
125      } else if (qName.endsWith("Name")) {
126         this.name = currentOrNull();
127      }
128      currentText = new StringBuilder();
129   }
130 
131   public void characters(char ch[], int start, int length) {
132      currentText.append(ch, start, length);
133   }
134 
135   protected String currentOrNull() {
136      String returnVal = currentText.toString();
137      return returnVal.equals("") ? null : returnVal;
138   }
139}

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