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