From 0375aac1b9e994a88a82973ae0df7b8814251a7e Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Wed, 9 Apr 2008 19:39:07 +0000 Subject: [PATCH] add constructor that creates noderef from fcp message git-svn-id: http://trooper/svn/projects/jSite/trunk@674 c3eda9e8-030b-0410-8277-bc7414b0a119 --- src/net/pterodactylus/util/fcp/NodeRef.java | 35 +++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/src/net/pterodactylus/util/fcp/NodeRef.java b/src/net/pterodactylus/util/fcp/NodeRef.java index 4eb80eb..cc8241f 100644 --- a/src/net/pterodactylus/util/fcp/NodeRef.java +++ b/src/net/pterodactylus/util/fcp/NodeRef.java @@ -52,6 +52,37 @@ public class NodeRef { private String signature; /** + * Creates a new, empty noderef. + */ + public NodeRef() { + } + + /** + * Creates a new noderef that is initialized with fields from the given + * message. + * + * @param fromMessage + * The message to get initial values for the noderef from + */ + public NodeRef(FcpMessage fromMessage) { + identity = fromMessage.getField("identity"); + opennet = Boolean.valueOf(fromMessage.getField("opennet")); + name = fromMessage.getField("myName"); + if (fromMessage.hasField("location")) { + location = Double.valueOf(fromMessage.getField("location")); + } + physicalUDP = fromMessage.getField("physical.udp"); + ark = new ARK(fromMessage.getField("ark.pubURI"), fromMessage.getField("ark.privURI"), fromMessage.getField("ark.number")); + dsaPublicKey = fromMessage.getField("dsaPubKey.y"); + dsaGroup = new DSAGroup(fromMessage.getField("dsaGroup.b"), fromMessage.getField("dsaGroup.p"), fromMessage.getField("dsaGroup.q")); + negotiationTypes = FcpUtils.decodeMultiIntegerField(fromMessage.getField("auth.negTypes")); + version = new Version(fromMessage.getField("version")); + lastGoodVersion = new Version(fromMessage.getField("lastGoodVersion")); + testnet = Boolean.valueOf(fromMessage.getField("testnet")); + signature = fromMessage.getField("sig"); + } + + /** * Returns the identity of the node. * * @return The identity of the node @@ -155,7 +186,7 @@ public class NodeRef { * * @return The ARK of the node */ - public ARK getArk() { + public ARK getARK() { return ark; } @@ -165,7 +196,7 @@ public class NodeRef { * @param ark * The ARK of the node */ - public void setArk(ARK ark) { + public void setARK(ARK ark) { this.ark = ark; } -- 2.7.4