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

COVERAGE SUMMARY FOR SOURCE FILE [RealmHandler.java]

nameclass, %method, %block, %line, %
RealmHandler.java100% (1/1)100% (5/5)100% (122/122)100% (27/27)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class RealmHandler100% (1/1)100% (5/5)100% (122/122)100% (27/27)
RealmHandler (): 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% (82/82)100% (17/17)
getResult (): Realm 100% (1/1)100% (3/3)100% (1/1)
startElement (String, String, String, Attributes): void 100% (1/1)100% (21/21)100% (5/5)

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.Realm;
25import org.jclouds.deltacloud.domain.Realm.State;
26import org.jclouds.http.functions.ParseSax;
27import org.jclouds.util.SaxUtils;
28import org.xml.sax.Attributes;
29import org.xml.sax.SAXException;
30 
31/**
32 * @author Adrian Cole
33 */
34public class RealmHandler extends ParseSax.HandlerWithResult<Realm> {
35   private StringBuilder currentText = new StringBuilder();
36 
37   private URI href;
38   private String id;
39   private String name;
40   private String limit;
41   private State state;
42 
43   private Realm realm;
44 
45   public Realm getResult() {
46      return realm;
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 (attributes.containsKey("href")) {
53         this.href = URI.create(attributes.get("href"));
54         this.id = attributes.get("id");
55      }
56   }
57 
58   @Override
59   public void endElement(String uri, String localName, String qName) throws SAXException {
60      if (qName.equalsIgnoreCase("limit")) {
61         this.limit = currentText.toString().trim();
62         if ("".equals(limit))
63            limit = null;
64      } else if (qName.equalsIgnoreCase("name")) {
65         this.name = currentText.toString().trim();
66      } else if (qName.equalsIgnoreCase("state")) {
67         this.state = State.fromValue(currentText.toString().trim());
68      } else if (qName.equalsIgnoreCase("realm")) {
69         this.realm = new Realm(href, id, name, limit, state);
70         this.href = null;
71         this.id = null;
72         this.name = null;
73         this.limit = null;
74         this.state = null;
75      }
76      currentText = new StringBuilder();
77   }
78 
79   public void characters(char ch[], int start, int length) {
80      currentText.append(ch, start, length);
81   }
82}

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