swpchat.server
Class ChannelCollection

java.lang.Object
  |
  +--swpchat.server.ChannelCollection

public class ChannelCollection
extends java.lang.Object

This class saves all possible channels at the server.

Author:
Andre Brunner, Christian Stuellenberg, Marc Sturm

Field Summary
private  java.util.HashMap channelHash
           
private static java.lang.String CLS
           
private  java.util.HashMap listener
           
 
Constructor Summary
ChannelCollection()
           
 
Method Summary
 void addListener(ChannelCollectionListener newListener)
          Used to add a listener to the listeners collection.
 Channel getChannel(java.lang.String channelKey)
          return the channel, that is identified by the channelKey
 java.util.Iterator iterator()
           
 void removeChannel(java.lang.String name)
          Remove the Channel identified by its Name from the collection.
 void removeListener(ChannelCollectionListener oldListener)
          Used to remove a listener from the listeners collection.
 boolean tryToAddChannel(java.lang.String name, Channel channel)
          Method tries to add Channel to hashtable and is threadsave
 boolean tryToChangeName(java.lang.String oldName, java.lang.String newName)
          Change the nickname of a Channel.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

CLS

private static final java.lang.String CLS

channelHash

private java.util.HashMap channelHash

listener

private java.util.HashMap listener
Constructor Detail

ChannelCollection

public ChannelCollection()
Method Detail

tryToAddChannel

public boolean tryToAddChannel(java.lang.String name,
                               Channel channel)
Method tries to add Channel to hashtable and is threadsave
Parameters:
nickname -  
Channel -  

tryToChangeName

public boolean tryToChangeName(java.lang.String oldName,
                               java.lang.String newName)
                        throws NoSuchChannelException
Change the nickname of a Channel.
Parameters:
oldName, - newName
Returns:
false iff the newName was not allowed in the collection.
Throws:
NoSuchChannelException - if there is no Channel with the old Name in the collection.

removeChannel

public void removeChannel(java.lang.String name)
                   throws NoSuchChannelException
Remove the Channel identified by its Name from the collection.
Parameters:
nickname -  
Throws:
NoSuchChannelException - if there is no Channel with the old Name in the collection.

iterator

public java.util.Iterator iterator()

getChannel

public Channel getChannel(java.lang.String channelKey)
                   throws NoSuchChannelException
return the channel, that is identified by the channelKey
Parameters:
channelKey - String specifying the channelName
Returns:
Channel that is indentified by the channelKey

addListener

public void addListener(ChannelCollectionListener newListener)
Used to add a listener to the listeners collection.
Parameters:
newListener - is the listener to be added.

removeListener

public void removeListener(ChannelCollectionListener oldListener)
Used to remove a listener from the listeners collection.
Parameters:
oldListener - is the listener to be removed.