01: /*
02: * GeoTools - OpenSource mapping toolkit
03: * http://geotools.org
04: * (C) 2005-2006, Geotools Project Managment Committee (PMC)
05: *
06: * This library is free software; you can redistribute it and/or
07: * modify it under the terms of the GNU Lesser General Public
08: * License as published by the Free Software Foundation; either
09: * version 2.1 of the License, or (at your option) any later version.
10: *
11: * This library is distributed in the hope that it will be useful,
12: * but WITHOUT ANY WARRANTY; without even the implied warranty of
13: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14: * Lesser General Public License for more details.
15: */
16: package org.geotools.factory;
17:
18: // Geotools dependencies
19: import java.util.Arrays;
20: import java.util.Iterator;
21:
22: /**
23: * An implementation of {@link FactoryIteratorProvider} over the {@link DummyFactory}.
24: *
25: * @source $URL: http://svn.geotools.org/geotools/tags/2.4.1/modules/library/metadata/src/test/java/org/geotools/factory/DummyFactoryIteratorProvider.java $
26: * @version $Id: DummyFactoryIteratorProvider.java 24924 2007-03-27 17:49:59Z desruisseaux $
27: * @author Martin Desruisseaux
28: */
29: public final class DummyFactoryIteratorProvider implements
30: FactoryIteratorProvider {
31: /**
32: * {@code true} for iterating over the first half or examples, or {@code false}
33: * for iterating over the second half.
34: */
35: private final boolean firstHalf;
36:
37: /**
38: * Creates a new instance of the dummy factory iterator provider.
39: */
40: public DummyFactoryIteratorProvider(final boolean firstHalf) {
41: this .firstHalf = firstHalf;
42: }
43:
44: /**
45: * Returns an iterator over all {@link DummyFactory}.
46: */
47: public Iterator iterator(final Class category) {
48: final DummyFactory[] factories;
49: if (firstHalf) {
50: factories = new DummyFactory[] {
51: new DummyFactory.Example1(),
52: new DummyFactory.Example2(), };
53: } else {
54: factories = new DummyFactory[] {
55: new DummyFactory.Example3(),
56: new DummyFactory.Example4() };
57: }
58: return Arrays.asList(factories).iterator();
59: }
60: }
|