2 * © 2008 INA Service GmbH
4 package net.pterodactylus.util.fcp.message;
6 import net.pterodactylus.util.fcp.FcpMessage;
9 * Some convenience methods for parsing a “NodeHello” message from the node.
11 * @author <a href="mailto:dr@ina-germany.de">David Roden</a>
14 public class NodeHello extends BaseMessage {
17 * @param receivedMessage
18 * The received FCP message
20 public NodeHello(FcpMessage receivedMessage) {
21 super(receivedMessage);
25 * Returns the build of the node. This may not be a number but also a string
26 * like “@custom@” in case you built the node yourself.
28 * @return The build of the node
30 public String getBuild() {
31 return getField("Build");
35 * Returns the build number of the node. This may not be a number but also a
36 * string like “@custom@” in case you built the node yourself.
38 * @return The build number of the node, or <code>-1</code> if the build
39 * number could not be determined
41 public int getBuildNumber() {
42 String build = getBuild();
44 return Integer.valueOf(build);
45 } catch (NumberFormatException nfe1) {
52 * Returns the number of compression codecs.
54 * @return The number of compression codecs
56 public String getCompressionCodecs() {
57 return getField("CompressionCodecs");
61 * Returns the number of compression codecs.
63 * @return The number of compression codecs, or <code>-1</code> if the
64 * number of compression codecs could not be determined
66 public int getCompressionCodecsNumber() {
67 String compressionCodecs = getCompressionCodecs();
69 return Integer.valueOf(compressionCodecs);
70 } catch (NumberFormatException nfe1) {
77 * Returns the unique connection identifier.
79 * @return The connection identifier
81 public String getConnectionIdentifier() {
82 return getField("ConnectionIdentifier");
86 * Returns the build of the external library file.
88 * @return The build of the external library file
90 public String getExtBuild() {
91 return getField("ExtBuild");
95 * Returns the build number of the external library file.
97 * @return The build number of the external library file, or <code>-1</code>
98 * if the build number could not be determined
100 public int getExtBuildNumber() {
101 String extBuild = getExtBuild();
103 return Integer.valueOf(extBuild);
104 } catch (NumberFormatException nfe1) {
111 * Returns the revision of the external library file.
113 * @return The revision of the external library file
115 public String getExtRevision() {
116 return getField("ExtRevision");
120 * Returns the revision number of the external library file.
122 * @return The revision number of the external library file, or
123 * <code>-1</code> if the revision number could not be determined
125 public int getExtRevisionNumber() {
126 String extRevision = getExtRevision();
128 return Integer.valueOf(extRevision);
129 } catch (NumberFormatException nfe1) {
136 * Returns the FCP version the node speaks.
138 * @return The FCP version the node speaks
140 public String getFCPVersion() {
141 return getField("FCPVersion");
145 * Returns the make of the node, e.g. “Fred” (freenet reference
148 * @return The make of the node
150 public String getNode() {
151 return getField("Node");
155 * Returns the language of the node as 2-letter code, e.g. “en” or “de”.
157 * @return The language of the node
159 public String getNodeLanguage() {
160 return getField("NodeLanguage");
164 * Returns the revision of the node.
166 * @return The revision of the node
168 public String getRevision() {
169 return getField("Revision");
173 * Returns the revision number of the node.
175 * @return The revision number of the node, or <code>-1</code> if the
176 * revision number coult not be determined
178 public int getRevisionNumber() {
179 String revision = getRevision();
181 return Integer.valueOf(revision);
182 } catch (NumberFormatException nfe1) {
189 * Returns whether the node is currently is testnet mode.
191 * @return <code>true</code> if the node is currently in testnet mode,
192 * <code>false</code> otherwise
194 public boolean getTestnet() {
195 return Boolean.valueOf(getField("Testnet"));
199 * Returns the version of the node.
201 * @return The version of the node
203 public String getVersion() {
204 return getField("Version");