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

nameclass, %method, %block, %line, %
VAppTemplateHandler.java100% (1/1)100% (5/5)90%  (61/68)93%  (14/15)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class VAppTemplateHandler100% (1/1)100% (5/5)90%  (61/68)93%  (14/15)
startElement (String, String, String, Attributes): void 100% (1/1)70%  (16/23)83%  (5/6)
VAppTemplateHandler (): 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% (15/15)100% (4/4)
getResult (): VAppTemplate 100% (1/1)100% (14/14)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.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 org.jclouds.http.functions.ParseSax;
28import org.jclouds.trmk.vcloud_0_8.domain.ReferenceType;
29import org.jclouds.trmk.vcloud_0_8.domain.Status;
30import org.jclouds.trmk.vcloud_0_8.domain.VAppTemplate;
31import org.jclouds.trmk.vcloud_0_8.domain.internal.VAppTemplateImpl;
32import org.xml.sax.Attributes;
33import org.xml.sax.SAXException;
34 
35/**
36 * @author Adrian Cole
37 */
38public class VAppTemplateHandler extends ParseSax.HandlerWithResult<VAppTemplate> {
39   private StringBuilder currentText = new StringBuilder();
40 
41   private ReferenceType catalog;
42   private String description;
43   private Status status;
44 
45   public VAppTemplate getResult() {
46      return new VAppTemplateImpl(catalog.getName(), catalog.getHref(), description, status);
47   }
48 
49   @Override
50   public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException {
51      Map<String, String> attributes = cleanseAttributes(attrs);
52      if (qName.equals("VAppTemplate")) {
53         catalog = newReferenceType(attributes);
54         if (attributes.containsKey("status"))
55            status = Status.fromValue(attributes.get("status"));
56      }
57   }
58 
59   public void endElement(String uri, String name, String qName) {
60      if (qName.equals("Description")) {
61         description = currentOrNull(currentText);
62      }
63      currentText = new StringBuilder();
64   }
65 
66   public void characters(char ch[], int start, int length) {
67      currentText.append(ch, start, length);
68   }
69}

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