irc
Class RootInterpretor

java.lang.Object
  |
  +--irc.IRCObject
        |
        +--irc.RootInterpretor
All Implemented Interfaces:
Interpretor
Direct Known Subclasses:
AWTInterpretor, BasicInterpretor, NullInterpretor

public abstract class RootInterpretor
extends IRCObject
implements Interpretor

Root interpretor.


Field Summary
protected  Interpretor _next
          The next interpretor to be used if the command is unknown.
protected  StringParser _parser
          The used string parser.
 
Fields inherited from class irc.IRCObject
_ircConfiguration
 
Constructor Summary
RootInterpretor(IRCConfiguration config)
          Create a new BasicInterpretor without default interpretor.
RootInterpretor(IRCConfiguration config, Interpretor next)
          Create a new BasicInterpretor.
 
Method Summary
 void addLast(Interpretor in)
          Add the given interpretor at the end of this interpretor chain.
 Interpretor getNextInterpretor()
          Get the next interpretor.
protected  void handleCommand(Source source, java.lang.String cmd, java.lang.String[] parts, java.lang.String[] cumul)
          Handle the received command.
 boolean isInside(Interpretor in)
          Check whether the given interpretor is already in the interpretor chain.
protected  void say(Source source, java.lang.String str)
          Say the given text.
 void sendString(Source source, java.lang.String str)
          Send the given string to the server.
 void setNextInterpretor(Interpretor next)
          Set the next interpretor.
protected  void test(java.lang.String cmd, java.lang.String[] parts, int params)
          Test the given command against the expected number of parameters.
 
Methods inherited from class irc.IRCObject
getColor, getIRCConfiguration, getText, getText, getText, getText, getTimeStamp, release
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_parser

protected StringParser _parser
The used string parser.


_next

protected Interpretor _next
The next interpretor to be used if the command is unknown.

Constructor Detail

RootInterpretor

public RootInterpretor(IRCConfiguration config)
Create a new BasicInterpretor without default interpretor.

Parameters:
config - the configuration.

RootInterpretor

public RootInterpretor(IRCConfiguration config,
                       Interpretor next)
Create a new BasicInterpretor.

Parameters:
config - the configuration.
next - next interpretor to be used if the command is unknown. If null, the command will be sent as it to the server.
Method Detail

setNextInterpretor

public void setNextInterpretor(Interpretor next)
Description copied from interface: Interpretor
Set the next interpretor.

Specified by:
setNextInterpretor in interface Interpretor
Parameters:
next - interpretor to use. May be null.

getNextInterpretor

public Interpretor getNextInterpretor()
Description copied from interface: Interpretor
Get the next interpretor.

Specified by:
getNextInterpretor in interface Interpretor
Returns:
the next interpretor, or null if this interpretor is the last.

isInside

public boolean isInside(Interpretor in)
Description copied from interface: Interpretor
Check whether the given interpretor is already in the interpretor chain.

Specified by:
isInside in interface Interpretor
Parameters:
in - the interpretor to check.
Returns:
true if in is in the chain, false otherwise.

addLast

public void addLast(Interpretor in)
Description copied from interface: Interpretor
Add the given interpretor at the end of this interpretor chain. If in is already in the chain, nothing is done.

Specified by:
addLast in interface Interpretor
Parameters:
in - interpretor to add.

test

protected void test(java.lang.String cmd,
                    java.lang.String[] parts,
                    int params)
             throws NotEnoughParametersException
Test the given command against the expected number of parameters.

Parameters:
cmd - the hole command line.
parts - the parsed command line.
params - expected amount of parameters.
Throws:
NotEnoughParametersException - if there is not enough parameters. That's it : if parts.length<=params.

handleCommand

protected void handleCommand(Source source,
                             java.lang.String cmd,
                             java.lang.String[] parts,
                             java.lang.String[] cumul)
Handle the received command.

Parameters:
source - the source that emitted the command.
cmd - the hole command line.
parts - the parsed command line.
cumul - the cumul parsed command line.

sendString

public void sendString(Source source,
                       java.lang.String str)
Description copied from interface: Interpretor
Send the given string to the server.

Specified by:
sendString in interface Interpretor
Parameters:
source - the source.
str - the string to send.

say

protected void say(Source source,
                   java.lang.String str)
Say the given text.

Parameters:
source - the source.
str - what to say.