EMMA Coverage Report (generated Mon Oct 17 05:41:20 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 * 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.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