net.sourceforge.cilib.problem.dataset
Class DataSetManager

java.lang.Object
  extended by net.sourceforge.cilib.problem.dataset.DataSetManager
All Implemented Interfaces:
Serializable

public final class DataSetManager
extends Object
implements Serializable

This class is a Singleton and is responsible for managing all the DataSets and DataSetBuilders that might be instantiated by a Simulation, Problem or Thread. It prevents the same dataset or dataset builder from being parsed or initialised more than once. It achieves this by maintaining two Hashtables. The first, datasets (with its key the identifier of the dataset and its value an ArrayList of ClusterableDataSet.Patterns that have been returned by the LocalDataSet.parseDataSet() method) makes sure that a specific dataset is parsed and instantiated only once.
The second, builders (with its key the identifier of the dataset builder and its value the AssociatedPairDataSetBuilder object) makes sure that a specific dataset builder is built and initialised only once.
The concrete LocalDataSet is used, but only for now, because I didn't want to change the more generic DataSet.
The concrete AssociatedPairDataSetBuilder is used, but only for now, because I didn't want to change the more generic DataSetBuilder.

See Also:
Serialized Form

Method Summary
 ArrayList<ClusterableDataSet.Pattern> getDataFromSet(LocalDataSet dataset)
          Either parse and retrieve or just retrieve the list of patterns that represents the requested dataset.
 AssociatedPairDataSetBuilder getDataSetBuilder(AssociatedPairDataSetBuilder datasetBuilder)
          Either initialise and retrieve or just retrieve the object that represents the requested built up dataset.
static DataSetManager getInstance()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static DataSetManager getInstance()

getDataFromSet

public ArrayList<ClusterableDataSet.Pattern> getDataFromSet(LocalDataSet dataset)
Either parse and retrieve or just retrieve the list of patterns that represents the requested dataset. The dataset's identifier (filename in the case of a LocalDataSet) is used as the key into the datasets Hashtable.

Parameters:
dataset - a LocalDataSet that may or may not have been parsed/instantiated before
Returns:
an ArrayList of ClusterableDataSet.Patterns representing the given dataset

getDataSetBuilder

public AssociatedPairDataSetBuilder getDataSetBuilder(AssociatedPairDataSetBuilder datasetBuilder)
Either initialise and retrieve or just retrieve the object that represents the requested built up dataset. The dataset builder's identifier is used as the key into the builders Hashtable.

Parameters:
datasetBuilder - an AssociatedPairDataSetBuilder that may or may not have been built/instantiated before
Returns:
an AssociatedPairDataSetBuilder that represent the requested built up dataset


Copyright © 2009 CIRG. All Rights Reserved.