Source code: feynman/framework/datastore/DataStoreFactory.java
1 /*
2 * $Header: /cvsroot/feynman/src/feynman/framework/datastore/DataStoreFactory.java,v 1.1.1.1 2002/11/12 02:25:41 wesley_bailey Exp $
3 * $Revision: 1.1.1.1 $
4 * $Date: 2002/11/12 02:25:41 $
5 * $Copyright: Copyright (C) 2002 Path Integral Software $
6 */
7 package feynman.framework.datastore;
8
9 /**
10 * Factory class for the creation of particular <b>DataStore</b> implementation.
11 * The frameworkd currently supports the <b>DataStoreFile</b> implementation only.
12 *
13 * @author Wes Bailey
14 * @version $Revision: 1.1.1.1 $ $Date: 2002/11/12 02:25:41 $
15 */
16 public class DataStoreFactory {
17
18 // Create the instance of the class.
19 private static final DataStoreFactory INSTANCE = new DataStoreFactory();
20
21 private DataStoreFactory() {
22 // singleton
23 }
24
25 /**
26 * Method to retrieve an instance of the class.
27 */
28 public static DataStoreFactory getInstance() {
29 return INSTANCE;
30 }
31
32 /**
33 * Method to create the <b>DataStore</b> object that has been specified
34 * in the <em>Simulation.properties</em> file in the following manner:
35 * <p>
36 * </pre>
37 * # Define the data storage mechanism to be used.
38 * DataStore=file
39 * #DataStore=dbms
40 *
41 * # Define the data source destination that the measurement data will be stored in.
42 * DataStoreFile=data.csv
43 * #DataStoreTable=table
44 * </pre>
45 * </p>
46 * <b>Note:</b> If an invalid data store is defined in the properties file
47 * the <b>Controller</b> class will throw and <em>InvalidDataStoreException</em>.
48 */
49
50 public DataStore create(String type) throws InvalidDataStoreException {
51
52 // Decision tree for the parametrized data store specification.
53 if (type.equalsIgnoreCase("file")) {
54
55 return new FileDataStore();
56
57 } else if (type.equalsIgnoreCase("dbms")) {
58
59 // no specific implementation for a dbms exists yet.
60 //return new DbmsDataStore();
61 throw new InvalidDataStoreException("DataStore dbms not implemented");
62
63 } else {
64
65 // The specified data store is not implemented.
66 throw new InvalidDataStoreException("Invalid DataStore: " + type);
67
68 }
69
70 }
71
72 }