?? events-2.html.svn-base
字號(hào):
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<HTML>
<HEAD>
<META NAME="GENERATOR" CONTENT="SGML-Tools 1.0.6">
<TITLE>JNS Event Type Documentation: How to Handle Events</TITLE>
<LINK HREF="Events-3.html" REL=next>
<LINK HREF="Events-1.html" REL=previous>
<LINK HREF="Events.html#toc2" REL=contents>
</HEAD>
<BODY>
<A HREF="Events-3.html">Next</A>
<A HREF="Events-1.html">Previous</A>
<A HREF="Events.html#toc2">Contents</A>
<HR>
<H2><A NAME="s2">2. How to Handle Events</A></H2>
<P>This section will give a brief description of what is involved in handling
events. The answer is really very simple. The trace class you might be
writing will be passed an Event and you have to somehow convert what is
contained in this event into your own format (for example some kind of
trace-file).
<P>
<P>You just have to pass through a number of straight-forward steps in order
to accomplish this:
<OL>
<LI>Identify the event name and fork - You will want to look at the
<I>name</I> parameter of the event in order to see which event it is and
then execute different bits of code depending on the event type.</LI>
<LI>Go through the parameters - in the code that handles the special kind
of event it is supposed to, go through the parameters. You <B>know</B> which
parameters to expect in a certain type of event because they are all
documented in here.</LI>
<LI>Look at each parameters name and fork - Depending on the parameter's
name, you will have to treat its value differently</LI>
<LI>Cast the value - After reaching the required code that can deal with
this parameter, cast the value to the object type it must contain. You may
exit with an error if it doesn't, but it will not (unless strange things
happen..)</LI>
</OL>
<P>
<P>That is really all there is to it. If you are still puzzled then I recommend
you read the following sections, which are a catalog to the pre-defined
events in JNS. You are also encouraged to read the source code of the Javis
trace-file writer class (jns.trace.JavisTrace) if you want to find out how to handle
events in practice. In addition, look at the jns.elements.QueueDropTail class
and the jns.util.EventGenerator class if you want to see how events that are
later received by a Trace class are actually generated.
<P>
<P>
<HR>
<A HREF="Events-3.html">Next</A>
<A HREF="Events-1.html">Previous</A>
<A HREF="Events.html#toc2">Contents</A>
</BODY>
</HTML>
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -