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 Addition extends JtObject { 15 16 17 18 19 public Addition () { 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 ("ADD")) { 54 return (new Integer (op1 + op2)); 55 } 56 57 58 if (msgid.equals ("JtREMOVE")) { 59 return (null); 60 } 61 62 67 handleError ("Addition.processMessage: invalid message id:" + msgid); 68 return (null); 69 70 } 71 72 73 74 75 } 76 77 78 | Popular Tags |