001 // Copyright May 21, 2006 The Apache Software Foundation 002 // 003 // Licensed under the Apache License, Version 2.0 (the "License"); 004 // you may not use this file except in compliance with the License. 005 // You may obtain a copy of the License at 006 // 007 // http://www.apache.org/licenses/LICENSE-2.0 008 // 009 // Unless required by applicable law or agreed to in writing, software 010 // distributed under the License is distributed on an "AS IS" BASIS, 011 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 012 // See the License for the specific language governing permissions and 013 // limitations under the License. 014 package org.apache.tapestry.event; 015 016 import java.util.Map; 017 018 import org.apache.commons.lang.builder.ToStringBuilder; 019 import org.apache.commons.lang.builder.ToStringStyle; 020 021 022 /** 023 * Represents a browser generated event "target". Most browser events will 024 * have an event.target property, which is what this represents. 025 * 026 * @author jkuhnert 027 */ 028 public class EventTarget 029 { 030 private final Map _properties; 031 032 /** 033 * Creates a new target with an immutable set 034 * of properties. 035 * 036 * @param properties The properties of the target. 037 */ 038 public EventTarget(Map properties) 039 { 040 _properties = properties; 041 } 042 043 /** 044 * Gets a target object property. (Could be things like "id" 045 * for html dom nodes, etc..) 046 * @param key The key of the property. 047 * @return The property value, or null if it doesn't exist. 048 */ 049 public Object get(String key) 050 { 051 return _properties.get(key); 052 } 053 054 public String toString() 055 { 056 return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE) 057 .append("properties", _properties) 058 .toString(); 059 } 060 }