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

COVERAGE SUMMARY FOR SOURCE FILE [Util.java]

nameclass, %method, %block, %line, %
Util.java100% (1/1)67%  (2/3)80%  (47/59)75%  (9/12)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class Util100% (1/1)67%  (2/3)80%  (47/59)75%  (9/12)
Util (): void 0%   (0/1)0%   (0/3)0%   (0/1)
wrap (Object): Object [] 100% (1/1)82%  (14/17)80%  (4/5)
loadContext (): Context 100% (1/1)85%  (33/39)83%  (5/6)

1package com.hammurapi.common;
2 
3import java.lang.reflect.Array;
4import java.util.ArrayList;
5import java.util.Iterator;
6import java.util.List;
7import java.util.ServiceLoader;
8 
9/**
10 * Helper class.
11 * @author Pavel Vlasov
12 *
13 */
14public class Util {
15        
16        /**
17         * Loads single instance of service.
18         * @param <T>
19         * @param type
20         * @return
21         */
22        static Context loadContext() {
23                List<Context> parts = new ArrayList<Context>();
24                Iterator<Context> it = ServiceLoader.load(Context.class, Util.class.getClassLoader()).iterator();
25                while (it.hasNext()) {
26                        parts.add(it.next());
27                }
28                parts.add(new DefaultContext(Util.class.getClassLoader(), null));
29                return new CompositeContext(parts.toArray(new Context[parts.size()]));
30        }
31 
32        /**
33         * Wraps a single object into array to avoid problems with generic arrays.
34         * @param <V>
35         * @param obj
36         * @return
37         */
38        @SuppressWarnings("unchecked")
39        public static <V> V[] wrap(V obj) {
40                if (obj == null) {
41                        return (V[]) new Object[] {null};
42                }
43                V[] ret = (V[]) Array.newInstance(obj.getClass(), 1);
44                ret[0] = obj;
45                return ret;
46        }
47 
48}

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