2 * © 2008 INA Service GmbH
4 package net.pterodactylus.util.fcp;
8 * Some convenience methods for parsing a “NodeHello” message from the node.
10 * @author <a href="mailto:dr@ina-germany.de">David Roden</a>
13 public class NodeHello extends BaseMessage {
16 * Createa a new “NodeHello” message that wraps the received message.
18 * @param receivedMessage
19 * The received FCP message
21 public NodeHello(FcpMessage receivedMessage) {
22 super(receivedMessage);
26 * Returns the build of the node. This may not be a number but also a string
27 * like “@custom@” in case you built the node yourself.
29 * @return The build of the node
31 public String getBuild() {
32 return getField("Build");
36 * Returns the build number of the node. This may not be a number but also a
37 * string like “@custom@” in case you built the node yourself.
39 * @return The build number of the node, or <code>-1</code> if the build
40 * number could not be determined
42 public int getBuildNumber() {
43 String build = getBuild();
45 return Integer.valueOf(build);
46 } catch (NumberFormatException nfe1) {
53 * Returns the number of compression codecs.
55 * @return The number of compression codecs
57 public String getCompressionCodecs() {
58 return getField("CompressionCodecs");
62 * Returns the number of compression codecs.
64 * @return The number of compression codecs, or <code>-1</code> if the
65 * number of compression codecs could not be determined
67 public int getCompressionCodecsNumber() {
68 String compressionCodecs = getCompressionCodecs();
70 return Integer.valueOf(compressionCodecs);
71 } catch (NumberFormatException nfe1) {
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 <code>-1</code>
99 * if the build number could not be determined
101 public int getExtBuildNumber() {
102 String extBuild = getExtBuild();
104 return Integer.valueOf(extBuild);
105 } catch (NumberFormatException nfe1) {
112 * Returns the revision of the external library file.
114 * @return The revision of the external library file
116 public String getExtRevision() {
117 return getField("ExtRevision");
121 * Returns the revision number of the external library file.
123 * @return The revision number of the external library file, or
124 * <code>-1</code> if the revision number could not be determined
126 public int getExtRevisionNumber() {
127 String extRevision = getExtRevision();
129 return Integer.valueOf(extRevision);
130 } catch (NumberFormatException nfe1) {
137 * Returns the FCP version the node speaks.
139 * @return The FCP version the node speaks
141 public String getFCPVersion() {
142 return getField("FCPVersion");
146 * Returns the make of the node, e.g. “Fred” (freenet reference
149 * @return The make of the node
151 public String getNode() {
152 return getField("Node");
156 * Returns the language of the node as 2-letter code, e.g. “en” or “de”.
158 * @return The language of the node
160 public String getNodeLanguage() {
161 return getField("NodeLanguage");
165 * Returns the revision of the node.
167 * @return The revision of the node
169 public String getRevision() {
170 return getField("Revision");
174 * Returns the revision number of the node.
176 * @return The revision number of the node, or <code>-1</code> if the
177 * revision number coult not be determined
179 public int getRevisionNumber() {
180 String revision = getRevision();
182 return Integer.valueOf(revision);
183 } catch (NumberFormatException nfe1) {
190 * Returns whether the node is currently is testnet mode.
192 * @return <code>true</code> if the node is currently in testnet mode,
193 * <code>false</code> otherwise
195 public boolean getTestnet() {
196 return Boolean.valueOf(getField("Testnet"));
200 * Returns the version of the node.
202 * @return The version of the node
204 public String getVersion() {
205 return getField("Version");