EventObject.java |
1 /* 2 * %W% %E% 3 * 4 * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. 5 * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. 6 */ 7 8 package java.util; 9 10 /** 11 * <p> 12 * The root class from which all event state objects shall be derived. 13 * <p> 14 * All Events are constructed with a reference to the object, the "source", 15 * that is logically deemed to be the object upon which the Event in question 16 * initially occurred upon. 17 * 18 * @since JDK1.1 19 */ 20 21 public class EventObject implements java.io.Serializable { 22 23 private static final long serialVersionUID = 5516075349620653480L; 24 25 /** 26 * The object on which the Event initially occurred. 27 */ 28 protected transient Object source; 29 30 /** 31 * Constructs a prototypical Event. 32 * 33 * @param source The object on which the Event initially occurred. 34 * @exception IllegalArgumentException if source is null. 35 */ 36 public EventObject(Object source) { 37 if (source == null) 38 throw new IllegalArgumentException("null source"); 39 40 this.source = source; 41 } 42 43 /** 44 * The object on which the Event initially occurred. 45 * 46 * @return The object on which the Event initially occurred. 47 */ 48 public Object getSource() { 49 return source; 50 } 51 52 /** 53 * Returns a String representation of this EventObject. 54 * 55 * @return A a String representation of this EventObject. 56 */ 57 public String toString() { 58 return getClass().getName() + "[source=" + source + "]"; 59 } 60 } 61