2 * jSite2 - NodeHello.java -
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.fcp;
23 * Some convenience methods for parsing a “NodeHello” message from the node.
25 * @author <a href="mailto:dr@ina-germany.de">David Roden</a>
28 public class NodeHello extends BaseMessage {
31 * Createa a new “NodeHello” message that wraps the received message.
33 * @param receivedMessage
34 * The received FCP message
36 NodeHello(FcpMessage receivedMessage) {
37 super(receivedMessage);
41 * Returns the build of the node. This may not be a number but also a string
42 * like “@custom@” in case you built the node yourself.
44 * @return The build of the node
46 public String getBuild() {
47 return getField("Build");
51 * Returns the build number of the node. This may not be a number but also a
52 * string like “@custom@” in case you built the node yourself.
54 * @return The build number of the node, or <code>-1</code> if the build
55 * number could not be determined
57 public int getBuildNumber() {
58 return FcpUtils.safeParseInt(getBuild());
62 * Returns the number of compression codecs.
64 * @return The number of compression codecs
66 public String getCompressionCodecs() {
67 return getField("CompressionCodecs");
71 * Returns the number of compression codecs.
73 * @return The number of compression codecs, or <code>-1</code> if the
74 * number of compression codecs could not be determined
76 public int getCompressionCodecsNumber() {
77 return FcpUtils.safeParseInt(getCompressionCodecs());
81 * Returns the unique connection identifier.
83 * @return The connection identifier
85 public String getConnectionIdentifier() {
86 return getField("ConnectionIdentifier");
90 * Returns the build of the external library file.
92 * @return The build of the external library file
94 public String getExtBuild() {
95 return getField("ExtBuild");
99 * Returns the build number of the external library file.
101 * @return The build number of the external library file, or <code>-1</code>
102 * if the build number could not be determined
104 public int getExtBuildNumber() {
105 return FcpUtils.safeParseInt(getExtBuild());
109 * Returns the revision of the external library file.
111 * @return The revision of the external library file
113 public String getExtRevision() {
114 return getField("ExtRevision");
118 * Returns the revision number of the external library file.
120 * @return The revision number of the external library file, or
121 * <code>-1</code> if the revision number could not be determined
123 public int getExtRevisionNumber() {
124 return FcpUtils.safeParseInt(getExtRevision());
128 * Returns the FCP version the node speaks.
130 * @return The FCP version the node speaks
132 public String getFCPVersion() {
133 return getField("FCPVersion");
137 * Returns the make of the node, e.g. “Fred” (freenet reference
140 * @return The make of the node
142 public String getNode() {
143 return getField("Node");
147 * Returns the language of the node as 2-letter code, e.g. “en” or “de”.
149 * @return The language of the node
151 public String getNodeLanguage() {
152 return getField("NodeLanguage");
156 * Returns the revision of the node.
158 * @return The revision of the node
160 public String getRevision() {
161 return getField("Revision");
165 * Returns the revision number of the node.
167 * @return The revision number of the node, or <code>-1</code> if the
168 * revision number coult not be determined
170 public int getRevisionNumber() {
171 return FcpUtils.safeParseInt(getRevision());
175 * Returns whether the node is currently is testnet mode.
177 * @return <code>true</code> if the node is currently in testnet mode,
178 * <code>false</code> otherwise
180 public boolean getTestnet() {
181 return Boolean.valueOf(getField("Testnet"));
185 * Returns the version of the node.
187 * @return The version of the node
189 public String getVersion() {
190 return getField("Version");