Source code: com/fm/rss/channelStorageFactory.java
1 /****************************************************************************
2 * Copyright (c) 2003 Andrew Duka | aduka@users.sourceforge.net
3 * All right reserved.
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 ****************************************************************************/
11 package com.fm.rss;
12
13 import java.util.HashMap;
14 import java.util.Iterator;
15
16 /**
17 * Defines a factory API that enables applications to configure and
18 * obtain a channel storage entity.
19 *
20 * <p>This is a dumb implementation, which actually does nothing except
21 * defining some common API</p>
22 *
23 */
24 public class channelStorageFactory {
25
26 HashMap params;
27
28 protected channelStorageFactory() {
29 this.params = new HashMap();
30 }
31
32 public static channelStorageFactory newInstance()
33 {
34 return new channelStorageFactory();
35 }
36
37 /**
38 * Create new ChannelStorage instance
39 *
40 * @return Instance of the class which implements ChannelStorage interface
41 */
42 public ChannelStorage newStorageInstance()
43 {
44 /*
45 * @todo Implement functionality for getting various storages
46 */
47 fsChannelStorage newStorage = new fsChannelStorage();
48 String key;
49
50 // Applying storage(or whatever) params to the new storage
51 for (Iterator i = params.keySet().iterator(); i.hasNext();)
52 {
53 key = (String)i.next();
54 newStorage.setParamValue(key, this.params.get(key));
55 }
56 return newStorage;
57 }
58
59 /**
60 * Set configuration param.
61 *
62 * Basically factory accepts all params it is asked for .
63 *
64 * @param param String with parameter name
65 * @param value String with parameter value
66 */
67 public void setParamValue(String param,Object value)
68 {
69 this.params.put(param, value);
70 }
71
72 /**
73 * Get configuration param values.
74 *
75 * If no parameter with given name exists the null value will be
76 * returned.
77 *
78 * @param param String with parameter name
79 *
80 * @return Object representing parameter value or null if param doesn't exist
81 */
82 public Object getParamValue(String param)
83 {
84 return this.params.get(param);
85 }
86
87
88
89 }