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