1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.apache.commons.chain;
17
18
19 import java.util.Iterator;
20
21
22 /***
23 * <p>A {@link Catalog} is a collection of named {@link Command}s (or
24 * {@link Chain}s) that can be used retrieve the set of commands that
25 * should be performed based on a symbolic identifier. Use of catalogs
26 * is optional, but convenient when there are multiple possible chains
27 * that can be selected and executed based on environmental conditions.</p>
28 *
29 * @author Craig R. McClanahan
30 * @version $Revision: 410386 $ $Date: 2006-05-30 22:48:31 +0100 (Tue, 30 May 2006) $
31 */
32
33 public interface Catalog {
34
35
36 /***
37 * <p>A default context attribute for storing a default {@link Catalog},
38 * provided as a convenience only.</p>
39 */
40 String CATALOG_KEY = "org.apache.commons.chain.CATALOG";
41
42
43 /***
44 * <p>Add a new name and associated {@link Command} or {@link Chain}
45 * to the set of named commands known to this {@link Catalog},
46 * replacing any previous command for that name.
47 *
48 * @param name Name of the new command
49 * @param command {@link Command} or {@link Chain} to be returned
50 * for later lookups on this name
51 */
52 void addCommand(String name, Command command);
53
54
55 /***
56 * <p>Return the {@link Command} or {@link Chain} associated with the
57 * specified name, if any; otherwise, return <code>null</code>.</p>
58 *
59 * @param name Name for which a {@link Command} or {@link Chain}
60 * should be retrieved
61 * @return The Command associated with the specified name.
62 */
63 Command getCommand(String name);
64
65
66
67 /***
68 * <p>Return an <code>Iterator</code> over the set of named commands
69 * known to this {@link Catalog}. If there are no known commands,
70 * an empty Iterator is returned.</p>
71 * @return An iterator of the names in this Catalog.
72 */
73 Iterator getNames();
74
75
76 }
77