View Javadoc

1   package org.andromda.cartridges.mgmt;
2   
3   import java.util.Collection;
4   import java.util.HashMap;
5   import java.util.ArrayList;
6   
7   import org.andromda.cartridges.interfaces.IAndroMDACartridge;
8   
9   /***
10   * Dictionary that registers cartridges under a stereotype. It can manage more
11   * than one cartridge with the same stereotype.
12   * 
13   * @since 01.04.2003
14   * @author <a href="http://www.mbohlen.de">Matthias Bohlen</a>
15   *
16   */
17  public class CartridgeDictionary
18  {
19      private HashMap hm = new HashMap();
20      
21      /***
22       * Adds a cartridge to the dictionary.
23       * 
24       * @param stereotype the stereotype that is supported by this cartridge
25       * @param desc the cartridge descriptor
26       */
27      public void addCartridge (String stereotype, IAndroMDACartridge desc)
28      {
29          if (hm.containsKey(stereotype))
30          {
31              ArrayList v = (ArrayList)hm.get(stereotype);
32              v.add(desc);
33          }
34          else
35          {
36              ArrayList v = new ArrayList();
37              v.add(desc);
38              hm.put(stereotype, v);
39          }
40      }
41      
42      
43      /***
44       * Looks up all cartridges that support a given stereotype.
45       * 
46       * @param stereotype the stereotype
47       * @return Collection collection of cartridges
48       */
49      public Collection lookupCartridges (String stereotype)
50      {
51          return (ArrayList)hm.get(stereotype);
52      }
53  }