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

COVERAGE SUMMARY FOR SOURCE FILE [TasksListHandler.java]

nameclass, %method, %block, %line, %
TasksListHandler.java100% (1/1)100% (4/4)100% (71/71)100% (16/16)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class TasksListHandler100% (1/1)100% (4/4)100% (71/71)100% (16/16)
TasksListHandler (TaskHandler): void 100% (1/1)100% (9/9)100% (4/4)
endElement (String, String, String): void 100% (1/1)100% (18/18)100% (4/4)
getResult (): TasksList 100% (1/1)100% (9/9)100% (1/1)
startElement (String, String, String, Attributes): void 100% (1/1)100% (35/35)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 java.util.Map;
22import java.util.SortedSet;
23 
24import javax.inject.Inject;
25 
26import org.jclouds.http.functions.ParseSax;
27import org.jclouds.util.SaxUtils;
28import org.jclouds.vcloud.domain.ReferenceType;
29import org.jclouds.vcloud.domain.Task;
30import org.jclouds.vcloud.domain.TasksList;
31import org.jclouds.vcloud.domain.internal.TasksListImpl;
32import org.jclouds.vcloud.util.Utils;
33import org.xml.sax.Attributes;
34import org.xml.sax.SAXException;
35 
36import com.google.common.collect.Sets;
37 
38/**
39 * @author Adrian Cole
40 */
41public class TasksListHandler extends ParseSax.HandlerWithResult<TasksList> {
42 
43   private SortedSet<Task> tasks = Sets.newTreeSet();
44   private final TaskHandler taskHandler;
45   private ReferenceType resource;
46 
47   @Inject
48   public TasksListHandler(TaskHandler taskHandler) {
49      this.taskHandler = taskHandler;
50   }
51 
52   public TasksList getResult() {
53      return new TasksListImpl(resource.getHref(), tasks);
54   }
55 
56   @Override
57   public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException {
58      Map<String, String> attributes = SaxUtils.cleanseAttributes(attrs);
59      if (qName.equals("TasksList")) {
60         resource = Utils.newReferenceType(attributes);
61      } else if (qName.equals("Link") && "self".equals(attributes.get("rel"))) {
62         resource = Utils.newReferenceType(attributes);
63      } else {
64         taskHandler.startElement(uri, localName, qName, attrs);
65      }
66   }
67 
68   @Override
69   public void endElement(String uri, String localName, String qName) throws SAXException {
70      taskHandler.endElement(uri, localName, qName);
71      if (qName.equals("Task")) {
72         this.tasks.add(taskHandler.getResult());
73      }
74   }
75 
76}

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