1 package com.sourceforge.jpatterns.patterns.bhv.chain;
2
3 /**
4 * This class is served as handler of the messages by types and by my implementations of {@link IChainMessage} specified. It could
5 * also see not only the implementation of the message but also its type and composition of the inout params. It allows to provide
6 * output params (in that view IChainMessage is Data Trasnfer Object).
7 *
8 * todo: method for checking the permissions on the changing inputs/outputs
9 * todo: method answering the questions: forward/include/ next chain ???
10 * todo: method saying if it rewriting output/ does this extend the input.
11 *
12 * todo: !!! we could chain the handlers using appropriate parents' handlers of this type of message or could chain the handlers
13 * of this chain item
14 * todo: IHandlersChain running all the hadnlers of this chain item for appropriate type of message and then passing the control
15 * above.
16 *
17 *
18 * dfvgsdg
19 * $Author:: zmicer $<br/>
20 */
21 public interface IChainHandler
22 {
23 /**
24 * @return the type of the chain handler. This type is useful when we need to divide some instances of the same implementation
25 * on the groups. Could be null if this info is not valuable at the context of the implementation of the handler.
26 */
27 String getType();
28
29 /**
30 * Answers the question if the specified message fits this handler (could be handled by it). The specifics of this info is
31 * specified at the configuration of system (it is implementation specific info).
32 *
33 * @param message for which we need to answer the question above. Can not be null (otherwise
34 * <code>IllegalArgumentException</code> would appear).
35 *
36 * @return <code>true</code> if message could handle the message and <code>false</code> otherwise.
37 */
38 boolean doesMessageFit(String message);
39
40 /**
41 * Answers the question if the specified message fits this handler (could be handled by it). The specifics of this info is
42 * specified at the configuration of system (it is implementation specific info).
43 *
44 * @param message for which we need to answer the question above. Can not be null (otherwise
45 * <code>IllegalArgumentException</code> would appear).
46 *
47 * @return <code>true</code> if message could handle the message and <code>false</code> otherwise.
48 */
49 boolean doesMessageFit(IChainMessage message);
50
51 /**
52 * Handle the message.
53 * t
54 * todo: think of the return type - status etc??
55 * todo: think if this method operating with string is usefull??? where it could be used???
56 *
57 * @param message which we need to handle. Can not be null (otherwise <code>IllegalArgumentException</code> would appear).
58 *
59 * @throws UnsupportedOperationException in the case it can not handle the message (not permissions/illegal type of message etc.)
60 */
61 void handleMessage(String message) throws UnsupportedOperationException;
62
63 /**
64 * Handle the message. The chain item is specified too to allow handler to perform chaining the handlers ot to call chain methods
65 * of the above chain items etc.
66 * todo: see IHandlersChain
67 *
68 * todo: think of the return type - status etc??
69 * todo: think if this method operating with string is usefull??? where it could be used???
70 *
71 * @param message which we need to handle. Can not be null (otherwise <code>IllegalArgumentException</code> would appear).
72 * @param chainItem the current chain item calling this
73 *
74 * @throws UnsupportedOperationException in the case it can not handle the message (not permissions/illegal type of message etc.)
75 */
76 void handleMessage(String message, IHierarchyItem chainItem) throws UnsupportedOperationException;
77
78 /**
79 * Handle the message. The chain item is specified too to allow handler to perform chaining the handlers ot to call chain methods
80 * of the above chain items etc.
81 * todo: see IHandlersChain
82 *
83 * @param message which we need to handle. Can not be null (otherwise <code>IllegalArgumentException</code> would appear).
84 *
85 * @throws UnsupportedOperationException in the case it can not handle the message (not permissions/illegal type of message etc.)
86 */
87 void handleMessage(IChainMessage message, IHierarchyItem chainItem) throws UnsupportedOperationException;
88
89 }