Reformat source code, new line length for comments (79), some trailing whitespace...
[jFCPlib.git] / src / main / java / net / pterodactylus / fcp / NodeHello.java
1 /*
2  * jFCPlib - NodeHello.java - Copyright © 2008 David Roden
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17  */
18
19 package net.pterodactylus.fcp;
20
21 /**
22  * Some convenience methods for parsing a “NodeHello” message from the node.
23  *
24  * @author David ‘Bombe’ Roden <bombe@freenetproject.org>
25  */
26 public class NodeHello extends BaseMessage {
27
28         /**
29          * Createa a new “NodeHello” message that wraps the received message.
30          *
31          * @param receivedMessage
32          *            The received FCP message
33          */
34         NodeHello(FcpMessage receivedMessage) {
35                 super(receivedMessage);
36         }
37
38         /**
39          * Returns the build of the node. This may not be a number but also a
40          * string like “@custom@” in case you built the node yourself.
41          *
42          * @return The build of the node
43          */
44         public String getBuild() {
45                 return getField("Build");
46         }
47
48         /**
49          * Returns the build number of the node. This may not be a number but also
50          * a string like “@custom@” in case you built the node yourself.
51          *
52          * @return The build number of the node, or <code>-1</code> if the build
53          *         number could not be determined
54          */
55         public int getBuildNumber() {
56                 return FcpUtils.safeParseInt(getBuild());
57         }
58
59         /**
60          * Returns the number of compression codecs.
61          *
62          * @return The number of compression codecs
63          */
64         public String getCompressionCodecs() {
65                 return getField("CompressionCodecs");
66         }
67
68         /**
69          * Returns the number of compression codecs.
70          *
71          * @return The number of compression codecs, or <code>-1</code> if the
72          *         number of compression codecs could not be determined
73          */
74         public int getCompressionCodecsNumber() {
75                 return FcpUtils.safeParseInt(getCompressionCodecs());
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
100          *         <code>-1</code> if the build number could not be determined
101          */
102         public int getExtBuildNumber() {
103                 return FcpUtils.safeParseInt(getExtBuild());
104         }
105
106         /**
107          * Returns the revision of the external library file.
108          *
109          * @return The revision of the external library file
110          */
111         public String getExtRevision() {
112                 return getField("ExtRevision");
113         }
114
115         /**
116          * Returns the revision number of the external library file.
117          *
118          * @return The revision number of the external library file, or
119          *         <code>-1</code> if the revision number could not be determined
120          */
121         public int getExtRevisionNumber() {
122                 return FcpUtils.safeParseInt(getExtRevision());
123         }
124
125         /**
126          * Returns the FCP version the node speaks.
127          *
128          * @return The FCP version the node speaks
129          */
130         public String getFCPVersion() {
131                 return getField("FCPVersion");
132         }
133
134         /**
135          * Returns the make of the node, e.g. “Fred” (freenet reference
136          * implementation).
137          *
138          * @return The make of the node
139          */
140         public String getNode() {
141                 return getField("Node");
142         }
143
144         /**
145          * Returns the language of the node as 2-letter code, e.g. “en” or “de”.
146          *
147          * @return The language of the node
148          */
149         public String getNodeLanguage() {
150                 return getField("NodeLanguage");
151         }
152
153         /**
154          * Returns the revision of the node.
155          *
156          * @return The revision of the node
157          */
158         public String getRevision() {
159                 return getField("Revision");
160         }
161
162         /**
163          * Returns the revision number of the node.
164          *
165          * @return The revision number of the node, or <code>-1</code> if the
166          *         revision number coult not be determined
167          */
168         public int getRevisionNumber() {
169                 return FcpUtils.safeParseInt(getRevision());
170         }
171
172         /**
173          * Returns whether the node is currently is testnet mode.
174          *
175          * @return <code>true</code> if the node is currently in testnet mode,
176          *         <code>false</code> otherwise
177          */
178         public boolean getTestnet() {
179                 return Boolean.valueOf(getField("Testnet"));
180         }
181
182         /**
183          * Returns the version of the node.
184          *
185          * @return The version of the node
186          */
187         public String getVersion() {
188                 return getField("Version");
189         }
190
191 }