001 // Copyright 2004, 2005 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 015 package org.apache.tapestry.event; 016 017 import java.util.EventObject; 018 019 import org.apache.hivemind.util.Defense; 020 import org.apache.tapestry.IComponent; 021 022 /** 023 * Event which describes a change to a particular {@link IComponent}. 024 * 025 * @author Howard Ship 026 */ 027 028 public class ObservedChangeEvent extends EventObject 029 { 030 031 private static final long serialVersionUID = -7693394232554811975L; 032 033 private IComponent _component; 034 035 private String _propertyName; 036 037 private Object _newValue; 038 039 /** 040 * Creates the event. The new value must be null, or be a serializable 041 * object. (It is declared as Object as a concession to the Java 2 042 * collections framework, where the implementations are serializable but the 043 * interfaces (Map, List, etc.) don't extend Serializable ... so we wait 044 * until runtime to check). 045 * 046 * @param component 047 * The component (not necessarily a page) whose property changed. 048 * @param propertyName 049 * the name of the property which was changed. 050 * @param newValue 051 * The new value of the property. 052 * @throws IllegalArgumentException 053 * if propertyName is null, or if the new value is not 054 * serializable 055 */ 056 057 public ObservedChangeEvent(IComponent component, String propertyName, Object newValue) 058 { 059 super(component); 060 061 Defense.notNull(propertyName, "propertyName"); 062 063 _component = component; 064 _propertyName = propertyName; 065 _newValue = newValue; 066 } 067 068 public IComponent getComponent() 069 { 070 return _component; 071 } 072 073 public Object getNewValue() 074 { 075 return _newValue; 076 } 077 078 public String getPropertyName() 079 { 080 return _propertyName; 081 } 082 083 }