KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > tapestry > event > ObservedChangeEvent


1 // Copyright 2004, 2005 The Apache Software Foundation
2
//
3
// Licensed under the Apache License, Version 2.0 (the "License");
4
// you may not use this file except in compliance with the License.
5
// You may obtain a copy of the License at
6
//
7
// http://www.apache.org/licenses/LICENSE-2.0
8
//
9
// Unless required by applicable law or agreed to in writing, software
10
// distributed under the License is distributed on an "AS IS" BASIS,
11
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
// See the License for the specific language governing permissions and
13
// limitations under the License.
14

15 package org.apache.tapestry.event;
16
17 import java.util.EventObject JavaDoc;
18
19 import org.apache.hivemind.util.Defense;
20 import org.apache.tapestry.IComponent;
21
22 /**
23  * Event which describes a change to a particular {@link IComponent}.
24  *
25  * @author Howard Ship
26  */

27
28 public class ObservedChangeEvent extends EventObject JavaDoc
29 {
30     private IComponent _component;
31
32     private String JavaDoc _propertyName;
33
34     private Object JavaDoc _newValue;
35
36     /**
37      * Creates the event. The new value must be null, or be a serializable object. (It is declared
38      * as Object as a concession to the Java 2 collections framework, where the implementations are
39      * serializable but the interfaces (Map, List, etc.) don't extend Serializable ... so we wait
40      * until runtime to check).
41      *
42      * @param component
43      * The component (not necessarily a page) whose property changed.
44      * @param propertyName
45      * the name of the property which was changed.
46      * @param newValue
47      * The new value of the property.
48      * @throws IllegalArgumentException
49      * if propertyName is null, or if the new value is not serializable
50      */

51
52     public ObservedChangeEvent(IComponent component, String JavaDoc propertyName, Object JavaDoc newValue)
53     {
54         super(component);
55
56         Defense.notNull(propertyName, "propertyName");
57
58         _component = component;
59         _propertyName = propertyName;
60         _newValue = newValue;
61     }
62
63     public IComponent getComponent()
64     {
65         return _component;
66     }
67
68     public Object JavaDoc getNewValue()
69     {
70         return _newValue;
71     }
72
73     public String JavaDoc getPropertyName()
74     {
75         return _propertyName;
76     }
77
78 }
Popular Tags