org.schwering.irc.lib
Class IRCModeParser

java.lang.Object
  extended byorg.schwering.irc.lib.IRCModeParser

public class IRCModeParser
extends java.lang.Object

Parses channel-modes.

An instance of this class is an argument of the IRCEventListener.onMode(String chan, IRCUser user, IRCModeParser modeParser). It's intended to help the programmer to work with the modes.

Channelmodes are:

These are all channel-modes defined in RFC1459. Nevertheless, most networks provide more channel-modes. This class can handle all modes; it's not restricted to the rights defined in RFC1459.

Version:
1.22
Author:
Christoph Schwering <schwering@gmail.com>
See Also:
IRCEventListener

Constructor Summary
IRCModeParser(java.lang.String line)
          Analyzes the modes and parses them into the parts operators (+ or -), modes (one character) and optional arguments (one word or number).
IRCModeParser(java.lang.String modes, java.lang.String args)
          Analyzes the modes and parses them into the parts operators (+ or -), modes (one character) and optional arguments (one word or number).
 
Method Summary
 java.lang.String getArgAt(int i)
          Returns the nick of a given index.
 int getCount()
          Returns count of modes.
 java.lang.String getLine()
          Returns the line as it was sent from the IRC server.
 char getModeAt(int i)
          Returns the mode (for example o, v, m, i) of a given index.
 char getOperatorAt(int i)
          Returns the operator (+ or -) of a given index.
 java.lang.String toString()
          Generates a String with some information about the instance of IRCModeParser.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

IRCModeParser

public IRCModeParser(java.lang.String line)
Analyzes the modes and parses them into the parts operators (+ or -), modes (one character) and optional arguments (one word or number).

Parameters:
line - The modes and the arguments; nothing more.

IRCModeParser

public IRCModeParser(java.lang.String modes,
                     java.lang.String args)
Analyzes the modes and parses them into the parts operators (+ or -), modes (one character) and optional arguments (one word or number).

Parameters:
modes - The modes (for example +oo+m-v).
args - The modes' arguments (for example Heinz Hans Thomas).
Method Detail

getCount

public int getCount()
Returns count of modes.

Returns:
The count of modes.
See Also:
getOperatorAt(int), getModeAt(int), getArgAt(int)

getOperatorAt

public char getOperatorAt(int i)
Returns the operator (+ or -) of a given index.

Parameters:
i - The index of the operator you want to get. The index starts with 1 and not with 0.
Returns:
The operator at the given index (+ or -).
See Also:
getCount(), getModeAt(int), getArgAt(int)

getModeAt

public char getModeAt(int i)
Returns the mode (for example o, v, m, i) of a given index.

Parameters:
i - The index of the mode you want to get. The index starts with 1 and not with 0.
Returns:
The mode of the given index (for example o, v, m, i)
See Also:
getCount(), getOperatorAt(int), getArgAt(int)

getArgAt

public java.lang.String getArgAt(int i)
Returns the nick of a given index.

Parameters:
i - The index of the argument you want to get. The index starts with 1 and not with 0.
Returns:
The argument you requested. It's "" if there's no argument at this index (for example +m for moderated has never an argument).
See Also:
getCount(), getOperatorAt(int), getModeAt(int)

getLine

public java.lang.String getLine()
Returns the line as it was sent from the IRC server. The line contains the the operators, the modes and the nicknames, but not the channel or the nickname who executed the MODE command!

Returns:
The line which was set as argument when the parser was initialized.

toString

public java.lang.String toString()
Generates a String with some information about the instance of IRCModeParser. Its format is: classname[line].

Returns:
A String with information about the instance.