01: /*=============================================================================
02: * Copyright Texas Instruments 2002. All Rights Reserved.
03: *
04: * This program is free software; you can redistribute it and/or modify
05: * it under the terms of the GNU General Public License as published by
06: * the Free Software Foundation; either version 2 of the License, or
07: * (at your option) any later version.
08: *
09: * This program is distributed in the hope that it will be useful,
10: * but WITHOUT ANY WARRANTY; without even the implied warranty of
11: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12: * GNU General Public License for more details.
13: *
14: * You should have received a copy of the GNU General Public License
15: * along with this program; if not, write to the Free Software
16: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17: */
18:
19: package ti.chimera.registry;
20:
21: import ti.chimera.Registry;
22:
23: /**
24: * An adapter class that implements {@link NodeCreationSubscriber},
25: * {@link NodeDeletionSubscriber}, and {@link NodeSubscriber}.
26: *
27: * @author ;Rob Clark;a0873619;San Diego;;
28: * @version 0.1
29: */
30: public abstract class NodeSubscriberAdapter implements NodeSubscriber,
31: NodeCreationSubscriber, NodeDeletionSubscriber {
32: private Registry registry;
33:
34: /**
35: * Class Constructor
36: */
37: public NodeSubscriberAdapter(Registry registry) {
38: this .registry = registry;
39: }
40:
41: /**
42: * Called to publish the new node value to the subscriber.
43: *
44: * @param node the node doing the publishing
45: * @param value the node's new value
46: */
47: public void publish(Node node, Object value) {
48: }
49:
50: /**
51: * Called when the node is created (ie. added to it's parent)
52: *
53: * @param node the node created
54: */
55: public void nodeCreated(Node node) {
56: }
57:
58: /**
59: * Called when the node is deleted (ie. removed from it's parent)
60: *
61: * @param node the node deleted
62: */
63: public void nodeDeleted(Node node) {
64: }
65:
66: /**
67: * Subscribe to creation/value/deletion
68: */
69: public void subscribe(String path, NodeContract contract) {
70: registry.subscribeToCreation(path, this );
71: registry.subscribeToValue(path, contract, this );
72: registry.subscribeToDeletion(path, this );
73: }
74:
75: /**
76: * Unsubscribe from creation/value/deletion.
77: */
78: public void unsubscribe() {
79: registry.unsubscribeFromCreation(this );
80: registry.unsubscribeFromValue(this );
81: registry.unsubscribeFromDeletion(this );
82: }
83: }
84:
85: /*
86: * Local Variables:
87: * tab-width: 2
88: * indent-tabs-mode: nil
89: * mode: java
90: * c-indentation-style: java
91: * c-basic-offset: 2
92: * eval: (c-set-offset 'substatement-open '0)
93: * eval: (c-set-offset 'case-label '+)
94: * eval: (c-set-offset 'inclass '+)
95: * eval: (c-set-offset 'inline-open '0)
96: * End:
97: */
|