org/codehaus/griffon/runtime/core/AbstractObservable.java

`AbstractObservable.java`
`01 /* 02 * Copyright 2009-2012 the original author or authors. 03 * 04 * Licensed under the Apache License, Version 2.0 (the "License"); 05 * you may not use this file except in compliance with the License. 06 * You may obtain a copy of the License at 07 * 08 * http://www.apache.org/licenses/LICENSE-2.0 09 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 package org.codehaus.griffon.runtime.core; 17 18 import griffon.core.Observable; 19 20 import java.beans.PropertyChangeEvent; 21 import java.beans.PropertyChangeListener; 22 import java.beans.PropertyChangeSupport; 23 24 /** 25 * @author Andres Almiray 26 * @since 0.9.1 27 */ 28 public abstract class AbstractObservable implements Observable { 29 protected PropertyChangeSupport pcs; 30 31 public AbstractObservable() { 32 pcs = new PropertyChangeSupport(this); 33 } 34 35 public void addPropertyChangeListener(PropertyChangeListener listener) { 36 pcs.addPropertyChangeListener(listener); 37 } 38 39 public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener) { 40 pcs.addPropertyChangeListener(propertyName, listener); 41 } 42 43 public void removePropertyChangeListener(PropertyChangeListener listener) { 44 pcs.removePropertyChangeListener(listener); 45 } 46 47 public void removePropertyChangeListener(String propertyName, PropertyChangeListener listener) { 48 pcs.removePropertyChangeListener(propertyName, listener); 49 } 50 51 public PropertyChangeListener[] getPropertyChangeListeners() { 52 return pcs.getPropertyChangeListeners(); 53 } 54 55 public PropertyChangeListener[] getPropertyChangeListeners(String propertyName) { 56 return pcs.getPropertyChangeListeners(propertyName); 57 } 58 59 protected void firePropertyChange(PropertyChangeEvent event) { 60 pcs.firePropertyChange(event); 61 } 62 63 protected void firePropertyChange(String propertyName, Object oldValue, Object newValue) { 64 pcs.firePropertyChange(propertyName, oldValue, newValue); 65 } 66 }`