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