01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17:
18: package java.util;
19:
20: import java.io.Serializable;
21:
22: /**
23: * EventObjects represent events. Typically applications subclass this class to
24: * add event specific information.
25: *
26: * @see EventListener
27: */
28: public class EventObject implements Serializable {
29:
30: private static final long serialVersionUID = 5516075349620653480L;
31:
32: /**
33: * The event source.
34: */
35: protected transient Object source;
36:
37: /**
38: * Constructs a new instance of this class.
39: *
40: * @param source
41: * the object which fired the event
42: */
43: public EventObject(Object source) {
44: if (source != null) {
45: this .source = source;
46: } else {
47: throw new IllegalArgumentException();
48: }
49: }
50:
51: /**
52: * Answers the event source.
53: *
54: * @return the object which fired the event
55: */
56: public Object getSource() {
57: return source;
58: }
59:
60: /**
61: * Answers the string representation of this EventObject.
62: *
63: * @return the string representation of this EventObject
64: */
65: @Override
66: public String toString() {
67: return getClass().getName() + "[source=" + source + ']'; //$NON-NLS-1$
68: }
69: }
|