Package org.schwering.irc.lib
Class IRCModeParser
- java.lang.Object
-
- org.schwering.irc.lib.IRCModeParser
-
public class IRCModeParser extends java.lang.Object
Parses channel-modes.An instance of this class is an argument of the
. It's intended to help the programmer to work with the modes.IRCEventListener.onMode(String chan, IRCUser user, IRCModeParser modeParser)
Channelmodes are:
- +/- o nick
- +/- v nick
- +/- b banmask
- +/- l limit
- +/- k key
- +/- p
- +/- s
- +/- i
- +/- t
- +/- n
- +/- m
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.
- See Also:
IRCEventListener
-
-
Constructor Summary
Constructors Constructor Description 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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description 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 exampleo
,v
,m
,i
) of a given index.char
getOperatorAt(int i)
Returns the operator (+
or-
) of a given index.java.lang.String
toString()
Generates aString
with some information about the instance ofIRCModeParser
.
-
-
-
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 exampleHeinz 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 with1
and not with0
.- 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 exampleo
,v
,m
,i
) of a given index.- Parameters:
i
- The index of the mode you want to get. The index starts with1
and not with0
.- 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 with1
and not with0
.- 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 aString
with some information about the instance ofIRCModeParser
. Its format is:classname[line]
.- Overrides:
toString
in classjava.lang.Object
- Returns:
- A
String
with information about the instance.
-
-