X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fnet%2Fpterodactylus%2Fjsite%2Fcore%2FNode.java;h=b7bf63765cd98a4a69ba1c4a9f8542e52654b471;hb=34a047561daab16685702cfdf16716fc008106bd;hp=854a668df32c47db9c01a05f636240304ef50bfb;hpb=bcb9cebfa11ffbfee8ee8e5579edeed302e2d784;p=jSite2.git
diff --git a/src/net/pterodactylus/jsite/core/Node.java b/src/net/pterodactylus/jsite/core/Node.java
index 854a668..b7bf637 100644
--- a/src/net/pterodactylus/jsite/core/Node.java
+++ b/src/net/pterodactylus/jsite/core/Node.java
@@ -19,13 +19,27 @@
package net.pterodactylus.jsite.core;
+import java.beans.PropertyChangeListener;
+
+import net.pterodactylus.util.beans.AbstractBean;
+
/**
- * 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$
*/
-public class Node {
+public class Node extends AbstractBean {
+
+ /** 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;
@@ -36,8 +50,9 @@ public class Node {
/** The port number of the node. */
private int port;
- /** Whether the node is running on the same machine as jSite. */
- private boolean sameMachine;
+ //
+ // EVENT MANAGEMENT
+ //
/**
* Returns the user-given name of the node.
@@ -55,7 +70,9 @@ public class Node {
* The name of the node
*/
public void setName(String name) {
+ String oldName = this.name;
this.name = name;
+ fireIfPropertyChanged(PROPERTY_NAME, oldName, name);
}
/**
@@ -74,7 +91,9 @@ public class Node {
* The hostname of the node
*/
public void setHostname(String hostname) {
+ String oldHostname = this.hostname;
this.hostname = hostname;
+ fireIfPropertyChanged(PROPERTY_HOSTNAME, oldHostname, hostname);
}
/**
@@ -93,28 +112,9 @@ public class Node {
* The port number of the node
*/
public void setPort(int port) {
+ int oldPort = this.port;
this.port = port;
- }
-
- /**
- * Returns whether this node is running on the same machine as jSite.
- *
- * @return the sameMachine true
if, and only if, the node is
- * running on the same machine as jSite
- */
- public boolean isSameMachine() {
- return sameMachine;
- }
-
- /**
- * Sets whether this node is running on the same machine as jSite.
- *
- * @param sameMachine
- * true
if the node is running on the same machine
- * as jSite, false
otherwise
- */
- public void setSameMachine(boolean sameMachine) {
- this.sameMachine = sameMachine;
+ fireIfPropertyChanged(PROPERTY_PORT, oldPort, port);
}
/**