2 * jFCPlib - NodeHello.java - Copyright © 2008 David Roden
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 package net.pterodactylus.fcp;
22 * Some convenience methods for parsing a “NodeHello” message from the node.
24 * @author David ‘Bombe’ Roden <bombe@freenetproject.org>
26 public class NodeHello extends BaseMessage {
29 * Createa a new “NodeHello” message that wraps the received message.
31 * @param receivedMessage
32 * The received FCP message
34 public NodeHello(FcpMessage receivedMessage) {
35 super(receivedMessage);
39 * Returns the build of the node. This may not be a number but also a
40 * string like “@custom@” in case you built the node yourself.
42 * @return The build of the node
44 public String getBuild() {
45 return getField("Build");
49 * Returns the build number of the node. This may not be a number but also
50 * a string like “@custom@” in case you built the node yourself.
52 * @return The build number of the node, or <code>-1</code> if the build
53 * number could not be determined
55 public int getBuildNumber() {
56 return FcpUtils.safeParseInt(getBuild());
60 * Returns the number of compression codecs.
62 * @return The number of compression codecs
64 public String getCompressionCodecs() {
65 return getField("CompressionCodecs");
69 * Returns the number of compression codecs.
71 * @return The number of compression codecs, or <code>-1</code> if the
72 * number of compression codecs could not be determined
74 public int getCompressionCodecsNumber() {
75 return FcpUtils.safeParseInt(getCompressionCodecs());
79 * Returns the unique connection identifier.
81 * @return The connection identifier
83 public String getConnectionIdentifier() {
84 return getField("ConnectionIdentifier");
88 * Returns the build of the external library file.
90 * @return The build of the external library file
92 public String getExtBuild() {
93 return getField("ExtBuild");
97 * Returns the build number of the external library file.
99 * @return The build number of the external library file, or
100 * <code>-1</code> if the build number could not be determined
102 public int getExtBuildNumber() {
103 return FcpUtils.safeParseInt(getExtBuild());
107 * Returns the revision of the external library file.
109 * @return The revision of the external library file
111 public String getExtRevision() {
112 return getField("ExtRevision");
116 * Returns the revision number of the external library file.
118 * @return The revision number of the external library file, or
119 * <code>-1</code> if the revision number could not be determined
121 public int getExtRevisionNumber() {
122 return FcpUtils.safeParseInt(getExtRevision());
126 * Returns the FCP version the node speaks.
128 * @return The FCP version the node speaks
130 public String getFCPVersion() {
131 return getField("FCPVersion");
135 * Returns the make of the node, e.g. “Fred” (freenet reference
138 * @return The make of the node
140 public String getNode() {
141 return getField("Node");
145 * Returns the language of the node as 2-letter code, e.g. “en” or “de”.
147 * @return The language of the node
149 public String getNodeLanguage() {
150 return getField("NodeLanguage");
154 * Returns the revision of the node.
156 * @return The revision of the node
158 public String getRevision() {
159 return getField("Revision");
163 * Returns the revision number of the node.
165 * @return The revision number of the node, or <code>-1</code> if the
166 * revision number coult not be determined
168 public int getRevisionNumber() {
169 return FcpUtils.safeParseInt(getRevision());
173 * Returns whether the node is currently is testnet mode.
175 * @return <code>true</code> if the node is currently in testnet mode,
176 * <code>false</code> otherwise
178 public boolean getTestnet() {
179 return Boolean.valueOf(getField("Testnet"));
183 * Returns the version of the node.
185 * @return The version of the node
187 public String getVersion() {
188 return getField("Version");