1 package Jt.examples.patterns; 2 import java.util.*; 3 import java.lang.reflect.*; 4 import java.beans.*; 5 import java.io.*; 6 import Jt.*; 7 8 9 12 13 14 public class Visitable extends JtObject { 15 16 17 public Visitable() { 18 } 19 20 21 28 29 public Object processMessage (Object event) { 30 31 String msgid = null; 32 JtMessage e = (JtMessage) event; 33 Object content; 34 Object data; 35 JtMessage aux; 36 37 if (e == null) 38 return null; 39 40 msgid = (String ) e.getMsgId (); 41 42 if (msgid == null) 43 return null; 44 45 content = e.getMsgContent(); 46 47 if (msgid.equals ("JtREMOVE")) { 48 return (this); 49 } 50 51 if (msgid.equals ("JtACCEPT")) { 52 53 if (content == null) { 54 handleError ("processMessage: invalid ACCEPT message; visitor reference is null"); 55 return (null); 56 } 57 58 61 aux = new JtMessage ("JtVISIT"); 62 aux.setMsgContent (this); 63 return (sendMessage (content, aux)); 64 } 65 66 67 handleError ("Visitable.processMessage: invalid message id:" + msgid); 68 return (null); 69 70 } 71 72 73 } 74 | Popular Tags |