X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fde%2Ftodesbaum%2Fjsite%2Fapplication%2FNode.java;h=65dbad0dac05dca0af5a7b01b6f01cef20b20a15;hb=a6bda7a82aa1b2cfd0313fb28d3dcca68ca516c5;hp=838346e8d483d992dbeb4c8fd1157baedc3a0383;hpb=e4f461213da0e30faf9e9eb2e97626abff320618;p=jSite.git diff --git a/src/de/todesbaum/jsite/application/Node.java b/src/de/todesbaum/jsite/application/Node.java index 838346e..65dbad0 100644 --- a/src/de/todesbaum/jsite/application/Node.java +++ b/src/de/todesbaum/jsite/application/Node.java @@ -1,6 +1,5 @@ /* - * jSite-0.7 - - * Copyright (C) 2006 David Roden + * jSite - Node.java - Copyright © 2006–2011 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 @@ -20,64 +19,120 @@ package de.todesbaum.jsite.application; /** - * @author David Roden <droden@gmail.com> - * @version $Id$ + * Container for node information. + * + * @author David ‘Bombe’ Roden <bombe@freenetproject.org> */ public class Node extends de.todesbaum.util.freenet.fcp2.Node { + /** The name of the node. */ protected String name; /** + * Creates a new node with the given hostname and the default port. + * + * @see de.todesbaum.util.freenet.fcp2.Node#DEFAULT_PORT * @param hostname + * The hostname of the new node */ public Node(String hostname) { this(hostname, DEFAULT_PORT); } /** + * Creates a new node with the given hostname and port. + * * @param hostname + * The hostname of the new node * @param port + * The port of the new node */ public Node(String hostname, int port) { this(hostname, port, ""); } + /** + * Creates a new node with the given hostname, port, and name. + * + * @param hostname + * The hostname of the new node + * @param port + * The port of the new node + * @param name + * The name of the node + */ public Node(String hostname, int port, String name) { super(hostname, port); this.name = name; } + /** + * Creates a new node that gets its settings from the given node. + * + * @param node + * The node to copy + */ public Node(Node node) { this(node.getHostname(), node.getPort()); } + /** + * Creates a new node from the given node, overwriting the name. + * + * @param node + * The node to copy from + * @param name + * The new name of the node + */ public Node(Node node, String name) { this(node.getHostname(), node.getPort(), name); } /** + * Sets the name of the node. + * * @param name - * The name to set. + * The name of the node */ public void setName(String name) { this.name = name; } /** - * @return Returns the name. + * Returns the name of the node. + * + * @return The name of the node */ public String getName() { return name; } + /** + * Sets the hostname of the node. + * + * @param hostname + * The hostname of the node + */ public void setHostname(String hostname) { this.hostname = hostname; } + /** + * Sets the port of the node. + * + * @param port + * The port of the node + */ public void setPort(int port) { this.port = port; } - + + /** + * {@inheritDoc} + *

+ * A node is considered as being equal to this node its name, hostname, and + * port equal their counterparts in this node. + */ @Override public boolean equals(Object o) { if ((o == null) || !(o instanceof Node)) { @@ -86,12 +141,23 @@ public class Node extends de.todesbaum.util.freenet.fcp2.Node { Node node = (Node) o; return name.equals(node.name) && hostname.equals(node.hostname) && (port == node.port); } - + + /** + * {@inheritDoc} + *

+ * The hashcode for a node is created from its name, its hostname, and its + * port. + */ @Override public int hashCode() { return name.hashCode() ^ hostname.hashCode() ^ port; } + /** + * {@inheritDoc} + *

+ * Creates a textual representation of this node. + */ @Override public String toString() { return name + " (" + hostname + ":" + port + ")";