f00f.net.irc.martyr.commands
Class ModeCommand

java.lang.Object
  |
  +--f00f.net.irc.martyr.commands.ModeCommand
All Implemented Interfaces:
Command
Direct Known Subclasses:
ChannelModeCommand, UserModeCommand

public class ModeCommand
extends java.lang.Object
implements Command

Defines MODE command. Since the MODE command is of two distinct types, this class is really more of a command mini-factory. It determines which type of command it is, either a UserModeCommand or a ChannelModeCommand.


Constructor Summary
ModeCommand()
          For use as a factory
 
Method Summary
 java.lang.String getSourceString()
          Allows a third party to receive a copy of the raw string.
 State getState()
          Some commands, when received by the server, can only occur in one state.
 Command parse(java.lang.String prefix, java.lang.String identifier, java.lang.String params)
          Parses a string and produces a formed command object, if it can.
 java.util.List parseModes(java.util.Map modes, java.util.StringTokenizer tokens)
          Takes a mode string, such as: '+ooo A B C' or '+o A +o B' or even '+o-o A B' and returns a List containing Mode objects that correspond to the modes specified.
static void registerMode(java.util.Map modes, Mode mode)
           
 java.lang.String render()
          Should not be called, as ModeCommand doesn't actually represent a command.
 void selfRegister(CommandRegister reg)
          Every command should know how to register itself (or not) with the command parsing engine.
 void setSourceString(java.lang.String source)
          Gives the command a copy of the raw string from the server.
 java.lang.String toString()
           
 boolean updateClientState(ClientState cs)
          Does nothing, as this is a factory command.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ModeCommand

public ModeCommand()
For use as a factory
Method Detail

registerMode

public static void registerMode(java.util.Map modes,
                                Mode mode)

getState

public State getState()
Description copied from interface: Command
Some commands, when received by the server, can only occur in one state. Thus, when this command is received, the protocol should assume that it is in that state, and a state change may be triggered. A command can use the 'unknown' state to indicate it can be received in any state (for example, ping).
Specified by:
getState in interface Command

selfRegister

public void selfRegister(CommandRegister reg)
Description copied from interface: Command
Every command should know how to register itself (or not) with the command parsing engine.
Specified by:
selfRegister in interface Command

parse

public Command parse(java.lang.String prefix,
                     java.lang.String identifier,
                     java.lang.String params)
Description copied from interface: Command
Parses a string and produces a formed command object, if it can. Should return null if it cannot form the command object. The identifier is usually ignored, except in the special case where commands can be identified by multiple identifiers. In that case, the behaviour of the command may change in sublte ways.
Specified by:
parse in interface Command

render

public java.lang.String render()
Should not be called, as ModeCommand doesn't actually represent a command.
Specified by:
render in interface Command

setSourceString

public void setSourceString(java.lang.String source)
Description copied from interface: Command
Gives the command a copy of the raw string from the server. Called by IRCConnection after the command is parsed.
Specified by:
setSourceString in interface Command

getSourceString

public java.lang.String getSourceString()
Description copied from interface: Command
Allows a third party to receive a copy of the raw string.
Specified by:
getSourceString in interface Command

updateClientState

public boolean updateClientState(ClientState cs)
Does nothing, as this is a factory command.
Specified by:
updateClientState in interface Command

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

parseModes

public java.util.List parseModes(java.util.Map modes,
                                 java.util.StringTokenizer tokens)
Takes a mode string, such as: '+ooo A B C' or '+o A +o B' or even '+o-o A B' and returns a List containing Mode objects that correspond to the modes specified.
Parameters:
modes - is a Map of Character to Mode objects.
tokens - is the sequence of tokens making up the parameters of the command.


Copyright ? 2000,2001, f00f networks. All Rights Reserved.