From 7415463c80f00f7251fbdd271f4c2f3c25449cd2 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Wed, 9 Apr 2008 20:02:40 +0000 Subject: [PATCH] add NodeData reply git-svn-id: http://trooper/svn/projects/jSite/trunk@679 c3eda9e8-030b-0410-8277-bc7414b0a119 --- src/net/pterodactylus/util/fcp/NodeData.java | 178 +++++++++++++++++++++++++++ 1 file changed, 178 insertions(+) create mode 100644 src/net/pterodactylus/util/fcp/NodeData.java diff --git a/src/net/pterodactylus/util/fcp/NodeData.java b/src/net/pterodactylus/util/fcp/NodeData.java new file mode 100644 index 0000000..facbd1c --- /dev/null +++ b/src/net/pterodactylus/util/fcp/NodeData.java @@ -0,0 +1,178 @@ +/* + * jSite2 - NodeData.java - + * Copyright © 2008 David Roden + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +package net.pterodactylus.util.fcp; + +/** + * The “NodeData” contains the noderef of the node, along with additional data. + * + * @author David Roden <droden@gmail.com> + * @version $Id$ + */ +public class NodeData extends BaseMessage { + + /** The noderef of the node. */ + private final NodeRef nodeRef; + + /** + * Creates a new “NodeData” message that wraps the received message. + * + * @param receivedMessage + * The received message + */ + public NodeData(FcpMessage receivedMessage) { + super(receivedMessage); + nodeRef = new NodeRef(receivedMessage); + } + + /** + * Returns the noderef of the node. + * + * @return The noderef of the node + */ + public NodeRef getNodeRef() { + return nodeRef; + } + + /** + * Returns the last good version, i.e. the oldest version the node will + * connect to. + * + * @return The last good version + */ + public Version getLastGoodVersion() { + return nodeRef.getLastGoodVersion(); + } + + /** + * Returns the signature of the noderef. + * + * @return The signature of the noderef + */ + public String getSignature() { + return nodeRef.getSignature(); + } + + /** + * Returns whether the noderef is the opennet noderef of the node + * + * @return true if the noderef is the opennet noderef of the + * node, false otherwise + */ + public boolean isOpennet() { + return nodeRef.isOpennet(); + } + + /** + * Returns the identity of the node + * + * @return The identity of the node + */ + public String getIdentity() { + return nodeRef.getIdentity(); + } + + /** + * Returns the name of the node. + * + * @return The name of the node + */ + public String getMyName() { + return nodeRef.getMyName(); + } + + /** + * Returns the version of the node. + * + * @return The version of the node + */ + public Version getVersion() { + return nodeRef.getVersion(); + } + + /** + * Returns IP addresses and port number of the node. + * + * @return The IP addresses and port numbers of the node + */ + public String getPhysicalUDP() { + return nodeRef.getPhysicalUDP(); + } + + /** + * Returns the ARK of the node. + * + * @return The ARK of the node + */ + public ARK getARK() { + return nodeRef.getARK(); + } + + /** + * Returns the public key of the node. + * + * @return The public key of the node + */ + public String getDSAPublicKey() { + return nodeRef.getDSAPublicKey(); + } + + /** + * Returns the private key of the node. + * + * @return The private key of the node + */ + public String getDSKPrivateKey() { + return getField("dsaPrivKey.x"); + } + + /** + * Returns the DSA group of the node. + * + * @return The DSA group of the node + */ + public DSAGroup getDSAGroup() { + return nodeRef.getDSAGroup(); + } + + /** + * Returns the negotiation types supported by the node. + * + * @return The node’s supported negotiation types + */ + public int[] getNegotiationTypes() { + return nodeRef.getNegotiationTypes(); + } + + /** + * Returns one of the volatile fields from the message. The given field name + * is prepended with “volatile.” so if you want to get the value of the + * field with the name “volatile.freeJavaMemory” you only need to specify + * “freeJavaMemory”. + * + * @param field + * The name of the field + * @return The value of the field, or null if there is no + * such field + */ + public String getVolatile(String field) { + return getField("volatile." + field); + } + +} -- 2.7.4