KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > util > property > PropertyEvent


1 /*
2   * JBoss, Home of Professional Open Source
3   * Copyright 2005, JBoss Inc., and individual contributors as indicated
4   * by the @authors tag. See the copyright.txt in the distribution for a
5   * full listing of individual contributors.
6   *
7   * This is free software; you can redistribute it and/or modify it
8   * under the terms of the GNU Lesser General Public License as
9   * published by the Free Software Foundation; either version 2.1 of
10   * the License, or (at your option) any later version.
11   *
12   * This software is distributed in the hope that it will be useful,
13   * but WITHOUT ANY WARRANTY; without even the implied warranty of
14   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15   * Lesser General Public License for more details.
16   *
17   * You should have received a copy of the GNU Lesser General Public
18   * License along with this software; if not, write to the Free
19   * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20   * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21   */

22 package org.jboss.util.property;
23
24 import java.util.EventObject JavaDoc;
25
26 import org.jboss.util.NullArgumentException;
27
28 /**
29  * A property event.
30  *
31  * @version <tt>$Revision: 1958 $</tt>
32  * @author <a HREF="mailto:jason@planet57.com">Jason Dillon</a>
33  */

34 public class PropertyEvent
35    extends EventObject JavaDoc
36 {
37    /** Property name. */
38    protected final String JavaDoc name;
39
40    /** Property value. */
41    protected final String JavaDoc value;
42
43    /**
44     * Construct a new <tt>PropertyEvent</tt>.
45     *
46     * @param source The source of the event.
47     * @param name The property name effected.
48     * @param value The value of the property effected.
49     *
50     * @throws NullArgumentException Name or source is <tt>null</tt>.
51     */

52    public PropertyEvent(final Object JavaDoc source,
53                         final String JavaDoc name,
54                         final String JavaDoc value)
55    {
56       super(source);
57
58       if (name == null)
59          throw new NullArgumentException("name");
60       // value can be null
61

62       this.name = name;
63       this.value = value;
64    }
65
66    /**
67     * Construct a new <tt>PropertyEvent</tt>.
68     *
69     * @param source The source of the event.
70     * @param name The property name effected.
71     *
72     * @throws NullArgumentException Name or source is <tt>null</tt>.
73     */

74    public PropertyEvent(Object JavaDoc source, String JavaDoc name) {
75       this(source, name, null);
76    }
77
78    /**
79     * Get the name of the property that is effected.
80     *
81     * @return Property name.
82     */

83    public final String JavaDoc getPropertyName() {
84       return name;
85    }
86
87    /**
88     * Get the value of the property that is effected.
89     *
90     * @return The value of the property that is effected or <tt>null</tt>.
91     */

92    public final String JavaDoc getPropertyValue() {
93       return value;
94    }
95
96    /**
97     * Return a string representation of this event.
98     *
99     * @return A string representation of this event.
100     */

101    public String JavaDoc toString() {
102       return super.toString() +
103          "{ name=" + name +
104          ", value=" + value +
105          " }";
106    }
107 }
108
Popular Tags