diff options
author | snowleo <schneeleo@gmail.com> | 2011-10-12 05:00:36 +0200 |
---|---|---|
committer | snowleo <schneeleo@gmail.com> | 2011-10-12 05:00:36 +0200 |
commit | d187c58f30b2ec2a1a1fa50208f7724a69f78390 (patch) | |
tree | 7340c417f82803f23869667fc1562ef9f61095d6 /EssentialsUpdate/src/f00f/net/irc/martyr/util/CtcpUtil.java | |
parent | ea192ddd6d5b538e0bd0f6f1721890eb3c25de30 (diff) | |
download | Essentials-d187c58f30b2ec2a1a1fa50208f7724a69f78390.tar Essentials-d187c58f30b2ec2a1a1fa50208f7724a69f78390.tar.gz Essentials-d187c58f30b2ec2a1a1fa50208f7724a69f78390.tar.lz Essentials-d187c58f30b2ec2a1a1fa50208f7724a69f78390.tar.xz Essentials-d187c58f30b2ec2a1a1fa50208f7724a69f78390.zip |
Replacing martyr with Pircbot 1.5
Diffstat (limited to 'EssentialsUpdate/src/f00f/net/irc/martyr/util/CtcpUtil.java')
-rw-r--r-- | EssentialsUpdate/src/f00f/net/irc/martyr/util/CtcpUtil.java | 99 |
1 files changed, 0 insertions, 99 deletions
diff --git a/EssentialsUpdate/src/f00f/net/irc/martyr/util/CtcpUtil.java b/EssentialsUpdate/src/f00f/net/irc/martyr/util/CtcpUtil.java deleted file mode 100644 index ed31c46e7..000000000 --- a/EssentialsUpdate/src/f00f/net/irc/martyr/util/CtcpUtil.java +++ /dev/null @@ -1,99 +0,0 @@ -package f00f.net.irc.martyr.util; - -import java.util.NoSuchElementException; - -public class CtcpUtil -{ - public static final char CTCP_TAG_DELIM = '\001'; - - /** - * Returns a new string ready for sending via MessageCommand. - * - * @param action Action string to create - * @return Action string ready for sending - */ - public static String makeActionString( String action ) - { - return makeCtcpString( "ACTION " + action ); - } - - public static String makeCtcpString( String s ) - { - return "" + CTCP_TAG_DELIM + s + CTCP_TAG_DELIM; - } - - /** - * Parses the string into tokens, where each token is either a - * CTCP escaped sequence or not. - */ - public static class CtcpTokenizer - { - private String str; - - public CtcpTokenizer( String in ) - { - this.str = in; - } - - public boolean isNextACtcp() - { - return str.charAt(0) == CTCP_TAG_DELIM; - } - - public boolean hasNext() - { - return !str.equals(""); - } - - public String next() - { - return nextToken(); - } - public String nextToken() - { - if( !hasNext() ) - { - throw new NoSuchElementException(); - } - - int pos = str.indexOf( CTCP_TAG_DELIM, 1 ); - String result; - if( isNextACtcp() ) - { - if( pos < 0 ) - { - // Error? Well, whatever, return the rest of the - // string. - result = str.substring( 1 ); - str = ""; - return result; - } - else - { - // ^Aour string^A(rest of string) - // Lose both ^A - result = str.substring( 1, pos ); - str = str.substring( pos + 1 ); - return result; - } - } - else - { - // Not a CTCP - if( pos < 0 ) - { - result = str; - str = ""; - return result; - } - else - { - result = str.substring( 0, pos ); - str = str.substring( pos ); - return result; - } - } - } - } -} - |