01: /*
02: * Copyright 2003-2004 The Apache Software Foundation
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16: package org.apache.commons.chain;
17:
18: import java.util.Iterator;
19:
20: /**
21: * <p>A {@link Catalog} is a collection of named {@link Command}s (or
22: * {@link Chain}s) that can be used retrieve the set of commands that
23: * should be performed based on a symbolic identifier. Use of catalogs
24: * is optional, but convenient when there are multiple possible chains
25: * that can be selected and executed based on environmental conditions.</p>
26: *
27: * @author Craig R. McClanahan
28: * @version $Revision: 410386 $ $Date: 2006-05-30 22:48:31 +0100 (Tue, 30 May 2006) $
29: */
30:
31: public interface Catalog {
32:
33: /**
34: * <p>A default context attribute for storing a default {@link Catalog},
35: * provided as a convenience only.</p>
36: */
37: String CATALOG_KEY = "org.apache.commons.chain.CATALOG";
38:
39: /**
40: * <p>Add a new name and associated {@link Command} or {@link Chain}
41: * to the set of named commands known to this {@link Catalog},
42: * replacing any previous command for that name.
43: *
44: * @param name Name of the new command
45: * @param command {@link Command} or {@link Chain} to be returned
46: * for later lookups on this name
47: */
48: void addCommand(String name, Command command);
49:
50: /**
51: * <p>Return the {@link Command} or {@link Chain} associated with the
52: * specified name, if any; otherwise, return <code>null</code>.</p>
53: *
54: * @param name Name for which a {@link Command} or {@link Chain}
55: * should be retrieved
56: * @return The Command associated with the specified name.
57: */
58: Command getCommand(String name);
59:
60: /**
61: * <p>Return an <code>Iterator</code> over the set of named commands
62: * known to this {@link Catalog}. If there are no known commands,
63: * an empty Iterator is returned.</p>
64: * @return An iterator of the names in this Catalog.
65: */
66: Iterator getNames();
67:
68: }
|