| 
 | |||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectorg.schwering.irc.lib.IRCParser
Parses a line sent from the IRC server.
 Note: Probably this class is unimportant for you. It's used by the
 IRCConnection to parse incoming lines. Nevertheless I declared
 it as public because you might want to use it to parse IRC 
 command-shortcuts like MSG instead of PRIVMSG in 
 your client.
 The following text goes on with the description of the class and what it
 does.
 
According with RFC1459 it divides the line into a prefix, a command and its parameters.
 The prefix is only given if a line starts with a : (colon) 
 and is used to indicate from where the line is send.
 
The next word in the line (if no prefix exists it is the first, else the second word) is the command. The command is eiter a valid IRC command or a three-digit number which represents a numeric reply or a numeric error.
 The parameters are divided into a middle and a trailing part. 
 In the middle part one word means one parameter while the trailing part is 
 just one parameter independent from the amount of words in it. 
 If there is a  " :" (space+colon) in the line, this point 
 means the beginning of the trailing.
 If there is no such space+colon, the trailing is just the last word. 
 All words behind the space+colon mean just one parameter.
 If there is only one parameter given (the parameter is the first, the last 
 and the only one), the parameter is available as trailing (with 
 getTrailing), not as middle!
 
One line may have up to 15 parameters. Therefore up to 14 are middle and one is the trailing.
The line may have up to 510 characters plus the CR-LF (carriage return - line feed) which trails the incoming line.
The following extract of the RFC1459 shows the message format in BNF:
 <message>  ::=
 [':' <prefix> <SPACE> ] <command> <params> 
 <crlf> 
 <prefix>   ::=
 <servername> | <nick> 
 [ '!' <username> ] [ '@' <host> ]
 
 <command>  ::=
 <letter> { <letter> } | <number> <number> 
 <number> 
 <SPACE>    ::=
 ' ' { ' ' }
 <params>   ::=
 <SPACE> [ ':' <trailing> | <middle> <params> ] 
 <middle>   ::=
 <Any *non-empty* sequence of octets not including SPACE or NUL or CR or 
 LF, the first of which may not be ':'> 
 <trailing> ::=
 <Any, possibly *empty*, sequence of octets not including NUL or CR or 
 LF> 
 <crlf>     ::=
 CR LF
 
IRCConnection| Constructor Summary | |
| IRCParser(java.lang.String line)Parses the line after erasing all mIRC color codes. | |
| IRCParser(java.lang.String line,
          boolean colorsEnabled)The main constructor. | |
| Method Summary | |
|  java.lang.String | getCommand()Returns the line's command. | 
|  java.lang.String | getHost()Returns the host of the person who sent the line. | 
|  java.lang.String | getLine()Returns the unparsed line. | 
|  java.lang.String | getMiddle()Returns the line's middle. | 
|  java.lang.String | getNick()Returns the nickname of the person who sent the line or the servername of the server which sent the line. | 
|  java.lang.String | getParameter(int i)Get one parameter of the line. | 
|  int | getParameterCount()Gets count of parameters. | 
|  java.lang.String | getParameters()Returns the line's parameters which consists of the middle and the trailing. | 
|  java.lang.String | getParametersFrom(int i)Grabs the line's parameters from the ith to the last 
 parameter (including theith). | 
|  java.lang.String | getParametersTo(int i)Grabs the line's parameters from the first to the ith 
 parameters (including theith). | 
|  java.lang.String | getPrefix()Returns the line's prefix. | 
|  java.lang.String | getServername()Returns the servername of the server which sent the line or the nickname of the person who sent the line. | 
|  java.lang.String | getTrailing()Returns the line's trailing. | 
|  IRCUser | getUser()Returns a new IRCUserobject. | 
|  java.lang.String | getUsername()Returns the username of the person who sent the line. | 
|  java.lang.String | toString()Generates a Stringwith some information about the instance ofIRCParser. | 
| Methods inherited from class java.lang.Object | 
| equals, getClass, hashCode, notify, notifyAll, wait, wait, wait | 
| Constructor Detail | 
public IRCParser(java.lang.String line)
IRCParser(line, false).
line - The line which will be parsed.
public IRCParser(java.lang.String line,
                 boolean colorsEnabled)
line - The line which will be parsed.colorsEnabled - If false, mIRC color codes are parsed out
                      by using IRCUtil.parseColors method.| Method Detail | 
public java.lang.String getPrefix()
"" is 
 returned; but in fact there's always a prefix.
public java.lang.String getCommand()
public java.lang.String getMiddle()
public java.lang.String getTrailing()
public java.lang.String getLine()
public java.lang.String getParameters()
public java.lang.String getNick()
 <servername> | <nick> 
 [ '!' <username> ] [ '@' <host> ]
 null is returned.
 getServername!
 getUser which returns
 an IRCUser object which holds the nickname, username and host.
 By the way, the getUser uses the getNick, 
 getUsername and getHost methods to create this
 object.
null is returned.getServername(), 
getUsername(), 
getHost(), 
getUser()public java.lang.String getServername()
 <servername> | <nick> 
 [ '!' <username> ] [ '@' <host> ]
 null is returned.
 getNick!
 getUser which returns
 an IRCUser object which holds the nickname, username and host.
 By the way, the getUser uses the getNick, 
 getUsername and getHost methods to create this
 object.
null is returned.getNick(), 
getUser()public java.lang.String getUsername()
 <servername> | <nick> 
 [ '!' <username> ] [ '@' <host> ]
 null.
 getUser which returns
 an IRCUser object which holds the nickname, username and host.
 By the way, the getUser uses the getNick, 
 getUsername and getHost methods to create this
 object.
null if it's not given.getNick(), 
getHost(), 
getUser()public java.lang.String getHost()
 <servername> | <nick> 
 [ '!' <username> ] [ '@' <host> ]
 null.
 getUser which returns
 an IRCUser object which holds the nickname, username and host.
 By the way, the getUser uses the getNick, 
 getUsername and getHost methods to create this
 object.
null if it's not given.getNick(), 
getUsername(), 
getUser()public IRCUser getUser()
IRCUser object.
 This method is equal to new IRCUser(IRCParser.getNick(), 
 IRCParser.getUsername(), IRCParser.getHost()). See those methods to
 learn which value they return if they are not set.
IRCUser object with exactly those values which
         are returned by the getNick, getUsername 
         and getHost methods.getNick(), 
getUsername(), 
getHost()public int getParameterCount()
parameters isn't initialized yet, it calls 
 initParameters to do that.
public java.lang.String getParameter(int i)
parameters isn't initialized yet, it calls 
 initParameters to do that.
i - The index of the parameter you want to get. The index starts with 
          1 and not with 0.
ith parameter. If i is out of bounds,
         "" is returned.public java.lang.String getParametersFrom(int i)
ith to the last 
 parameter (including the ith).
 If parameters isn't initialized yet, it calls 
 initParameters to do that.
i - The index of the first parameter you want to get.
ith. 
         If i is out of bounds, "" is returned.public java.lang.String getParametersTo(int i)
ith 
 parameters (including the ith).
 If parameters isn't initialized yet, it calls 
 initParameters to do that.
i - The index of the last parameter you want to get.
ith.  If i is out of bounds, 
         "" is returned.public java.lang.String toString()
String with some information about the instance of
 IRCParser.classname[prefix,command,middle,trailing].
String with information about the instance.| 
 | |||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||