1 package org.andromda.cartridges.interfaces;
2
3 import java.io.File;
4 import java.util.HashMap;
5
6 /***
7 * Dictionary of mappings from cartridge outlets to physical directories.
8 *
9 * @since 02.04.2003
10 * @author <a href="http://www.mbohlen.de">Matthias Bohlen</a>
11 *
12 */
13 public class OutletDictionary
14 {
15 private HashMap dict = new HashMap();
16
17 /***
18 * Add a mapping for a catridge outlet to a physical directory.
19 *
20 * @param cartridgeName name of the cartridge to which the mapping applies
21 * @param outletName name of the outlet to map
22 * @param physDir physical directory
23 */
24 public void addOutletMapping(
25 String cartridgeName,
26 String outletName,
27 File physDir)
28 {
29 HashMap hm;
30 if (dict.containsKey(cartridgeName))
31 {
32 hm = (HashMap) dict.get(cartridgeName);
33 }
34 else
35 {
36 hm = new HashMap();
37 dict.put(cartridgeName, hm);
38 }
39 hm.put(outletName, physDir);
40 }
41
42 /***
43 * Lookup a mapping for a catridge outlet to a physical directory.
44 *
45 * @param cartridgeName name of the cartridge to which the mapping applies
46 * @param outletName name of the outlet to map
47 * @return File the absolute path to the directory
48 */
49 public File lookupOutlet(String cartridgeName, String outletName)
50 {
51 File result = null;
52 HashMap outlets = (HashMap) dict.get(cartridgeName);
53
54 if (outlets != null)
55 {
56 result = (File) outlets.get(outletName);
57 }
58 return result;
59 }
60 }