01: package csdl.jblanket.methodset;
02:
03: import java.util.HashMap;
04: import java.util.Map;
05:
06: /**
07: * Implements a Singleton design pattern for the container of method information
08: * collected by JBlanket. This class is needed to avoid collisions when method
09: * type signatures are stored by the JUnit test classes.
10: *
11: * @author Joy M. Agustin
12: * @version $Id: MethodSetManager.java,v 1.1 2004/11/07 00:32:38 timshadel Exp $
13: */
14: public class MethodSetManager {
15:
16: /** The instance of the MethodSetManager class */
17: private static MethodSetManager theInstance = null;
18:
19: /** Container mapping fileName -> MethodSetManager */
20: private Map managerMap;
21:
22: /**
23: * Initializes a new MethodSetManager instance.
24: */
25: private MethodSetManager() {
26: this .managerMap = new HashMap();
27: }
28:
29: /**
30: * Gets the current instance of MethodSetManager.
31: *
32: * @return the MethodSetManager instance.
33: */
34: public static synchronized MethodSetManager getInstance() {
35:
36: if (MethodSetManager.theInstance == null) {
37: MethodSetManager.theInstance = new MethodSetManager();
38: }
39:
40: return MethodSetManager.theInstance;
41: }
42:
43: /**
44: * Gets the MethodSet instance corresponding to <code>fileName</code> from the
45: * MethodSetManager instance.
46: *
47: * @param fileName the name of the file the MethodSet instance will be store in.
48: * @return the MethodSet instance corresponding to <code>fileName</code>.
49: * If none exists, create a new one.
50: */
51: public MethodSet getMethodSet(String fileName) {
52: MethodSet methodSet = (MethodSet) this .managerMap.get(fileName);
53:
54: if (methodSet == null) {
55: methodSet = new MethodSet();
56: this.managerMap.put(fileName, methodSet);
57: }
58:
59: return methodSet;
60: }
61: }
|