3 * Copyright © 2008 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 net.pterodactylus.jsite.core;
22 import java.beans.PropertyChangeListener;
24 import net.pterodactylus.util.beans.AbstractBean;
27 * Container for a Freenet node. A Node is capable of notifying
28 * {@link PropertyChangeListener}s if any of the contained properties change.
30 * @author David ‘Bombe’ Roden <bombe@freenetproject.org>
32 public class Node extends AbstractBean {
34 /** Name of the “name” property. */
35 public static final String PROPERTY_NAME = "name";
37 /** Name of the “hostname” property. */
38 public static final String PROPERTY_HOSTNAME = "hostname";
40 /** Name of the “port” property. */
41 public static final String PROPERTY_PORT = "port";
46 /** The name of the node. */
49 /** The hostname of the node. */
50 private String hostname;
52 /** The port number of the node. */
56 * Returns the internal ID of the node.
58 * @return The internal ID of the node
65 * Sets the internal ID of the node.
68 * The internal ID of the node
70 void setId(String id) {
75 * Returns the user-given name of the node.
77 * @return The name of the node
79 public String getName() {
84 * Sets the user-given name of the node.
87 * The name of the node
89 public void setName(String name) {
90 String oldName = this.name;
92 fireIfPropertyChanged(PROPERTY_NAME, oldName, name);
96 * Returns the hostname of the node.
98 * @return The hostname of the node
100 public String getHostname() {
105 * Sets the hostname of the node.
108 * The hostname of the node
110 public void setHostname(String hostname) {
111 String oldHostname = this.hostname;
112 this.hostname = hostname;
113 fireIfPropertyChanged(PROPERTY_HOSTNAME, oldHostname, hostname);
117 * Returns the port number of the node.
119 * @return The port number of the node
121 public int getPort() {
126 * Sets the port number of the node.
129 * The port number of the node
131 public void setPort(int port) {
132 int oldPort = this.port;
134 fireIfPropertyChanged(PROPERTY_PORT, oldPort, port);
141 public String toString() {
142 return name + " (" + hostname + ((port == 9481) ? ("") : (":" + port)) + ")";