X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fnet%2Fpterodactylus%2Fjsite%2Fcore%2FNode.java;h=b632eea859ef3e6ceaee76f1d75ccde567dfbe28;hb=b232aebb9732be0bb6b6252c57bca77836a9298b;hp=183a9165584d4e70f46d698c06df35ed66fa56a5;hpb=cf127faffabd3f07b0acc6de9ea746059d571b56;p=jSite2.git diff --git a/src/net/pterodactylus/jsite/core/Node.java b/src/net/pterodactylus/jsite/core/Node.java index 183a916..b632eea 100644 --- a/src/net/pterodactylus/jsite/core/Node.java +++ b/src/net/pterodactylus/jsite/core/Node.java @@ -21,7 +21,9 @@ package net.pterodactylus.jsite.core; import java.beans.PropertyChangeListener; +import net.pterodactylus.jsite.util.IdGenerator; import net.pterodactylus.util.beans.AbstractBean; +import net.pterodactylus.util.number.Hex; /** * Container for a Freenet node. A Node is capable of notifying @@ -40,6 +42,9 @@ public class Node extends AbstractBean { /** Name of the “port” property. */ public static final String PROPERTY_PORT = "port"; + /** Internal ID. */ + private String id; + /** The name of the node. */ private String name; @@ -49,9 +54,31 @@ public class Node extends AbstractBean { /** The port number of the node. */ private int port; - // - // EVENT MANAGEMENT - // + /** + * Creates a new node. + */ + public Node() { + id = Hex.toHex(IdGenerator.generateId()); + } + + /** + * Returns the internal ID of the node. + * + * @return The internal ID of the node + */ + String getId() { + return id; + } + + /** + * Sets the internal ID of the node. + * + * @param id + * The internal ID of the node + */ + void setId(String id) { + this.id = id; + } /** * Returns the user-given name of the node. @@ -121,7 +148,7 @@ public class Node extends AbstractBean { */ @Override public String toString() { - return name + " (" + hostname + ((port == 9481) ? ("") : (":" + port)) + ")"; + return getClass().getName() + "[name=" + name + ",hostname=" + hostname + ",port=" + port + "]"; } }