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 | */ |
11 | package org.jtiger.ant; |
12 | |
13 | import static org.jtiger.framework.ClassAliasMappingFactory.newClassAliasMapping; |
14 | import org.jtiger.framework.FixtureResultsHandler; |
15 | |
16 | final class FixtureResultsHandlerFactory |
17 | { |
18 | private FixtureResultsHandlerFactory() |
19 | { |
20 | |
21 | } |
22 | |
23 | public static Class<? extends FixtureResultsHandler> newFixtureResultsHandler(String name) throws ClassNotFoundException |
24 | { |
25 | if(name == null) |
26 | { |
27 | return null; |
28 | } |
29 | |
30 | final String aliasedName = newClassAliasMapping().getMappedClassName(name); |
31 | |
32 | if(aliasedName != null) |
33 | { |
34 | name = aliasedName; |
35 | } |
36 | |
37 | final Class<?> c = Class.forName(name); |
38 | |
39 | if(FixtureResultsHandler.class.isAssignableFrom(c)) |
40 | { |
41 | return c.asSubclass(FixtureResultsHandler.class); |
42 | } |
43 | |
44 | return null; |
45 | } |
46 | } |