package de.ugoe.cs.quest.ui; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.Serializable; import java.util.Collection; import java.util.HashMap; import java.util.LinkedList; import java.util.Map; import java.util.Map.Entry; import de.ugoe.cs.quest.SequenceInstanceOf; import de.ugoe.cs.quest.usageprofiles.IStochasticProcess; /** *
* This data structure can be used by the commands to store any {@link Object}. * The data is stored in a key-value map, with strings as keys. *
** This class is implemented as a singleton, as more than one data container * does not serves no purpose. *
* * @author Steffen Herbold * @version 1.0 */ public class GlobalDataContainer implements Serializable { /** ** Id for object serialization. *
*/ private static final long serialVersionUID = 1L; /** ** Instance of the {@link GlobalDataContainer} (implemented as singleton). *
*/ transient private static GlobalDataContainer theInstance = null; /** ** Internal storage of the data. *
*/ private Map* Returns the instance of the container. If it does not yet exist, the data * container is created. *
* * @return instance of the container */ public static GlobalDataContainer getInstance() { if (theInstance == null) { theInstance = new GlobalDataContainer(); } return theInstance; } /** ** Manual serialization of the object. Necessary to guarantee the singleton * property. *
* * @param s * output stream for the serialization * @throws IOException * thrown if there is problem writing to the output stream */ private void writeObject(ObjectOutputStream s) throws IOException { s.defaultWriteObject(); s.writeObject(dataObjects); } /** *
* Manual de-serialization of the object. Necessary to guarantee the
* singleton property.
*
* @param s
* input stream for the de-serialization
* @throws IOException
* thrown if there is problem reading from the input stream
* @throws ClassNotFoundException
* thrown if there is a problem reading from the input stream
*/
@SuppressWarnings("unchecked")
private void readObject(ObjectInputStream s) throws IOException,
ClassNotFoundException {
s.defaultReadObject();
if (theInstance == null) {
theInstance = new GlobalDataContainer();
}
theInstance.dataObjects = (Map
* Manual de-serialization to guarantee the singleton property.
*
* Constructor. Creates a new GlobalDataContainer. Private to guarantee the
* singleton property.
*
* Adds data to the container.
*
* Removes data from the container.
*
* Returns the data associated with a key or {@code null} if no data is
* stored for the key.
*
* Resets the data container, i.e., deletes all its contents.
*
* Returns all keys of collections of sequences contained in the storage.
*
* Returns the keys of all {@link IStochasticProcess}s contained in the
* storage.
*
* Returns the keys of all objects contained in the storage.
*