source: trunk/EventBenchConsole/src/de/ugoe/cs/eventbench/data/GlobalDataContainer.java @ 27

Last change on this file since 27 was 1, checked in by sherbold, 14 years ago
File size: 918 bytes
Line 
1package de.ugoe.cs.eventbench.data;
2
3import java.util.HashMap;
4import java.util.Map;
5
6public class GlobalDataContainer {
7       
8        private static GlobalDataContainer theInstance= null;
9       
10        private Map<String, Object> dataObjects;
11       
12        public static GlobalDataContainer getInstance() {
13                if( theInstance==null ) {
14                        theInstance = new GlobalDataContainer();
15                }
16                return theInstance;
17        }
18       
19        private GlobalDataContainer() {
20                dataObjects = new HashMap<String, Object>();
21        }
22       
23        public boolean addData(String key, Object data) {
24                Object previousEntry = dataObjects.put(key, data);
25                return previousEntry!=null;
26        }
27       
28        public boolean removeData(String key) {
29                Object previousEntry = dataObjects.remove(key);
30                return previousEntry==null;
31        }
32       
33        public Object getData(String key) {
34                return dataObjects.get(key);
35        }
36       
37        public void reset() {
38                dataObjects = new HashMap<String, Object>();
39        }
40
41}
Note: See TracBrowser for help on using the repository browser.