enhance javadoc
[jSite2.git] / src / net / pterodactylus / util / fcp / message / NodeHello.java
1 /**
2  * © 2008 INA Service GmbH
3  */
4 package net.pterodactylus.util.fcp.message;
5
6 import net.pterodactylus.util.fcp.FcpMessage;
7
8 /**
9  * Some convenience methods for parsing a “NodeHello” message from the node.
10  * 
11  * @author <a href="mailto:dr@ina-germany.de">David Roden</a>
12  * @version $Id$
13  */
14 public class NodeHello extends BaseMessage {
15
16         /**
17          * Createa a new “NodeHello” message that wraps the received message.
18          * 
19          * @param receivedMessage
20          *            The received FCP message
21          */
22         public NodeHello(FcpMessage receivedMessage) {
23                 super(receivedMessage);
24         }
25
26         /**
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.
29          * 
30          * @return The build of the node
31          */
32         public String getBuild() {
33                 return getField("Build");
34         }
35
36         /**
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.
39          * 
40          * @return The build number of the node, or <code>-1</code> if the build
41          *         number could not be determined
42          */
43         public int getBuildNumber() {
44                 String build = getBuild();
45                 try {
46                         return Integer.valueOf(build);
47                 } catch (NumberFormatException nfe1) {
48                         /* ignore. */
49                 }
50                 return -1;
51         }
52
53         /**
54          * Returns the number of compression codecs.
55          * 
56          * @return The number of compression codecs
57          */
58         public String getCompressionCodecs() {
59                 return getField("CompressionCodecs");
60         }
61
62         /**
63          * Returns the number of compression codecs.
64          * 
65          * @return The number of compression codecs, or <code>-1</code> if the
66          *         number of compression codecs could not be determined
67          */
68         public int getCompressionCodecsNumber() {
69                 String compressionCodecs = getCompressionCodecs();
70                 try {
71                         return Integer.valueOf(compressionCodecs);
72                 } catch (NumberFormatException nfe1) {
73                         /* ignore. */
74                 }
75                 return -1;
76         }
77
78         /**
79          * Returns the unique connection identifier.
80          * 
81          * @return The connection identifier
82          */
83         public String getConnectionIdentifier() {
84                 return getField("ConnectionIdentifier");
85         }
86
87         /**
88          * Returns the build of the external library file.
89          * 
90          * @return The build of the external library file
91          */
92         public String getExtBuild() {
93                 return getField("ExtBuild");
94         }
95
96         /**
97          * Returns the build number of the external library file.
98          * 
99          * @return The build number of the external library file, or <code>-1</code>
100          *         if the build number could not be determined
101          */
102         public int getExtBuildNumber() {
103                 String extBuild = getExtBuild();
104                 try {
105                         return Integer.valueOf(extBuild);
106                 } catch (NumberFormatException nfe1) {
107                         /* ignore. */
108                 }
109                 return -1;
110         }
111
112         /**
113          * Returns the revision of the external library file.
114          * 
115          * @return The revision of the external library file
116          */
117         public String getExtRevision() {
118                 return getField("ExtRevision");
119         }
120
121         /**
122          * Returns the revision number of the external library file.
123          * 
124          * @return The revision number of the external library file, or
125          *         <code>-1</code> if the revision number could not be determined
126          */
127         public int getExtRevisionNumber() {
128                 String extRevision = getExtRevision();
129                 try {
130                         return Integer.valueOf(extRevision);
131                 } catch (NumberFormatException nfe1) {
132                         /* ignore. */
133                 }
134                 return -1;
135         }
136
137         /**
138          * Returns the FCP version the node speaks.
139          * 
140          * @return The FCP version the node speaks
141          */
142         public String getFCPVersion() {
143                 return getField("FCPVersion");
144         }
145
146         /**
147          * Returns the make of the node, e.g. “Fred” (freenet reference
148          * implementation).
149          * 
150          * @return The make of the node
151          */
152         public String getNode() {
153                 return getField("Node");
154         }
155
156         /**
157          * Returns the language of the node as 2-letter code, e.g. “en” or “de”.
158          * 
159          * @return The language of the node
160          */
161         public String getNodeLanguage() {
162                 return getField("NodeLanguage");
163         }
164
165         /**
166          * Returns the revision of the node.
167          * 
168          * @return The revision of the node
169          */
170         public String getRevision() {
171                 return getField("Revision");
172         }
173
174         /**
175          * Returns the revision number of the node.
176          * 
177          * @return The revision number of the node, or <code>-1</code> if the
178          *         revision number coult not be determined
179          */
180         public int getRevisionNumber() {
181                 String revision = getRevision();
182                 try {
183                         return Integer.valueOf(revision);
184                 } catch (NumberFormatException nfe1) {
185                         /* ignore. */
186                 }
187                 return -1;
188         }
189
190         /**
191          * Returns whether the node is currently is testnet mode.
192          * 
193          * @return <code>true</code> if the node is currently in testnet mode,
194          *         <code>false</code> otherwise
195          */
196         public boolean getTestnet() {
197                 return Boolean.valueOf(getField("Testnet"));
198         }
199
200         /**
201          * Returns the version of the node.
202          * 
203          * @return The version of the node
204          */
205         public String getVersion() {
206                 return getField("Version");
207         }
208
209 }