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