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