Source code: recoin/system/session/ComponentOrder.java
1 package recoin.system.session;
2
3 import java.util.Vector;
4
5 /**
6 * A ComponentOrder is used to to tell a Component what it should do with
7 * a RetrievalContainer in terms of the objects it should try to process and
8 * their order.<br>
9 * Therefore it contains information as to what objects in the
10 * container should be processed, whether any results should be stored inside
11 * the container, and if these results - together with a corresponding
12 * ComponentOrder - should be forwarded to another component inside the
13 * ModuleGroup.
14 * <br><br>
15 * A ComponentOrder can have another single ComponentOrder as its parent order and any
16 * number of them as child order thus creating a tree structure to implement
17 * the order in which the ComponentOrders are executed. Naturally, the parent order
18 * is executed before any of its child orders.
19 * @author Jan H. Scheufen
20 * @version 0.2.9
21 */
22 public class ComponentOrder
23 {
24 /**
25 * The chain IDs of the ComponentSupport objects that the Component should
26 * try to process.
27 */
28 public Vector csChainIDs;
29 /**
30 * The parent of this ComponentOrder which has to be executed before this one.
31 */
32 public ComponentOrder parentOrder = null;
33 /**
34 * A number of child orders that are executed when this ComponentOrder is finished.
35 */
36 public Vector childOrders;
37 /**
38 * The ID of the Module this ComponentOrder is destined for.
39 */
40 public int moduleID;
41 /**
42 * The ID of the Component this ComponentOrder is destined for.
43 */
44 public int componentID;
45
46 /**
47 * Creates a new ComponentOrder for the Module and Component with the specified IDs.
48 * @param moduleID the ID of the Module
49 * @param componentID the ID of the Component
50 */
51 public ComponentOrder( int moduleID, int componentID )
52 {
53 this.moduleID = moduleID;
54 this.componentID = componentID;
55 childOrders = new Vector();
56 csChainIDs = new Vector();
57 }
58
59 /**
60 * Creates a new ComponentOrder for the Module and Component with the specified IDs.
61 * The specified ComponentOrder is set as this ComponentOrder's parent.
62 * @param parentOrder a ComponentOrder
63 * @param moduleID the ID of the Module
64 * @param componentID the ID of the Component
65 */
66 public ComponentOrder( ComponentOrder parentOrder, int moduleID, int componentID )
67 {
68 this.parentOrder = parentOrder;
69 this.moduleID = moduleID;
70 this.componentID = componentID;
71 childOrders = new Vector();
72 csChainIDs = new Vector();
73 }
74
75 /**
76 * Returns the ID of the Component this ComponentOrder is destined for.
77 * @return int
78 */
79 public int getComponentID()
80 {
81 return componentID;
82 }
83 /**
84 * Returns the chain IDs of the ComponentSupports that should be processed as a String
85 * array.
86 * @return the chain IDs in a String[]
87 */
88 public String[] getSupportChainIDs()
89 {
90 String[] ids = new String[this.csChainIDs.size()];
91 csChainIDs.toArray( ids );
92 return ids;
93 }
94
95 /**
96 * Returns the child orders.
97 * @return a Vector of ComponentOrder objects
98 */
99 public Vector getChildOrders()
100 {
101 return childOrders;
102 }
103
104 /**
105 * Returns the parent order.
106 * @return the parent ComponentOrder
107 */
108 public ComponentOrder getParentOrder()
109 {
110 return parentOrder;
111 }
112
113 /**
114 * Adds the specified ComponentOrder to the child orders.
115 * @param childOrder a ComponentOrder
116 */
117 public void addChildOrder(ComponentOrder childOrder)
118 {
119 this.childOrders.add(childOrder);
120 }
121
122 }