EMMA Coverage Report (generated Thu Jan 20 11:39:44 EST 2011)
[all classes][com.hammurapi.common]

COVERAGE SUMMARY FOR SOURCE FILE [FacadeContext.java]

nameclass, %method, %block, %line, %
FacadeContext.java0%   (0/1)0%   (0/4)0%   (0/65)0%   (0/18)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class FacadeContext0%   (0/1)0%   (0/4)0%   (0/65)0%   (0/18)
FacadeContext (Map, Map): void 0%   (0/1)0%   (0/9)0%   (0/4)
lookup (Class): Object 0%   (0/1)0%   (0/26)0%   (0/7)
lookup (String): Object 0%   (0/1)0%   (0/10)0%   (0/1)
lookupAll (Class): Iterator 0%   (0/1)0%   (0/20)0%   (0/6)

1package com.hammurapi.common;
2 
3import java.util.Collections;
4import java.util.Iterator;
5import java.util.Map;
6 
7/**
8 * Simple context implementation.
9 * @author Pavel Vlasov
10 *
11 */
12public class FacadeContext implements Context {
13        
14        private Map<String, ?> bindings;
15        private Map<Class<?>, Iterable<?>> services;
16        
17        /**
18         * @param classLoader ClassLoader for services. Can be null.
19         * @param bindings Name bindings. Can be null.
20         */
21        public FacadeContext(Map<Class<?>, Iterable<?>> services, Map<String, ?> bindings) {
22                this.services = services;
23                this.bindings = bindings;
24        }
25                
26        public Object lookup(String name) {
27                return bindings==null ? null : bindings.get(name);
28        }
29 
30        @SuppressWarnings("unchecked")
31        public <T> T lookup(Class<T> serviceClass) {
32                if (services==null) { 
33                        return null;
34                }
35                
36                Iterable<?> sl = services.get(serviceClass);
37                if (sl==null) {
38                        return null;
39                }
40                                
41                Iterator<?> it = sl.iterator();
42                return it.hasNext() ? (T) it.next() : null;
43        }
44 
45        @SuppressWarnings("unchecked")
46        public <T> Iterator<T> lookupAll(Class<T> serviceClass) {
47                if (services==null) {
48                        return (Iterator<T>) Collections.emptyList().iterator();
49                }
50                
51                Iterable<?> sl = services.get(serviceClass);
52                if (sl==null) {
53                        return (Iterator<T>) Collections.emptyList().iterator();
54                }
55                
56                return (Iterator<T>) sl.iterator();
57        }
58 
59}

[all classes][com.hammurapi.common]
EMMA 2.0.5312 EclEmma Fix 2 (C) Vladimir Roubtsov