package net.pterodactylus.jsite.core;
-import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
+import net.pterodactylus.util.beans.AbstractBean;
import net.pterodactylus.util.beans.Comparer;
/**
* @author David ‘Bombe’ Roden <bombe@freenetproject.org>
* @version $Id$
*/
-public class Node {
-
- /** Property change listeners. */
- private final List<PropertyChangeListener> propertyChangeListeners = Collections.synchronizedList(new ArrayList<PropertyChangeListener>());
+public class Node extends AbstractBean {
/** Name of the “name” property. */
public static final String PROPERTY_NAME = "name";
//
/**
- * Adds a property change listener.
- *
- * @param propertyChangeListener
- * The property change listener to add
- */
- public void addPropertyChangeListener(PropertyChangeListener propertyChangeListener) {
- propertyChangeListeners.add(propertyChangeListener);
- }
-
- /**
- * Removes a property change listener.
- *
- * @param propertyChangeListener
- * The property change listener to remove
- */
- public void removePropertyChangeListener(PropertyChangeListener propertyChangeListener) {
- propertyChangeListeners.remove(propertyChangeListener);
- }
-
- /**
- * Notifies all listeners that a property has changed.
- *
- * @param property
- * The name of the property
- * @param oldValue
- * The old value of the property
- * @param newValue
- * The new value of the property
- */
- private void firePropertyChange(String property, Object oldValue, Object newValue) {
- PropertyChangeEvent propertyChangeEvent = new PropertyChangeEvent(this, property, oldValue, newValue);
- for (PropertyChangeListener propertyChangeListener: propertyChangeListeners) {
- propertyChangeListener.propertyChange(propertyChangeEvent);
- }
-
- }
-
- //
- // ACCESSORS
- //
-
- /**
* Returns the user-given name of the node.
*
* @return The name of the node
package net.pterodactylus.jsite.core;
-import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
+import net.pterodactylus.util.beans.AbstractBean;
import net.pterodactylus.util.beans.Comparer;
/**
* @author David ‘Bombe’ Roden <bombe@freenetproject.org>
* @version $Id$
*/
-public class Project {
-
- /** Property change listeners. */
- private final List<PropertyChangeListener> propertyChangeListeners = Collections.synchronizedList(new ArrayList<PropertyChangeListener>());
+public class Project extends
+AbstractBean {
/** Name of the “name” property. */
public static final String PROPERTY_NAME = "name";
//
/**
- * Adds a property change listener.
- *
- * @param propertyChangeListener
- * The property change listener to add
- */
- public void addPropertyChangeListener(PropertyChangeListener propertyChangeListener) {
- propertyChangeListeners.add(propertyChangeListener);
- }
-
- /**
- * Removes a property change listener.
- *
- * @param propertyChangeListener
- * The property change listener to remove
- */
- public void removePropertyChangeListener(PropertyChangeListener propertyChangeListener) {
- propertyChangeListeners.remove(propertyChangeListener);
- }
-
- /**
- * Notifies all listeners that a property has changed.
- *
- * @param property
- * The name of the property
- * @param oldValue
- * The old value of the property
- * @param newValue
- * The new value of the property
- */
- private void firePropertyChange(String property, Object oldValue, Object newValue) {
- PropertyChangeEvent propertyChangeEvent = new PropertyChangeEvent(this, property, oldValue, newValue);
- for (PropertyChangeListener propertyChangeListener: propertyChangeListeners) {
- propertyChangeListener.propertyChange(propertyChangeEvent);
- }
-
- }
-
- //
- // ACCESSORS
- //
-
- /**
* Returns the name of the project.
*
* @return The name of the project
package net.pterodactylus.jsite.core;
-import java.beans.PropertyChangeEvent;
-import java.beans.PropertyChangeListener;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
+import net.pterodactylus.util.beans.AbstractBean;
import net.pterodactylus.util.beans.Comparer;
/**
* @author David ‘Bombe’ Roden <bombe@freenetproject.org>
* @version $Id$
*/
-public class Request {
+public class Request extends
+AbstractBean {
/**
* The type of a request.
/** Name of the “total finalized” property. */
public static final String PROPERTY_TOTAL_FINALIZED = "totalFinalized";
- /** Property change listeners. */
- private final List<PropertyChangeListener> propertyChangeListeners = Collections.synchronizedList(new ArrayList<PropertyChangeListener>());
-
/** The node the request belongs to. */
private final Node node;
//
/**
- * Adds a property change listener.
- *
- * @param propertyChangeListener
- * The property change listener to add
- */
- public void addPropertyChangeListener(PropertyChangeListener propertyChangeListener) {
- propertyChangeListeners.add(propertyChangeListener);
- }
-
- /**
- * Removes a property change listener.
- *
- * @param propertyChangeListener
- * The property change listener to remove
- */
- public void removePropertyChangeListener(PropertyChangeListener propertyChangeListener) {
- propertyChangeListeners.remove(propertyChangeListener);
- }
-
- /**
- * Notifies all listeners that a property has changed.
- *
- * @param property
- * The name of the property
- * @param oldValue
- * The old value of the property
- * @param newValue
- * The new value of the property
- */
- private void firePropertyChange(String property, Object oldValue, Object newValue) {
- PropertyChangeEvent propertyChangeEvent = new PropertyChangeEvent(this, property, oldValue, newValue);
- for (PropertyChangeListener propertyChangeListener: propertyChangeListeners) {
- propertyChangeListener.propertyChange(propertyChangeEvent);
- }
- }
-
- //
- // ACCESSORS
- //
-
- /**
* Returns the node the request belongs to.
*
* @return The node the request belongs to
--- /dev/null
+/*
+ * jSite2 - AbstractBean.java
+ * Copyright © 2008 David Roden
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+package net.pterodactylus.util.beans;
+
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+/**
+ * Abstract bean super class that contains property change listener management.
+ *
+ * @author David ‘Bombe’ Roden <bombe@freenetproject.org>
+ * @version $Id$
+ */
+public class AbstractBean {
+
+ /** Property change listeners. */
+ private final List<PropertyChangeListener> propertyChangeListeners = Collections.synchronizedList(new ArrayList<PropertyChangeListener>());
+
+ /**
+ * Adds a property change listener.
+ *
+ * @param propertyChangeListener
+ * The property change listener to add
+ */
+ public void addPropertyChangeListener(PropertyChangeListener propertyChangeListener) {
+ propertyChangeListeners.add(propertyChangeListener);
+ }
+
+ /**
+ * Removes a property change listener.
+ *
+ * @param propertyChangeListener
+ * The property change listener to remove
+ */
+ public void removePropertyChangeListener(PropertyChangeListener propertyChangeListener) {
+ propertyChangeListeners.remove(propertyChangeListener);
+ }
+
+ /**
+ * Notifies all listeners that a property has changed.
+ *
+ * @param property
+ * The name of the property
+ * @param oldValue
+ * The old value of the property
+ * @param newValue
+ * The new value of the property
+ */
+ protected void firePropertyChange(String property, Object oldValue, Object newValue) {
+ PropertyChangeEvent propertyChangeEvent = new PropertyChangeEvent(this, property, oldValue, newValue);
+ for (PropertyChangeListener propertyChangeListener: propertyChangeListeners) {
+ propertyChangeListener.propertyChange(propertyChangeEvent);
+ }
+
+ }
+
+}