diff options
Diffstat (limited to 'src/org/noreply/fancydress/directory/Server.java')
-rw-r--r-- | src/org/noreply/fancydress/directory/Server.java | 64 |
1 files changed, 62 insertions, 2 deletions
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 @@ -35,6 +35,11 @@ public class Server { ArrayList descriptors; /** + * whether or not this node is recommended. + */ + boolean recommended; + + /** * Construct a Server from a given ServerDescriptor. * * @param descriptor a 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; } /** @@ -77,11 +127,21 @@ public class Server { } /** + * 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; } } |