Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
ConditionFactory |
|
| 1.0;1 |
1 | package org.jtheque.primary.utils.web.analyzers.generic.condition; | |
2 | ||
3 | import org.jdom.Element; | |
4 | import org.jtheque.core.utils.file.XMLException; | |
5 | import org.jtheque.core.utils.file.XMLReader; | |
6 | import org.jtheque.primary.utils.web.analyzers.generic.FactoryContainer; | |
7 | ||
8 | /* | |
9 | * This file is part of JTheque. | |
10 | * | |
11 | * JTheque is free software: you can redistribute it and/or modify | |
12 | * it under the terms of the GNU General Public License as published by | |
13 | * the Free Software Foundation, either version 3 of the License. | |
14 | * | |
15 | * JTheque is distributed in the hope that it will be useful, | |
16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
18 | * GNU General Public License for more details. | |
19 | * | |
20 | * You should have received a copy of the GNU General Public License | |
21 | * along with JTheque. If not, see <http://www.gnu.org/licenses/>. | |
22 | */ | |
23 | ||
24 | /** | |
25 | * A factory to build Condition objects. | |
26 | * | |
27 | * @author Baptiste Wicht | |
28 | */ | |
29 | final class ConditionFactory { | |
30 | 0 | private static final FactoryContainer<Condition> FACTORY = new FactoryContainer<Condition>(); |
31 | ||
32 | /** | |
33 | * This is an utility class, non instanciable. | |
34 | */ | |
35 | private ConditionFactory(){ | |
36 | 0 | super(); |
37 | 0 | } |
38 | ||
39 | static{ | |
40 | 0 | FACTORY.add(new ContainFactory()); |
41 | 0 | FACTORY.add(new ContainNotFactory()); |
42 | 0 | FACTORY.add(new StartsNotFactory()); |
43 | 0 | FACTORY.add(new StartsFactory()); |
44 | 0 | } |
45 | ||
46 | /** | |
47 | * Return the condition under the specified element. | |
48 | * | |
49 | * @param element The element to get the condition for. | |
50 | * @param reader The reader to use. | |
51 | * | |
52 | * @return The condition of the specified element. | |
53 | * | |
54 | * @throws XMLException if an error occurs during the XML processing. | |
55 | */ | |
56 | public static Condition getCondition(Element element, XMLReader reader) throws XMLException{ | |
57 | 0 | return FACTORY.getFactoredObject(element, reader); |
58 | } | |
59 | } |