EMMA Coverage Report (generated Wed Jun 22 19:47:49 EDT 2011)
[all classes][org.jclouds.deltacloud.xml]

COVERAGE SUMMARY FOR SOURCE FILE [DeltacloudCollectionHandler.java]

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

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class DeltacloudCollectionHandler100% (1/1)100% (4/4)100% (71/71)100% (16/16)
DeltacloudCollectionHandler (): void 100% (1/1)100% (6/6)100% (2/2)
endElement (String, String, String): void 100% (1/1)100% (25/25)100% (6/6)
getResult (): DeltacloudCollection 100% (1/1)100% (3/3)100% (1/1)
startElement (String, String, String, Attributes): void 100% (1/1)100% (37/37)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;
23import java.util.Set;
24 
25import org.jclouds.deltacloud.domain.DeltacloudCollection;
26import org.jclouds.deltacloud.domain.Feature;
27import org.jclouds.http.functions.ParseSax;
28import org.jclouds.util.SaxUtils;
29import org.xml.sax.Attributes;
30import org.xml.sax.SAXException;
31 
32import com.google.common.collect.Sets;
33 
34/**
35 * @author Adrian Cole
36 */
37public class DeltacloudCollectionHandler extends ParseSax.HandlerWithResult<DeltacloudCollection> {
38   private URI href;
39   private String rel;
40   private Set<Feature> features = Sets.newLinkedHashSet();
41 
42   private DeltacloudCollection realm;
43 
44   public DeltacloudCollection getResult() {
45      return realm;
46   }
47 
48   @Override
49   public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException {
50      Map<String, String> attributes = SaxUtils.cleanseAttributes(attrs);
51      if (qName.equalsIgnoreCase("link")) {
52         this.href = URI.create(attributes.get("href"));
53         this.rel = attributes.get("rel");
54      } else if (qName.equalsIgnoreCase("feature")) {
55         features.add(new Feature(attributes.get("name")));
56      }
57   }
58 
59   @Override
60   public void endElement(String uri, String localName, String qName) throws SAXException {
61      if (qName.equalsIgnoreCase("link")) {
62         this.realm = new DeltacloudCollection(href, rel, features);
63         this.href = null;
64         this.rel = null;
65         this.features = Sets.newLinkedHashSet();
66      }
67   }
68 
69}

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