| 1 | package de.uka.ipd.sdq.sensorframework.filter; |
| 2 | |
| 3 | import java.util.ArrayList; |
| 4 | import java.util.HashMap; |
| 5 | import java.util.List; |
| 6 | |
| 7 | /** |
| 8 | * The class manages all available filtered collections. |
| 9 | * |
| 10 | * @author Roman Andrej |
| 11 | * |
| 12 | */ |
| 13 | public class FilteredCollectionRegistry { |
| 14 | |
| 15 | /** Define the FilteredCollectionRegistry instance. */ |
| 16 | private static FilteredCollectionRegistry singletonInstance = new FilteredCollectionRegistry(); |
| 17 | |
| 18 | /** Define the map with filtered collections (filter name, collection). */ |
| 19 | private static HashMap<String, IFilteredCollectionFactory> factories = new HashMap<String, IFilteredCollectionFactory>(); |
| 20 | |
| 21 | /** Singleton pattern. */ |
| 22 | private FilteredCollectionRegistry() { |
| 23 | } |
| 24 | |
| 25 | public static FilteredCollectionRegistry singleton() { |
| 26 | return singletonInstance; |
| 27 | } |
| 28 | |
| 29 | public void addFilteredCollectionFactory(String filterName, |
| 30 | IFilteredCollectionFactory filter) { |
| 31 | factories.put(filterName, filter); |
| 32 | } |
| 33 | |
| 34 | public IFilteredCollectionFactory getFilteredCollectionFactoryByID( |
| 35 | String factoryID) { |
| 36 | return factories.get(factoryID); |
| 37 | } |
| 38 | |
| 39 | /**TODO add documentation |
| 40 | * @return |
| 41 | */ |
| 42 | public List<IFilteredCollectionFactory> getAllAvailableCollectionFactories() { |
| 43 | ArrayList<IFilteredCollectionFactory> result = new ArrayList<IFilteredCollectionFactory>(); |
| 44 | for (IFilteredCollectionFactory filter : factories.values()) { |
| 45 | result.add(filter); |
| 46 | } |
| 47 | return result; |
| 48 | } |
| 49 | } |