Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
ConditionUtils |
|
| 2.5;2.5 |
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 | ||
7 | /* | |
8 | * This file is part of JTheque. | |
9 | * | |
10 | * JTheque is free software: you can redistribute it and/or modify | |
11 | * it under the terms of the GNU General Public License as published by | |
12 | * the Free Software Foundation, either version 3 of the License. | |
13 | * | |
14 | * JTheque is distributed in the hope that it will be useful, | |
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 | * GNU General Public License for more details. | |
18 | * | |
19 | * You should have received a copy of the GNU General Public License | |
20 | * along with JTheque. If not, see <http://www.gnu.org/licenses/>. | |
21 | */ | |
22 | ||
23 | /** | |
24 | * An utility class to create Condition from the XML file. | |
25 | * | |
26 | * @author Baptiste Wicht | |
27 | */ | |
28 | public final class ConditionUtils { | |
29 | /** | |
30 | * Utility class, not instanciable. | |
31 | */ | |
32 | private ConditionUtils(){ | |
33 | 0 | super(); |
34 | 0 | } |
35 | ||
36 | /** | |
37 | * Return the condition contained in a specific location of a specific node. | |
38 | * | |
39 | * @param currentNode The node to search in. | |
40 | * @param location The location to search in. | |
41 | * @param reader The XML Reader | |
42 | * | |
43 | * @return The Condition or null if we doesn't found one. | |
44 | * | |
45 | * @throws XMLException If an errors occurs during the parse of the XML Elements. | |
46 | */ | |
47 | public static Condition getCondition(Object currentNode, String location, XMLReader reader) throws XMLException{ | |
48 | 0 | Object conditionNode = reader.getNode(location, currentNode); |
49 | ||
50 | 0 | if (conditionNode != null){ |
51 | 0 | Element node = reader.getNode("*", conditionNode); |
52 | ||
53 | 0 | if (node != null){ |
54 | 0 | return ConditionFactory.getCondition(node, reader); |
55 | } | |
56 | } | |
57 | ||
58 | 0 | return null; |
59 | } | |
60 | } |