KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > Jt > examples > patterns > MultiplicationA


1
2
3 package Jt.examples.patterns;
4 import java.util.*;
5 import java.lang.reflect.*;
6 import java.beans.*;
7 import java.io.*;
8 import Jt.*;
9
10 /**
11  * Multiply two numbers
12  */

13
14 public class MultiplicationA extends JtObject {
15
16
17
18
19   public MultiplicationA () {
20   }
21
22
23
24
25   /**
26     * Process object messages.
27     */

28
29   public Object JavaDoc processMessage (Object JavaDoc event) {
30
31    String JavaDoc msgid = null;
32    JtMessage e = (JtMessage) event;
33    Object JavaDoc content;
34    Object JavaDoc data;
35    int op1, op2;
36
37
38      if (e == null)
39     return null;
40
41      msgid = (String JavaDoc) e.getMsgId ();
42
43      if (msgid == null)
44     return null;
45
46      content = e.getMsgContent();
47      data = e.getMsgData ();
48
49      op1 = ((Integer JavaDoc) content).intValue ();
50
51      op2 = ((Integer JavaDoc) data).intValue ();
52
53      if (msgid.equals ("MULTIPLY")) {
54        return (new Integer JavaDoc (op1 * op2));
55      }
56
57
58      if (msgid.equals ("JtREMOVE")) {
59        return (null);
60      }
61
62
63      handleError ("MultiplicationA.processMessage: invalid message id:" + msgid);
64      return (null);
65
66   }
67
68  
69
70
71 }
72
73
74
Popular Tags