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