Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
ObservedChangeEvent |
|
| 1.0;1 |
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; | |
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 | |
29 | { | |
30 | ||
31 | private static final long serialVersionUID = -7693394232554811975L; | |
32 | ||
33 | private IComponent _component; | |
34 | ||
35 | private String _propertyName; | |
36 | ||
37 | private Object _newValue; | |
38 | ||
39 | /** | |
40 | * Creates the event. The new value must be null, or be a serializable | |
41 | * object. (It is declared as Object as a concession to the Java 2 | |
42 | * collections framework, where the implementations are serializable but the | |
43 | * interfaces (Map, List, etc.) don't extend Serializable ... so we wait | |
44 | * until runtime to check). | |
45 | * | |
46 | * @param component | |
47 | * The component (not necessarily a page) whose property changed. | |
48 | * @param propertyName | |
49 | * the name of the property which was changed. | |
50 | * @param newValue | |
51 | * The new value of the property. | |
52 | * @throws IllegalArgumentException | |
53 | * if propertyName is null, or if the new value is not | |
54 | * serializable | |
55 | */ | |
56 | ||
57 | public ObservedChangeEvent(IComponent component, String propertyName, Object newValue) | |
58 | { | |
59 | 0 | super(component); |
60 | ||
61 | 0 | Defense.notNull(propertyName, "propertyName"); |
62 | ||
63 | 0 | _component = component; |
64 | 0 | _propertyName = propertyName; |
65 | 0 | _newValue = newValue; |
66 | 0 | } |
67 | ||
68 | public IComponent getComponent() | |
69 | { | |
70 | 0 | return _component; |
71 | } | |
72 | ||
73 | public Object getNewValue() | |
74 | { | |
75 | 0 | return _newValue; |
76 | } | |
77 | ||
78 | public String getPropertyName() | |
79 | { | |
80 | 0 | return _propertyName; |
81 | } | |
82 | ||
83 | } |