3 * Copyright (C) 2006 David Roden
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 package de.todesbaum.jsite.application;
23 * Container for node information.
25 * @author David ‘Bombe’ Roden <bombe@freenetproject.org>
27 public class Node extends de.todesbaum.util.freenet.fcp2.Node {
29 /** The name of the node. */
30 protected String name;
33 * Creates a new node with the given hostname and the default port.
35 * @see de.todesbaum.util.freenet.fcp2.Node#DEFAULT_PORT
37 * The hostname of the new node
39 public Node(String hostname) {
40 this(hostname, DEFAULT_PORT);
44 * Creates a new node with the given hostname and port.
47 * The hostname of the new node
49 * The port of the new node
51 public Node(String hostname, int port) {
52 this(hostname, port, "");
56 * Creates a new node with the given hostname, port, and name.
59 * The hostname of the new node
61 * The port of the new node
63 * The name of the node
65 public Node(String hostname, int port, String name) {
66 super(hostname, port);
71 * Creates a new node that gets its settings from the given node.
76 public Node(Node node) {
77 this(node.getHostname(), node.getPort());
81 * Creates a new node from the given node, overwriting the name.
84 * The node to copy from
86 * The new name of the node
88 public Node(Node node, String name) {
89 this(node.getHostname(), node.getPort(), name);
93 * Sets the name of the node.
96 * The name of the node
98 public void setName(String name) {
103 * Returns the name of the node.
105 * @return The name of the node
107 public String getName() {
112 * Sets the hostname of the node.
115 * The hostname of the node
117 public void setHostname(String hostname) {
118 this.hostname = hostname;
122 * Sets the port of the node.
125 * The port of the node
127 public void setPort(int port) {
134 * A node is considered as being equal to this node its name, hostname, and
135 * port equal their counterparts in this node.
138 public boolean equals(Object o) {
139 if ((o == null) || !(o instanceof Node)) {
142 Node node = (Node) o;
143 return name.equals(node.name) && hostname.equals(node.hostname) && (port == node.port);
149 * The hashcode for a node is created from its name, its hostname, and its
153 public int hashCode() {
154 return name.hashCode() ^ hostname.hashCode() ^ port;
160 * Creates a textual representation of this node.
163 public String toString() {
164 return name + " (" + hostname + ":" + port + ")";