EMMA Coverage Report (generated Fri Jul 28 01:51:09 CEST 2006)
[all classes][org.jtiger.framework]

COVERAGE SUMMARY FOR SOURCE FILE [MethodCategoryFactory.java]

nameclass, %method, %block, %line, %
MethodCategoryFactory.java100% (2/2)100% (5/5)100% (111/111)100% (26/26)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class MethodCategoryFactory100% (1/1)100% (2/2)100% (7/7)100% (3/3)
MethodCategoryFactory (): void 100% (1/1)100% (3/3)100% (2/2)
newMethodCategory (): MethodCategory 100% (1/1)100% (4/4)100% (1/1)
     
class MethodCategoryFactory$MethodCategoryImpl100% (1/1)100% (3/3)100% (104/104)100% (23/23)
MethodCategoryFactory$MethodCategoryImpl (): void 100% (1/1)100% (3/3)100% (2/2)
isInAnyCategories (Method, ReadOnlyArray): boolean 100% (1/1)100% (33/33)100% (9/9)
isInAnyCategory (Method, String): boolean 100% (1/1)100% (68/68)100% (12/12)

1/*
2 * JTiger Unit Testing Framework for J2SE 1.5
3 * Copyright (C) 2005 Tony Morris
4 *
5 * This software is licenced under the
6 * Common Public Licence version 1.0
7 * http://www.opensource.org/licenses/cpl1.0.php
8 *
9 * You received a copy of this licence with this software.
10 */
11package org.jtiger.framework;
12 
13import java.lang.reflect.Method;
14import java.util.regex.Pattern;
15 
16final class MethodCategoryFactory
17{
18    private MethodCategoryFactory()
19    {
20 
21    }
22 
23    static MethodCategory newMethodCategory()
24    {
25        return new MethodCategoryImpl();
26    }
27 
28    private static final class MethodCategoryImpl implements MethodCategory
29    {
30        MethodCategoryImpl()
31        {
32 
33        }
34 
35        public boolean isInAnyCategories(final Method m, final ReadOnlyArray<String> categories) throws NullPointerException
36        {
37            if(m == null)
38            {
39                throw new NullPointerException();
40            }
41 
42            if(categories == null || categories.length() == 0)
43            {
44                return true;
45            }
46 
47            for(String category : categories)
48            {
49                if(isInAnyCategory(m, category))
50                {
51                    return true;
52                }
53            }
54 
55            return false;
56        }
57 
58        private boolean isInAnyCategory(final Method m, final String category)
59        {
60            Category c = m.getAnnotation(Category.class);
61            final Pattern p = Pattern.compile(category);
62 
63            if(c != null)
64            {
65                for(String s : c.value())
66                {
67                    if(p.matcher(s).matches())
68                    {
69                        return true;
70                    }
71                }
72            }
73 
74            c = m.getDeclaringClass().getAnnotation(Category.class);
75 
76            if(c != null)
77            {
78                for(String s : c.value())
79                {
80                    if(p.matcher(s).matches())
81                    {
82                        return true;
83                    }
84                }
85            }
86 
87            return false;
88        }
89    }
90}

[all classes][org.jtiger.framework]
EMMA 2.0.5312 (C) Vladimir Roubtsov