2 * jFCPlib - NodeHello.java - Copyright © 2008–2016 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 3 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, see <http://www.gnu.org/licenses/>.
18 package net.pterodactylus.fcp;
21 * Some convenience methods for parsing a “NodeHello” message from the node.
23 * @author David ‘Bombe’ Roden <bombe@freenetproject.org>
25 public class NodeHello extends BaseMessage {
28 * Createa a new “NodeHello” message that wraps the received message.
30 * @param receivedMessage
31 * The received FCP message
33 public NodeHello(FcpMessage receivedMessage) {
34 super(receivedMessage);
38 * Returns the build of the node. This may not be a number but also a
39 * string like “@custom@” in case you built the node yourself.
41 * @return The build of the node
43 public String getBuild() {
44 return getField("Build");
48 * Returns the build number of the node. This may not be a number but also
49 * a string like “@custom@” in case you built the node yourself.
51 * @return The build number of the node, or <code>-1</code> if the build
52 * number could not be determined
54 public int getBuildNumber() {
55 return FcpUtils.safeParseInt(getBuild());
59 * Returns the number of compression codecs.
61 * @return The number of compression codecs
63 public String getCompressionCodecs() {
64 return getField("CompressionCodecs");
68 * Returns the number of compression codecs.
70 * @return The number of compression codecs, or <code>-1</code> if the
71 * number of compression codecs could not be determined
73 public int getCompressionCodecsNumber() {
74 return FcpUtils.safeParseInt(getCompressionCodecs());
78 * Returns the unique connection identifier.
80 * @return The connection identifier
82 public String getConnectionIdentifier() {
83 return getField("ConnectionIdentifier");
87 * Returns the build of the external library file.
89 * @return The build of the external library file
91 public String getExtBuild() {
92 return getField("ExtBuild");
96 * Returns the build number of the external library file.
98 * @return The build number of the external library file, or
99 * <code>-1</code> if the build number could not be determined
101 public int getExtBuildNumber() {
102 return FcpUtils.safeParseInt(getExtBuild());
106 * Returns the revision of the external library file.
108 * @return The revision of the external library file
110 public String getExtRevision() {
111 return getField("ExtRevision");
115 * Returns the revision number of the external library file.
117 * @return The revision number of the external library file, or
118 * <code>-1</code> if the revision number could not be determined
120 public int getExtRevisionNumber() {
121 return FcpUtils.safeParseInt(getExtRevision());
125 * Returns the FCP version the node speaks.
127 * @return The FCP version the node speaks
129 public String getFCPVersion() {
130 return getField("FCPVersion");
134 * Returns the make of the node, e.g. “Fred” (freenet reference
137 * @return The make of the node
139 public String getNode() {
140 return getField("Node");
144 * Returns the language of the node as 2-letter code, e.g. “en” or “de”.
146 * @return The language of the node
148 public String getNodeLanguage() {
149 return getField("NodeLanguage");
153 * Returns the revision of the node.
155 * @return The revision of the node
157 public String getRevision() {
158 return getField("Revision");
162 * Returns the revision number of the node.
164 * @return The revision number of the node, or <code>-1</code> if the
165 * revision number coult not be determined
167 public int getRevisionNumber() {
168 return FcpUtils.safeParseInt(getRevision());
172 * Returns whether the node is currently is testnet mode.
174 * @return <code>true</code> if the node is currently in testnet mode,
175 * <code>false</code> otherwise
177 public boolean getTestnet() {
178 return Boolean.valueOf(getField("Testnet"));
182 * Returns the version of the node.
184 * @return The version of the node
186 public String getVersion() {
187 return getField("Version");