org.schwering.irc.lib
Class IRCUtil

java.lang.Object
  extended byorg.schwering.irc.lib.IRCUtil
All Implemented Interfaces:
IRCConstants

public class IRCUtil
extends java.lang.Object
implements IRCConstants

Contains some utilities like numeric error and reply numbers.

The most description of the numeric errors and numeric replies are copied from RFC1459.

Version:
2.03
Author:
Christoph Schwering <schwering@gmail.com>, Normton <normton@latinmail.com>
See Also:
IRCConnection, IRCEventListener.onError(int, String), IRCEventListener.onReply(int, String, String)

Field Summary
static char actionIndicator
          Deprecated. Moved to IRCConstants.
static char boldIndicator
          Deprecated. Moved to IRCConstants.
static char colorEndIndicator
          Deprecated. Moved to IRCConstants.
static char colorIndicator
          Deprecated. Moved to IRCConstants.
static char colorReverseIndicator
          Deprecated. Moved to IRCConstants.
static char underlinedIndicator
          Deprecated. Moved to IRCConstants.
 
Fields inherited from interface org.schwering.irc.lib.IRCConstants
ACTION_INDICATOR, BOLD_INDICATOR, COLOR_END_INDICATOR, COLOR_INDICATOR, COLOR_REVERSE_INDICATOR, ERR_ALREADYREGISTRED, ERR_BADCHANMASK, ERR_BADCHANNELKEY, ERR_BANNEDFROMCHAN, ERR_CANNOTSENDTOCHAN, ERR_CANTKILLSERVER, ERR_CHANNELISFULL, ERR_CHANOPRIVSNEEDED, ERR_ERRONEUSNICKNAME, ERR_FILEERROR, ERR_INVITEONLYCHAN, ERR_KEYSET, ERR_NEEDMOREPARAMS, ERR_NICKCOLLISION, ERR_NICKNAMEINUSE, ERR_NOADMININFO, ERR_NOLOGIN, ERR_NOMOTD, ERR_NONICKNAMEGIVEN, ERR_NOOPERHOST, ERR_NOORIGIN, ERR_NOPERMFORHOST, ERR_NOPRIVILEGES, ERR_NORECIPIENT, ERR_NOSERVICEHOST, ERR_NOSUCHCHANNEL, ERR_NOSUCHNICK, ERR_NOSUCHSERVER, ERR_NOTEXTTOSEND, ERR_NOTONCHANNEL, ERR_NOTOPLEVEL, ERR_NOTREGISTERED, ERR_PASSWDMISMATCH, ERR_SUMMONDISABLED, ERR_TOOMANYCHANNELS, ERR_TOOMANYTARGETS, ERR_UMODEUNKNOWNFLAG, ERR_UNKNOWNCOMMAND, ERR_UNKNOWNMODE, ERR_USERNOTINCHANNEL, ERR_USERONCHANNEL, ERR_USERSDISABLED, ERR_USERSDONTMATCH, ERR_WASNOSUCHNICK, ERR_WILDTOPLEVEL, ERR_YOUREBANNEDCREEP, ERR_YOUWILLBEBANNED, RPL_ADMINEMAIL, RPL_ADMINLOC1, RPL_ADMINLOC2, RPL_ADMINME, RPL_AUTHNAME, RPL_AWAY, RPL_BANLIST, RPL_CHANNELMODEIS, RPL_CLOSEEND, RPL_CLOSING, RPL_CREATED, RPL_ENDOFBANLIST, RPL_ENDOFINFO, RPL_ENDOFLINKS, RPL_ENDOFMOTD, RPL_ENDOFNAMES, RPL_ENDOFSERVICES, RPL_ENDOFSTATS, RPL_ENDOFUSERS, RPL_ENDOFWHO, RPL_ENDOFWHOIS, RPL_ENDOFWHOWAS, RPL_INFO, RPL_INFOSTART, RPL_INVITING, RPL_ISON, RPL_ISUPPORT, RPL_KILLDONE, RPL_LINKS, RPL_LIST, RPL_LISTEND, RPL_LISTSTART, RPL_LUSERCHANNELS, RPL_LUSERCLIENT, RPL_LUSERME, RPL_LUSEROP, RPL_LUSERUNKNOWN, RPL_MOTD, RPL_MOTDSTART, RPL_MYINFO, RPL_MYPORTIS, RPL_NAMREPLY, RPL_NONE, RPL_NOTOPIC, RPL_NOUSERS, RPL_NOWAWAY, RPL_REHASHING, RPL_SERVICE, RPL_SERVICEINFO, RPL_SERVLIST, RPL_SERVLISTEND, RPL_STATSCLINE, RPL_STATSCOMMANDS, RPL_STATSHLINE, RPL_STATSILINE, RPL_STATSKLINE, RPL_STATSLINKINFO, RPL_STATSLLINE, RPL_STATSNLINE, RPL_STATSOLINE, RPL_STATSQLINE, RPL_STATSUPTIME, RPL_STATSYLINE, RPL_SUMMONING, RPL_TIME, RPL_TOPIC, RPL_TOPICINFO, RPL_TRACECLASS, RPL_TRACECONNECTING, RPL_TRACEHANDSHAKE, RPL_TRACELINK, RPL_TRACELOG, RPL_TRACENEWTYPE, RPL_TRACEOPERATOR, RPL_TRACESERVER, RPL_TRACEUNKNOWN, RPL_TRACEUSER, RPL_UMODEIS, RPL_UNAWAY, RPL_USERHOST, RPL_USERS, RPL_USERSSTART, RPL_VERSION, RPL_WELCOME, RPL_WHOISCHANNELS, RPL_WHOISCHANOP, RPL_WHOISIDLE, RPL_WHOISOPERATOR, RPL_WHOISSERVER, RPL_WHOISUSER, RPL_WHOREPLY, RPL_WHOWASUSER, RPL_YOUREOPER, RPL_YOURHOST, UNDERLINE_INDICATOR
 
Method Summary
static boolean isChan(java.lang.String str)
          According to RFC2812 the channel's name may and must start with one of the following characters.
static java.lang.String parseColors(java.lang.String str)
          Erases the mIRC colorcodes from a String.
static java.lang.StringBuffer parseColors(java.lang.StringBuffer buf)
          Erases the mIRC colorcodes from a String.
static int parseInt(java.lang.String str)
          Parses a String to an int via Integer.parseInt but avoids the NumberFormatException.
static java.lang.String[] split(java.lang.String str, int delim)
          Splits a string into substrings.
static java.lang.String[] split(java.lang.String str, int delim, java.lang.String trailing)
          Splits a string into substrings.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

colorIndicator

public static char colorIndicator
Deprecated. Moved to IRCConstants.

This is part of the mIRC code and shows that a color-code starts / ends. Here it is as the ASCII decimal int 3.


boldIndicator

public static char boldIndicator
Deprecated. Moved to IRCConstants.

This is part of the mIRC code and shows that bold starts / ends. Here it is as the ASCII decimal int 32.


underlinedIndicator

public static char underlinedIndicator
Deprecated. Moved to IRCConstants.

This is part of the mIRC code and shows that bold starts / ends. Here it is as the ASCII decimal int 2.


colorEndIndicator

public static char colorEndIndicator
Deprecated. Moved to IRCConstants.

This is part of the mIRC code and shows that bold, underline and colors end. Here it is as the ASCII decimal int 15.


colorReverseIndicator

public static char colorReverseIndicator
Deprecated. Moved to IRCConstants.

This is part of the mIRC code and indicates that the client's colors are reversed (background -> foreground and foreground -> background). Here it is as the ASCII decimal int 1.


actionIndicator

public static char actionIndicator
Deprecated. Moved to IRCConstants.

This is part of the mIRC code and shows that a PRIVMSG is an ACTION (/me). Here it is as the ASCII decimal int 22.

Method Detail

isChan

public static boolean isChan(java.lang.String str)
According to RFC2812 the channel's name may and must start with one of the following characters. .

Parameters:
str - The name to check if it's a channel.
Returns:
true if the argument starts with one of the characters mentioned above.

parseInt

public static int parseInt(java.lang.String str)
Parses a String to an int via Integer.parseInt but avoids the NumberFormatException.

Parameters:
str - The String to parse.
Returns:
The parsed new int. -1 if NumberFormatException was thrown.

parseColors

public static java.lang.String parseColors(java.lang.String str)
Erases the mIRC colorcodes from a String. The documentation of the evil color codes is available on http://www.mirc.co.uk/help/color.txt. This method links to the parseColors(StringBuffer) method.

Parameters:
str - The line which should be parsed.
Returns:
A line cleaned from any mIRC colorcodes.
See Also:
parseColors(StringBuffer)

parseColors

public static java.lang.StringBuffer parseColors(java.lang.StringBuffer buf)
Erases the mIRC colorcodes from a String. The documentation of the evil color codes is available on http://www.mirc.co.uk/help/color.txt.

Parameters:
buf - The line which should be parsed.
Returns:
A line as StringBuffer object which is cleaned from any mIRC colorcodes.
See Also:
parseColors(String)

split

public static java.lang.String[] split(java.lang.String str,
                                       int delim,
                                       java.lang.String trailing)
Splits a string into substrings.

Parameters:
str - The string which is to split.
delim - The delimiter character, for example a space ' '.
trailing - The ending which is added as a substring though it wasn't in the str. This parameter is just for the IRCParser class which uses this method to split the middle part into the parameters. But as last parameter always the trailing is added. This is done here because it's the fastest way to do it here.
If the end is null or "", nothing is appended.
Returns:
An array with all substrings.
See Also:
split(String, int)

split

public static java.lang.String[] split(java.lang.String str,
                                       int delim)
Splits a string into substrings. This method is totally equal to split(str, delim, null).

Parameters:
str - The string which is to split.
delim - The delimiter character, for example a space ' '.
Returns:
An array with all substrings.
See Also:
split(String, int, String)