001    /*
002     * Copyright (c) 2003, The Regents of the University of California, through
003     * Lawrence Berkeley National Laboratory (subject to receipt of any required
004     * approvals from the U.S. Dept. of Energy). All rights reserved.
005     */
006    
007    package gov.lbl.dsd.sea.event;
008    
009    import gov.lbl.dsd.sea.Stage;
010    
011    /**
012     * A multi-purpose generic event containing an arbitrary object as a message, the
013     * stage from which the event originates, as well as an optional arbitrary
014     * informational object, either of which may be <code>null</code>.
015     * 
016     * @author whoschek@lbl.gov, modified by kberket@lbl.gov
017     * @author $Author: hoschek3 $
018     * @version $Revision: 1.4 $, $Date: 2004/07/27 05:08:08 $
019     */
020    
021    public class GenericCallbackEvent extends CallbackEvent {
022    
023        protected Object msg; // the message to communicate
024        protected Object info; // optional further information such as "write",
025        // "read", a URL, etc.
026    
027        public GenericCallbackEvent(Stage source, Object msg) {
028            this(source, msg, null);
029        }
030    
031        public GenericCallbackEvent(Stage source, Object msg, Object info) {
032            super(source);
033            this.msg = msg;
034            this.info = info;
035        }
036    
037        public Object getMessage() {
038            return this.msg;
039        }
040    
041        public Object getInfo() {
042            return this.info;
043        }
044    
045        public String toString() {
046            return super.toString() +
047                    //(getMessage() != null ? ", msg.type=" + getMessage().getClass().getName() : "") +
048                    ", msg=" + getMessage() +
049                    (getInfo() != null ? ", info=" + getInfo() : "") +
050                    (getInfo() instanceof byte[] ? ", info.toString=" + new String((byte[]) this.getInfo()) : "");
051        }
052    }