Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: org/mitre/cvw/CVWServer.java


1   /*
2    * Copyright (c) 1996-2000. The MITRE Corporation (http://www.mitre.org/).
3    * All rights reserved.
4    * CVW comes with ABSOLUTELY NO WARRANTY. See license for details.
5    */
6   
7   package org.mitre.cvw;
8   
9   /**
10   * This class represents a CVW server within a possible federation of CVW servers
11   * @version 1
12   * @author S.R.Jones
13   */
14  
15  public class CVWServer extends Object {
16  
17      private String serverID; // the name of the server. Should be unique within the federation
18      private String serverDescription; // a brief description of the server
19      private boolean serverActive;  // denotes whether the server is currently active (can be reached)
20  
21      /** 
22       * STATIC METHODS & VARIABLES
23       * for handling CVW server stuff
24       */
25      public static final String delimiter = "@";
26  
27      /** 
28       * Takes a string of the form <part1>@<part2> and returns
29       * the index of the '@', or -1 if there is no '@'
30       */
31      public static int serverIndex(String str) {
32    return str.indexOf(delimiter);
33      }
34  
35      /**
36       * Takes a string of the form <part1>@<part2> and returns
37       * a two length array with part1 as the first element and <part2> as the 
38       * second.  If there is no '@', then the first element is the whole string,
39       * and the second element is the empty string.
40       *
41       * @param str the string to split
42       * @return a two length array of strings
43       */
44      public static String[] split(String str) {
45    String vals[] = new String[2];
46    int i;
47    
48    if ((i = serverIndex(str)) != -1) {
49        // there is a server portion
50        vals[0] = str.substring(0, i);
51        vals[1] = str.substring(i+1, str.length());
52    } else {
53        vals[0] = str;
54        vals[1] = "";
55    }
56    return vals;
57      }
58  
59      /**
60       * END OF STATIC SECTION
61       */
62  
63      /**
64       * Constructor
65       * 
66       * @param serverID The unique CVW system name
67       */
68      public CVWServer (String serverID) {
69    this(serverID, "No description available", true);
70      }
71  
72      /**
73       * Constructor
74       * 
75       * @param serverID The unique CVW system name
76       * @param serverDescription Descriptive text about the server
77       */
78      public CVWServer (String serverID, String serverDescription) {
79    this(serverID, serverDescription, true);
80      }
81  
82      /**
83       * Constructor
84       * 
85       * @param serverID The unique CVW system name
86       * @param serverDescription Descriptive text about the server
87       * @param serverActive Whether the server can currently be reached through the network
88       */
89      public CVWServer (String serverID, String serverDescription, boolean serverActive) {
90    this.serverID = serverID;
91    this.serverDescription = serverDescription;
92    this.serverActive = serverActive;
93      }
94  
95      /**
96       * Set whether the server is currently active
97       *
98       * @param activeState <code>true</code> if the server can be reached through the network
99       *                    <code>false</code> if the server is unreachable
100      *
101      */
102     public void setActive(boolean activeState) {
103   serverActive = activeState;
104     }
105 
106     /**
107      * Query to see if the server is active
108      * 
109      * @return The active state of the server
110      */
111     public boolean isServerActive() {
112   return serverActive;
113     }
114 
115     /**
116      * Send off a query to retrieve the current list of online users
117      * (maybe write a return parser method also???)
118      *
119      */
120     public void getOnlineUsers() {
121   // build an online user message for CVWServerComm
122     }
123 
124     /**
125      * Send off a query to retrieve a complete list of users for this server
126      * (again maybe write a return parser??)
127      */
128     public void getAllUsers() {
129   // build an all user message for CVWServerComm
130     }
131 
132     /**
133      * Return the ID of this server
134      * 
135      * @return the ID of the CVW server
136      */
137     public String getID() {
138   return serverID;
139     }
140 
141     /**
142      * Return the name of this server
143      * (could see this valuble for info listing purposes)
144      * 
145      * @return The name of the CVW server
146      */
147     public String toString() {
148   return serverID;
149     }
150 }