Chat
Class HostList

java.lang.Object
  |
  +--java.util.Dictionary
        |
        +--java.util.Hashtable
              |
              +--Chat.HostList
All Implemented Interfaces:
java.lang.Cloneable, java.util.Map, java.io.Serializable

class HostList
extends java.util.Hashtable

Maintains a list of other chat users, as well as local user information. Provides a thread-safe simultaneous iterating and updating of the list. Sender and Receiver hold a pointer to the instance of this class.

See Also:
Sender, Receiver, Serialized Form

Inner Class Summary
(package private)  class HostList.HostItem
          A data-storage class representing an item in the list of remote users.
(package private)  class HostList.HostIterator
          A custom thread-safe iterator over the list.
 
Inner classes inherited from class java.util.Map
java.util.Map.Entry
 
Field Summary
(package private)  Console console
          A link to the console - used solely for updating the user list.
(package private)  HostList.HostItem me
          Information about this (local) user.
(package private)  java.util.TreeSet nicks
          A separately maintained list of nicknames for updating the console user list.
 
Fields inherited from class java.util.Hashtable
count, emptyEnumerator, emptyIterator, ENTRIES, entrySet, KEYS, keySet, loadFactor, modCount, serialVersionUID, table, threshold, values, VALUES
 
Constructor Summary
(package private) HostList(Console console)
          Initializes the host list with the link to console.
 
Method Summary
(package private)  void add(java.lang.String nick, java.lang.String host, int port)
          Adds a remote user to hostlist.
 void clear()
          Clears the hostlist.
(package private)  void delete(java.lang.String nick)
          Deletes a remote user from hostlist.
(package private)  java.util.Iterator iterator()
           
(package private)  void setIdentity(java.lang.String nick, java.lang.String host, int port)
          Sets the identity of local user.
 
Methods inherited from class java.util.Hashtable
, clone, contains, containsKey, containsValue, elements, entrySet, equals, get, getEnumeration, getIterator, hashCode, isEmpty, keys, keySet, put, putAll, readObject, rehash, remove, size, toString, values, writeObject
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, registerNatives, wait, wait, wait
 

Field Detail

console

final Console console
A link to the console - used solely for updating the user list.

nicks

final java.util.TreeSet nicks
A separately maintained list of nicknames for updating the console user list.

me

HostList.HostItem me
Information about this (local) user.
Constructor Detail

HostList

HostList(Console console)
Initializes the host list with the link to console.
Parameters:
console - link to console.
Method Detail

setIdentity

void setIdentity(java.lang.String nick,
                 java.lang.String host,
                 int port)
Sets the identity of local user.
Parameters:
nick - user nickname
host - user hostname (IP adress)
port - user port

add

void add(java.lang.String nick,
         java.lang.String host,
         int port)
Adds a remote user to hostlist.
Parameters:
nick - user nickname
host - user hostname (IP adress)
port - user port

delete

void delete(java.lang.String nick)
Deletes a remote user from hostlist.
Parameters:
nick - user nickname

clear

public void clear()
Clears the hostlist.
Overrides:
clear in class java.util.Hashtable

iterator

java.util.Iterator iterator()