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 13 14 public class MultiplicationA extends JtObject { 15 16 17 18 19 public MultiplicationA () { 20 } 21 22 23 24 25 28 29 public Object processMessage (Object event) { 30 31 String msgid = null; 32 JtMessage e = (JtMessage) event; 33 Object content; 34 Object data; 35 int op1, op2; 36 37 38 if (e == null) 39 return null; 40 41 msgid = (String ) e.getMsgId (); 42 43 if (msgid == null) 44 return null; 45 46 content = e.getMsgContent(); 47 data = e.getMsgData (); 48 49 op1 = ((Integer ) content).intValue (); 50 51 op2 = ((Integer ) data).intValue (); 52 53 if (msgid.equals ("MULTIPLY")) { 54 return (new Integer (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 |