Reformat source code, new line length for comments (79), some trailing whitespace...
[jFCPlib.git] / src / main / java / net / pterodactylus / fcp / NodeData.java
1 /*
2  * jFCPlib - NodeData.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  * The “NodeData” contains the noderef of the node, along with additional data.
23  *
24  * @author David ‘Bombe’ Roden <bombe@freenetproject.org>
25  */
26 public class NodeData extends BaseMessage {
27
28         /** The noderef of the node. */
29         private final NodeRef nodeRef;
30
31         /**
32          * Creates a new “NodeData” message that wraps the received message.
33          *
34          * @param receivedMessage
35          *            The received message
36          */
37         NodeData(FcpMessage receivedMessage) {
38                 super(receivedMessage);
39                 nodeRef = new NodeRef(receivedMessage);
40         }
41
42         /**
43          * Returns the noderef of the node.
44          *
45          * @return The noderef of the node
46          */
47         public NodeRef getNodeRef() {
48                 return nodeRef;
49         }
50
51         /**
52          * Returns the last good version, i.e. the oldest version the node will
53          * connect to.
54          *
55          * @return The last good version
56          */
57         public Version getLastGoodVersion() {
58                 return nodeRef.getLastGoodVersion();
59         }
60
61         /**
62          * Returns the signature of the noderef.
63          *
64          * @return The signature of the noderef
65          */
66         public String getSignature() {
67                 return nodeRef.getSignature();
68         }
69
70         /**
71          * Returns whether the noderef is the opennet noderef of the node
72          *
73          * @return <code>true</code> if the noderef is the opennet noderef of the
74          *         node, <code>false</code> otherwise
75          */
76         public boolean isOpennet() {
77                 return nodeRef.isOpennet();
78         }
79
80         /**
81          * Returns the identity of the node
82          *
83          * @return The identity of the node
84          */
85         public String getIdentity() {
86                 return nodeRef.getIdentity();
87         }
88
89         /**
90          * Returns the name of the node.
91          *
92          * @return The name of the node
93          */
94         public String getMyName() {
95                 return nodeRef.getMyName();
96         }
97
98         /**
99          * Returns the version of the node.
100          *
101          * @return The version of the node
102          */
103         public Version getVersion() {
104                 return nodeRef.getVersion();
105         }
106
107         /**
108          * Returns IP addresses and port number of the node.
109          *
110          * @return The IP addresses and port numbers of the node
111          */
112         public String getPhysicalUDP() {
113                 return nodeRef.getPhysicalUDP();
114         }
115
116         /**
117          * Returns the ARK of the node.
118          *
119          * @return The ARK of the node
120          */
121         public ARK getARK() {
122                 return nodeRef.getARK();
123         }
124
125         /**
126          * Returns the public key of the node.
127          *
128          * @return The public key of the node
129          */
130         public String getDSAPublicKey() {
131                 return nodeRef.getDSAPublicKey();
132         }
133
134         /**
135          * Returns the private key of the node.
136          *
137          * @return The private key of the node
138          */
139         public String getDSKPrivateKey() {
140                 return getField("dsaPrivKey.x");
141         }
142
143         /**
144          * Returns the DSA group of the node.
145          *
146          * @return The DSA group of the node
147          */
148         public DSAGroup getDSAGroup() {
149                 return nodeRef.getDSAGroup();
150         }
151
152         /**
153          * Returns the negotiation types supported by the node.
154          *
155          * @return The node’s supported negotiation types
156          */
157         public int[] getNegotiationTypes() {
158                 return nodeRef.getNegotiationTypes();
159         }
160
161         /**
162          * Returns one of the volatile fields from the message. The given field
163          * name is prepended with “volatile.” so if you want to get the value of
164          * the field with the name “volatile.freeJavaMemory” you only need to
165          * specify “freeJavaMemory”.
166          *
167          * @param field
168          *            The name of the field
169          * @return The value of the field, or <code>null</code> if there is no such
170          *         field
171          */
172         public String getVolatile(String field) {
173                 return getField("volatile." + field);
174         }
175
176 }