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 * Createa a new “NodeHello” message that wraps the received message.
19 * @param receivedMessage
20 * The received FCP message
22 public NodeHello(FcpMessage receivedMessage) {
23 super(receivedMessage);
27 * Returns the build of the node. This may not be a number but also a string
28 * like “@custom@” in case you built the node yourself.
30 * @return The build of the node
32 public String getBuild() {
33 return getField("Build");
37 * Returns the build number of the node. This may not be a number but also a
38 * string like “@custom@” in case you built the node yourself.
40 * @return The build number of the node, or <code>-1</code> if the build
41 * number could not be determined
43 public int getBuildNumber() {
44 String build = getBuild();
46 return Integer.valueOf(build);
47 } catch (NumberFormatException nfe1) {
54 * Returns the number of compression codecs.
56 * @return The number of compression codecs
58 public String getCompressionCodecs() {
59 return getField("CompressionCodecs");
63 * Returns the number of compression codecs.
65 * @return The number of compression codecs, or <code>-1</code> if the
66 * number of compression codecs could not be determined
68 public int getCompressionCodecsNumber() {
69 String compressionCodecs = getCompressionCodecs();
71 return Integer.valueOf(compressionCodecs);
72 } catch (NumberFormatException nfe1) {
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 <code>-1</code>
100 * if the build number could not be determined
102 public int getExtBuildNumber() {
103 String extBuild = getExtBuild();
105 return Integer.valueOf(extBuild);
106 } catch (NumberFormatException nfe1) {
113 * Returns the revision of the external library file.
115 * @return The revision of the external library file
117 public String getExtRevision() {
118 return getField("ExtRevision");
122 * Returns the revision number of the external library file.
124 * @return The revision number of the external library file, or
125 * <code>-1</code> if the revision number could not be determined
127 public int getExtRevisionNumber() {
128 String extRevision = getExtRevision();
130 return Integer.valueOf(extRevision);
131 } catch (NumberFormatException nfe1) {
138 * Returns the FCP version the node speaks.
140 * @return The FCP version the node speaks
142 public String getFCPVersion() {
143 return getField("FCPVersion");
147 * Returns the make of the node, e.g. “Fred” (freenet reference
150 * @return The make of the node
152 public String getNode() {
153 return getField("Node");
157 * Returns the language of the node as 2-letter code, e.g. “en” or “de”.
159 * @return The language of the node
161 public String getNodeLanguage() {
162 return getField("NodeLanguage");
166 * Returns the revision of the node.
168 * @return The revision of the node
170 public String getRevision() {
171 return getField("Revision");
175 * Returns the revision number of the node.
177 * @return The revision number of the node, or <code>-1</code> if the
178 * revision number coult not be determined
180 public int getRevisionNumber() {
181 String revision = getRevision();
183 return Integer.valueOf(revision);
184 } catch (NumberFormatException nfe1) {
191 * Returns whether the node is currently is testnet mode.
193 * @return <code>true</code> if the node is currently in testnet mode,
194 * <code>false</code> otherwise
196 public boolean getTestnet() {
197 return Boolean.valueOf(getField("Testnet"));
201 * Returns the version of the node.
203 * @return The version of the node
205 public String getVersion() {
206 return getField("Version");