From a4c0d3d6d878da55435cb9d9cc8cff6199644199 Mon Sep 17 00:00:00 2001 From: Peter Palfrader Date: Sun, 19 Oct 2003 15:08:35 +0000 Subject: Support random path creation --- src/org/noreply/fancydress/directory/Server.java | 64 +++++++++++++++++++++++- 1 file changed, 62 insertions(+), 2 deletions(-) (limited to 'src/org/noreply/fancydress/directory/Server.java') diff --git a/src/org/noreply/fancydress/directory/Server.java b/src/org/noreply/fancydress/directory/Server.java index c4052d9..45ca720 100644 --- a/src/org/noreply/fancydress/directory/Server.java +++ b/src/org/noreply/fancydress/directory/Server.java @@ -34,6 +34,11 @@ public class Server { */ ArrayList descriptors; + /** + * whether or not this node is recommended. + */ + boolean recommended; + /** * Construct a Server from a given ServerDescriptor. * @@ -46,6 +51,51 @@ public class Server { descriptors = new ArrayList(); descriptors.add(descriptor); + recommended = false; + } + + /** + * Set this node recommended. + * + * This is done by the Directory according to the recommended-servers list. + * + * @see Directory + */ + public void setRecommended() { + recommended = true; + } + + /** + * Get whether or not this node recommended. + * + * @return whether or not this node is recommended + */ + public boolean isRecommended() { + return recommended; + } + + /** + * Get whether or not this node is useable. + * + * A server is useable if it understands PacketVersions that we speak, + * has a serverdescriptor that is useable right now, and this SD has + * an Incoming/MMTP section. + * + * @return whether or not this node is useable + */ + public boolean isUseable() { + ServerDescriptor sd; + try { + sd = getDescriptor(); + } catch (Mix3NoServerDescriptorException e) { + return false; + } + String[] pv = sd.getPacketVersions(); /* getPacketVersions only returns packet versions that we understand */ + if (pv.length == 0) + return false; + if (sd.getIncomingMMTPSection() == null) + return false; + return true; } /** @@ -76,12 +126,22 @@ public class Server { return keyid; } + /** + * Get the nickname of this server. + * + * @return nickname + */ + public String getNickname() { + return nickname; + } + /** * get the the currently valid server descriptor. * * @return current server descriptor + * @throws Mix3NoServerDescriptorException if there is no valid server descriptor */ - public ServerDescriptor getDescriptor() throws Mix3Exception { + public ServerDescriptor getDescriptor() throws Mix3NoServerDescriptorException { ServerDescriptor result = null; Date now = new Date(); @@ -93,7 +153,7 @@ public class Server { result = desc; } if (result == null) - throw new Mix3Exception("No valid server descriptor found."); + throw new Mix3NoServerDescriptorException("No valid server descriptor found."); return result; } } -- cgit v1.2.3