import java.util.List;
/**
- * Container for a Freenet node.
+ * Container for a Freenet node. A Node is capable of notifying
+ * {@link PropertyChangeListener}s if any of the contained properties change.
*
* @author David ‘Bombe’ Roden <bombe@freenetproject.org>
* @version $Id$
/** Property change listeners. */
private final List<PropertyChangeListener> propertyChangeListeners = Collections.synchronizedList(new ArrayList<PropertyChangeListener>());
+ /** Name of the “name” property. */
+ public static final String PROPERTY_NAME = "name";
+
+ /** Name of the “hostname” property. */
+ public static final String PROPERTY_HOSTNAME = "hostname";
+
+ /** Name of the “port” property. */
+ public static final String PROPERTY_PORT = "port";
+
/** The name of the node. */
private String name;
String oldName = this.name;
this.name = name;
if (((oldName != null) && (name == null)) || ((oldName == null) && (name != null)) || ((name != null) && !name.equals(oldName))) {
- firePropertyChange("name", oldName, name);
+ firePropertyChange(PROPERTY_NAME, oldName, name);
}
}
String oldHostname = this.hostname;
this.hostname = hostname;
if (((oldHostname != null) && (hostname == null)) || ((oldHostname == null) && (hostname != null)) || ((hostname != null) && !hostname.equals(oldHostname))) {
- firePropertyChange("hostname", oldHostname, hostname);
+ firePropertyChange(PROPERTY_HOSTNAME, oldHostname, hostname);
}
}
int oldPort = this.port;
this.port = port;
if (oldPort != port) {
- firePropertyChange("port", oldPort, port);
+ firePropertyChange(PROPERTY_PORT, oldPort, port);
}
}
-// /**
-// * {@inheritDoc} Two Node objects are considered equal if their hostnames
-// * and their port numbers are equal.
-// */
-// @Override
-// public boolean equals(Object object) {
-// if ((object == null) || !(object instanceof Node)) {
-// return false;
-// }
-// Node node = (Node) object;
-// return hostname.equals(node.hostname) && port == node.port;
-// }
-
-// /**
-// * {@inheritDoc}
-// */
-// @Override
-// public int hashCode() {
-// return hostname.hashCode() ^ (-1 - port);
-// }
-
/**
* {@inheritDoc}
*/