f00f.net.irc.martyr.clientstate
Class ClientState

java.lang.Object
  extended by f00f.net.irc.martyr.clientstate.ClientState

public class ClientState
extends java.lang.Object

Maintains a list of client-related facts such as what channels we are in, who else is in the channels, what our nick is, etc.

ClientState is a critical part of martyr. To get access to events that change the client state, the framework user can subclass ClientState and then pass the subclass to the IRCConnection's constructor. Then, when a command detects a change in client state, it will call the corresponding method in the custom ClientState.

If a user of the framework wishes to grab client state information about a channel (when a user joins, when a user leaves, topic change, etc), the user can do so in a similar manner. Simply override the 'addChannel(String)' method to instantiate their own Channel subclass, and call the protected 'addChannel' method. See the addChannel method for an example.


Field Summary
protected  java.util.Hashtable<java.lang.String,Channel> channels
           
 
Constructor Summary
ClientState()
           
 
Method Summary
protected  void addChannel(Channel channel)
           
 void addChannel(java.lang.String channame)
          Adds a channel to the list of channels we know about.
 Channel getChannel(java.lang.String chanName)
           
 java.util.Enumeration getChannelNames()
           
 java.util.Enumeration getChannels()
           
 java.lang.String getName()
           
 FullNick getNick()
           
 java.lang.String getPass()
           
 int getPort()
           
 java.lang.String getServer()
           
 java.lang.String getUser()
           
 boolean isOnChannel(java.lang.String channel)
           
 void removeChannel(java.lang.String channel)
          Removes a channel from the state, does nothing if the channel name is invalid.
 void setName(java.lang.String name)
           
 void setNick(FullNick nick)
           
 void setPass(java.lang.String pass)
           
 void setPort(int port)
           
 void setServer(java.lang.String server)
           
 void setUser(java.lang.String user)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

channels

protected java.util.Hashtable<java.lang.String,Channel> channels
Constructor Detail

ClientState

public ClientState()
Method Detail

setNick

public void setNick(FullNick nick)

getNick

public FullNick getNick()

setUser

public void setUser(java.lang.String user)

getUser

public java.lang.String getUser()
Returns:
the username that was used to register.

setName

public void setName(java.lang.String name)

getName

public java.lang.String getName()
Returns:
the name (any arbitrary string) that was used to register.

getPass

public java.lang.String getPass()
Returns:
the password that was used to register.

setPass

public void setPass(java.lang.String pass)

setServer

public void setServer(java.lang.String server)

getServer

public java.lang.String getServer()

setPort

public void setPort(int port)

getPort

public int getPort()

addChannel

public void addChannel(java.lang.String channame)

Adds a channel to the list of channels we know about. If you want to supply your own Channel object, override this method with:

 public void addChannel( String channame )
 {
     addChannel( new MyChannel( channame ) );
 }
 

Parameters:
channame - Channel to add to list of channels

addChannel

protected void addChannel(Channel channel)

getChannel

public Channel getChannel(java.lang.String chanName)

removeChannel

public void removeChannel(java.lang.String channel)
Removes a channel from the state, does nothing if the channel name is invalid. Should we throw an exception here?

Parameters:
channel - Channel to remove from list

isOnChannel

public boolean isOnChannel(java.lang.String channel)

getChannelNames

public java.util.Enumeration getChannelNames()

getChannels

public java.util.Enumeration getChannels()


Copyright © 2000-2007 Ben Damm, Daniel Henninger, et al.