EMMA Coverage Report (generated Tue Apr 17 08:51:20 BST 2007)
[all classes][org.jtoolkit.essence.data]

COVERAGE SUMMARY FOR SOURCE FILE [Event.java]

nameclass, %method, %block, %line, %
Event.java100% (1/1)100% (4/4)100% (23/23)100% (10/10)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class Event$StatusEvent100% (1/1)100% (4/4)100% (23/23)100% (10/10)
Event$StatusEvent (DataInput): void 100% (1/1)100% (7/7)100% (3/3)
Event$StatusEvent (boolean): void 100% (1/1)100% (6/6)100% (3/3)
notifyListener (Event$Listener): void 100% (1/1)100% (5/5)100% (2/2)
writeData (DataOutput): void 100% (1/1)100% (5/5)100% (2/2)

1package org.jtoolkit.essence.data;
2 
3import org.jetbrains.annotations.NotNull;
4import org.jtoolkit.essence.app.pojo.DataValue;
5import org.jtoolkit.essence.app.pojo.Datable;
6import org.jtoolkit.essence.concurrency.Immutable;
7import org.jtoolkit.essence.concurrency.CallbackSet;
8 
9import java.io.DataInput;
10import java.io.DataOutput;
11import java.io.IOException;
12 
13/*
14   Copyright 2006 Peter Lawrey
15 
16   Licensed under the Apache License, Version 2.0 (the "License");
17   you may not use this file except in compliance with the License.
18   You may obtain a copy of the License at
19 
20       http://www.apache.org/licenses/LICENSE-2.0
21 
22   Unless required by applicable law or agreed to in writing, software
23   distributed under the License is distributed on an "AS IS" BASIS,
24   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
25   See the License for the specific language governing permissions and
26   limitations under the License.
27*/
28 
29/**
30 * An Event which can be process by an Event Handler or Event Listener.
31 * <p/>A handler takes all Events as Event objects. A handler is not interested in the contents of the event only in routering it.
32 * <p/>A listener is notified of events of interest in a decoded way..
33 *
34 * @author Peter Lawrey
35 */
36@Immutable
37public interface Event {
38    /**
39     * Notify this listener of an event.
40     */
41    public void notifyListener(@NotNull Listener l);
42 
43    /**
44     * A Listenable can have event handlers and listeners.
45     */
46    public interface Listenable {
47        /**
48         * @return This object can have a set of listeners.
49         */
50        @NotNull public ListenerSet getListenerSet();
51    }
52 
53    /**
54     * Process an event based on its contents.
55     */
56    public interface Listener {
57        public void onStatusEvent(boolean online) throws IllegalStateException;
58    }
59 
60    /**
61     * Notify that a Listeneable is online/offline.  This event is triggers when a Listener is added for the first time.
62     */
63    public class StatusEvent extends DataValue implements Datable, Event {
64        public final boolean online;
65 
66        public StatusEvent(boolean online) {
67            this.online = online;
68        }
69 
70        public void notifyListener(@NotNull Listener l) {
71            l.onStatusEvent(online);
72        }
73 
74        @SuppressWarnings("UnusedDeclaration")
75        public StatusEvent(@NotNull DataInput in) throws IOException {
76            online = in.readBoolean();
77        }
78 
79        public void writeData(@NotNull DataOutput out) throws IOException {
80            out.writeBoolean(online);
81        }
82    }
83 
84    /**
85     * A set of handler and listeners.
86     */
87    public interface ListenerSet extends CallbackSet<Event> {
88        public void add(@NotNull Listener l);
89 
90        public void notifyReset(boolean online);
91 
92        public void remove(@NotNull Listener l);
93    }
94}

[all classes][org.jtoolkit.essence.data]
EMMA 2.0.5312 (C) Vladimir Roubtsov