| Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
| ValueGetterFactory |
|
| 1.0;1 |
| 1 | package org.jtheque.primary.utils.web.analyzers.generic.value; | |
| 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 | import org.jtheque.primary.utils.web.analyzers.generic.operation.ScannerPossessor; | |
| 8 | ||
| 9 | /* | |
| 10 | * This file is part of JTheque. | |
| 11 | * | |
| 12 | * JTheque is free software: you can redistribute it and/or modify | |
| 13 | * it under the terms of the GNU General Public License as published by | |
| 14 | * the Free Software Foundation, either version 3 of the License. | |
| 15 | * | |
| 16 | * JTheque is distributed in the hope that it will be useful, | |
| 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 19 | * GNU General Public License for more details. | |
| 20 | * | |
| 21 | * You should have received a copy of the GNU General Public License | |
| 22 | * along with JTheque. If not, see <http://www.gnu.org/licenses/>. | |
| 23 | */ | |
| 24 | ||
| 25 | /** | |
| 26 | * A factory for ValueGetter elements. | |
| 27 | * | |
| 28 | * @author Baptiste Wicht | |
| 29 | */ | |
| 30 | public final class ValueGetterFactory { | |
| 31 | 0 | private static final FactoryContainer<ValueGetter> FACTORY = new FactoryContainer<ValueGetter>(); |
| 32 | ||
| 33 | private static ScannerPossessor scannerPossessor; | |
| 34 | ||
| 35 | /** | |
| 36 | * This an utility class, not instanciable. | |
| 37 | */ | |
| 38 | private ValueGetterFactory(){ | |
| 39 | 0 | super(); |
| 40 | 0 | } |
| 41 | ||
| 42 | static{ | |
| 43 | 0 | FACTORY.add(new SimpleValueGetterFactory()); |
| 44 | 0 | FACTORY.add(new ConditionalValueGetterFactory()); |
| 45 | 0 | FACTORY.add(new IteratorValueGetterFactory()); |
| 46 | 0 | FACTORY.add(new EmptyValueFactory()); |
| 47 | 0 | } |
| 48 | ||
| 49 | /** | |
| 50 | * Set the scanner possessor. | |
| 51 | * | |
| 52 | * @param scannerPossessor The scanner possessor. | |
| 53 | */ | |
| 54 | public static void setScannerPossessor(ScannerPossessor scannerPossessor){ | |
| 55 | 0 | ValueGetterFactory.scannerPossessor = scannerPossessor; |
| 56 | 0 | } |
| 57 | ||
| 58 | /** | |
| 59 | * Return the scanner possessor. | |
| 60 | * | |
| 61 | * @return The scanner possessor. | |
| 62 | */ | |
| 63 | static ScannerPossessor getScannerPossessor(){ | |
| 64 | 0 | return scannerPossessor; |
| 65 | } | |
| 66 | ||
| 67 | /** | |
| 68 | * Return the value getter on the element. | |
| 69 | * | |
| 70 | * @param element The element to get the value getter for. | |
| 71 | * @param reader The reader to use. | |
| 72 | * | |
| 73 | * @return The factored ValueGetter to use. | |
| 74 | * | |
| 75 | * @throws XMLException If an error occurs during the XML processing. | |
| 76 | */ | |
| 77 | public static ValueGetter getValueGetter(Element element, XMLReader reader) throws XMLException{ | |
| 78 | 0 | return FACTORY.getFactoredObject(element, reader); |
| 79 | } | |
| 80 | } |