EMMA Coverage Report (generated Wed Aug 10 12:30:04 EDT 2011)
[all classes][org.jclouds.deltacloud.xml]

COVERAGE SUMMARY FOR SOURCE FILE [ImageHandler.java]

nameclass, %method, %block, %line, %
ImageHandler.java100% (1/1)100% (5/5)100% (133/133)100% (30/30)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class ImageHandler100% (1/1)100% (5/5)100% (133/133)100% (30/30)
ImageHandler (): 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% (89/89)100% (18/18)
getResult (): Image 100% (1/1)100% (3/3)100% (1/1)
startElement (String, String, String, Attributes): void 100% (1/1)100% (25/25)100% (7/7)

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.deltacloud.xml;
20 
21import java.net.URI;
22import java.util.Map;
23 
24import org.jclouds.deltacloud.domain.Image;
25import org.jclouds.http.functions.ParseSax;
26import org.jclouds.util.SaxUtils;
27import org.xml.sax.Attributes;
28import org.xml.sax.SAXException;
29 
30/**
31 * @author Adrian Cole
32 */
33public class ImageHandler extends ParseSax.HandlerWithResult<Image> {
34   private StringBuilder currentText = new StringBuilder();
35 
36   private URI href;
37   private String id;
38   private String ownerId;
39   private String name;
40   private String description;
41   private String architecture;
42 
43   private Image image;
44 
45   public Image getResult() {
46      return image;
47   }
48 
49   @Override
50   public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException {
51      Map<String, String> attributes = SaxUtils.cleanseAttributes(attrs);
52      if (qName.equals("image")) {
53         String href = attributes.get("href");
54         if (href != null) {
55            this.href = URI.create(href);
56         }
57         this.id = attributes.get("id");
58      }
59   }
60 
61   @Override
62   public void endElement(String uri, String localName, String qName) throws SAXException {
63      if (qName.equalsIgnoreCase("owner_id")) {
64         this.ownerId = currentText.toString().trim();
65      } else if (qName.equalsIgnoreCase("name")) {
66         this.name = currentText.toString().trim();
67      } else if (qName.equalsIgnoreCase("description")) {
68         this.description = currentText.toString().trim();
69      } else if (qName.equalsIgnoreCase("architecture")) {
70         this.architecture = currentText.toString().trim();
71      } else if (qName.equalsIgnoreCase("image")) {
72         this.image = new Image(href, id, ownerId, name, description, architecture);
73         this.href = null;
74         this.id = null;
75         this.ownerId = null;
76         this.name = null;
77         this.description = null;
78         this.architecture = null;
79      }
80      currentText = new StringBuilder();
81   }
82 
83   public void characters(char ch[], int start, int length) {
84      currentText.append(ch, start, length);
85   }
86}

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