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 David ‘Bombe’ Roden <bombe@freenetproject.org>
27 public class NodeHello extends BaseMessage {
30 * Createa a new “NodeHello” message that wraps the received message.
32 * @param receivedMessage
33 * The received FCP message
35 NodeHello(FcpMessage receivedMessage) {
36 super(receivedMessage);
40 * Returns the build of the node. This may not be a number but also a string
41 * like “@custom@” in case you built the node yourself.
43 * @return The build of the node
45 public String getBuild() {
46 return getField("Build");
50 * Returns the build number of the node. This may not be a number but also a
51 * string like “@custom@” in case you built the node yourself.
53 * @return The build number of the node, or <code>-1</code> if the build
54 * number could not be determined
56 public int getBuildNumber() {
57 return FcpUtils.safeParseInt(getBuild());
61 * Returns the number of compression codecs.
63 * @return The number of compression codecs
65 public String getCompressionCodecs() {
66 return getField("CompressionCodecs");
70 * Returns the number of compression codecs.
72 * @return The number of compression codecs, or <code>-1</code> if the
73 * number of compression codecs could not be determined
75 public int getCompressionCodecsNumber() {
76 return FcpUtils.safeParseInt(getCompressionCodecs());
80 * Returns the unique connection identifier.
82 * @return The connection identifier
84 public String getConnectionIdentifier() {
85 return getField("ConnectionIdentifier");
89 * Returns the build of the external library file.
91 * @return The build of the external library file
93 public String getExtBuild() {
94 return getField("ExtBuild");
98 * Returns the build number of the external library file.
100 * @return The build number of the external library file, or <code>-1</code>
101 * if the build number could not be determined
103 public int getExtBuildNumber() {
104 return FcpUtils.safeParseInt(getExtBuild());
108 * Returns the revision of the external library file.
110 * @return The revision of the external library file
112 public String getExtRevision() {
113 return getField("ExtRevision");
117 * Returns the revision number of the external library file.
119 * @return The revision number of the external library file, or
120 * <code>-1</code> if the revision number could not be determined
122 public int getExtRevisionNumber() {
123 return FcpUtils.safeParseInt(getExtRevision());
127 * Returns the FCP version the node speaks.
129 * @return The FCP version the node speaks
131 public String getFCPVersion() {
132 return getField("FCPVersion");
136 * Returns the make of the node, e.g. “Fred” (freenet reference
139 * @return The make of the node
141 public String getNode() {
142 return getField("Node");
146 * Returns the language of the node as 2-letter code, e.g. “en” or “de”.
148 * @return The language of the node
150 public String getNodeLanguage() {
151 return getField("NodeLanguage");
155 * Returns the revision of the node.
157 * @return The revision of the node
159 public String getRevision() {
160 return getField("Revision");
164 * Returns the revision number of the node.
166 * @return The revision number of the node, or <code>-1</code> if the
167 * revision number coult not be determined
169 public int getRevisionNumber() {
170 return FcpUtils.safeParseInt(getRevision());
174 * Returns whether the node is currently is testnet mode.
176 * @return <code>true</code> if the node is currently in testnet mode,
177 * <code>false</code> otherwise
179 public boolean getTestnet() {
180 return Boolean.valueOf(getField("Testnet"));
184 * Returns the version of the node.
186 * @return The version of the node
188 public String getVersion() {
189 return getField("Version");