Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
EventTarget |
|
| 1.0;1 |
1 | // Copyright May 21, 2006 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 | package org.apache.tapestry.event; | |
15 | ||
16 | import java.util.Map; | |
17 | ||
18 | import org.apache.commons.lang.builder.ToStringBuilder; | |
19 | import org.apache.commons.lang.builder.ToStringStyle; | |
20 | ||
21 | ||
22 | /** | |
23 | * Represents a browser generated event "target". Most browser events will | |
24 | * have an event.target property, which is what this represents. | |
25 | * | |
26 | * @author jkuhnert | |
27 | */ | |
28 | public class EventTarget | |
29 | { | |
30 | private final Map _properties; | |
31 | ||
32 | /** | |
33 | * Creates a new target with an immutable set | |
34 | * of properties. | |
35 | * | |
36 | * @param properties The properties of the target. | |
37 | */ | |
38 | public EventTarget(Map properties) | |
39 | 0 | { |
40 | 0 | _properties = properties; |
41 | 0 | } |
42 | ||
43 | /** | |
44 | * Gets a target object property. (Could be things like "id" | |
45 | * for html dom nodes, etc..) | |
46 | * @param key The key of the property. | |
47 | * @return The property value, or null if it doesn't exist. | |
48 | */ | |
49 | public Object get(String key) | |
50 | { | |
51 | 0 | return _properties.get(key); |
52 | } | |
53 | ||
54 | public String toString() | |
55 | { | |
56 | 0 | return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE) |
57 | .append("properties", _properties) | |
58 | .toString(); | |
59 | } | |
60 | } |