diff --git a/src/org/yaaic/command/BaseCommand.java b/src/org/yaaic/command/BaseHandler.java similarity index 98% rename from src/org/yaaic/command/BaseCommand.java rename to src/org/yaaic/command/BaseHandler.java index 160f6fc..b360cbe 100644 --- a/src/org/yaaic/command/BaseCommand.java +++ b/src/org/yaaic/command/BaseHandler.java @@ -29,7 +29,7 @@ import org.yaaic.model.Server; * * @author Sebastian Kaspari */ -public abstract class BaseCommand +public abstract class BaseHandler { /** * Execute the command diff --git a/src/org/yaaic/command/CommandParser.java b/src/org/yaaic/command/CommandParser.java index 452bd0c..5d52e77 100644 --- a/src/org/yaaic/command/CommandParser.java +++ b/src/org/yaaic/command/CommandParser.java @@ -22,6 +22,18 @@ package org.yaaic.command; import java.util.HashMap; +import org.yaaic.command.handler.DeopHandler; +import org.yaaic.command.handler.DevoiceHandler; +import org.yaaic.command.handler.EchoHandler; +import org.yaaic.command.handler.JoinHandler; +import org.yaaic.command.handler.KickHandler; +import org.yaaic.command.handler.MeHandler; +import org.yaaic.command.handler.NamesHandler; +import org.yaaic.command.handler.NickHandler; +import org.yaaic.command.handler.OpHandler; +import org.yaaic.command.handler.QuitHandler; +import org.yaaic.command.handler.TopicHandler; +import org.yaaic.command.handler.VoiceHandler; import org.yaaic.irc.IRCService; import org.yaaic.model.Broadcast; import org.yaaic.model.Channel; @@ -39,7 +51,7 @@ public class CommandParser { public static final String TAG = "Yaaic/CommandParser"; - private HashMap commands; + private HashMap commands; private static CommandParser instance; /** @@ -47,20 +59,20 @@ public class CommandParser */ private CommandParser() { - commands = new HashMap(); + commands = new HashMap(); - commands.put("nick", new NickCommand()); - commands.put("join", new JoinCommand()); - commands.put("me", new MeCommand()); - commands.put("names", new NamesCommand()); - commands.put("echo", new EchoCommand()); - commands.put("topic", new TopicCommand()); - commands.put("quit", new QuitCommand()); - commands.put("op", new OpCommand()); - commands.put("voice", new VoiceCommand()); - commands.put("deop", new DeopCommand()); - commands.put("devoice", new DevoiceCommand()); - commands.put("kick", new KickCommand()); + commands.put("nick", new NickHandler()); + commands.put("join", new JoinHandler()); + commands.put("me", new MeHandler()); + commands.put("names", new NamesHandler()); + commands.put("echo", new EchoHandler()); + commands.put("topic", new TopicHandler()); + commands.put("quit", new QuitHandler()); + commands.put("op", new OpHandler()); + commands.put("voice", new VoiceHandler()); + commands.put("deop", new DeopHandler()); + commands.put("devoice", new DevoiceHandler()); + commands.put("kick", new KickHandler()); } /** @@ -100,7 +112,7 @@ public class CommandParser String type = params[0]; if (isCommand(type)) { - BaseCommand command = commands.get(type); + BaseHandler command = commands.get(type); try { command.execute(params, server, channel, service); } catch(CommandException e) { diff --git a/src/org/yaaic/command/DeopCommand.java b/src/org/yaaic/command/handler/DeopHandler.java similarity index 89% rename from src/org/yaaic/command/DeopCommand.java rename to src/org/yaaic/command/handler/DeopHandler.java index baeb1a8..24a90c9 100644 --- a/src/org/yaaic/command/DeopCommand.java +++ b/src/org/yaaic/command/handler/DeopHandler.java @@ -18,8 +18,10 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Yaaic. If not, see . */ -package org.yaaic.command; +package org.yaaic.command.handler; +import org.yaaic.command.BaseHandler; +import org.yaaic.command.CommandException; import org.yaaic.irc.IRCService; import org.yaaic.model.Channel; import org.yaaic.model.Server; @@ -29,7 +31,7 @@ import org.yaaic.model.Server; * * @author Sebastian Kaspari */ -public class DeopCommand extends BaseCommand +public class DeopHandler extends BaseHandler { /** * Execute /voice diff --git a/src/org/yaaic/command/DevoiceCommand.java b/src/org/yaaic/command/handler/DevoiceHandler.java similarity index 89% rename from src/org/yaaic/command/DevoiceCommand.java rename to src/org/yaaic/command/handler/DevoiceHandler.java index 76d70d6..f64284e 100644 --- a/src/org/yaaic/command/DevoiceCommand.java +++ b/src/org/yaaic/command/handler/DevoiceHandler.java @@ -18,8 +18,10 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Yaaic. If not, see . */ -package org.yaaic.command; +package org.yaaic.command.handler; +import org.yaaic.command.BaseHandler; +import org.yaaic.command.CommandException; import org.yaaic.irc.IRCService; import org.yaaic.model.Channel; import org.yaaic.model.Server; @@ -29,7 +31,7 @@ import org.yaaic.model.Server; * * @author Sebastian Kaspari */ -public class DevoiceCommand extends BaseCommand +public class DevoiceHandler extends BaseHandler { /** * Execute /devoice diff --git a/src/org/yaaic/command/EchoCommand.java b/src/org/yaaic/command/handler/EchoHandler.java similarity index 87% rename from src/org/yaaic/command/EchoCommand.java rename to src/org/yaaic/command/handler/EchoHandler.java index fc7aa4c..ee59fde 100644 --- a/src/org/yaaic/command/EchoCommand.java +++ b/src/org/yaaic/command/handler/EchoHandler.java @@ -18,8 +18,10 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Yaaic. If not, see . */ -package org.yaaic.command; +package org.yaaic.command.handler; +import org.yaaic.command.BaseHandler; +import org.yaaic.command.CommandException; import org.yaaic.irc.IRCService; import org.yaaic.model.Broadcast; import org.yaaic.model.Channel; @@ -33,7 +35,7 @@ import android.content.Intent; * * @author Sebastian Kaspari */ -public class EchoCommand extends BaseCommand +public class EchoHandler extends BaseHandler { /** * Execute /echo @@ -42,7 +44,7 @@ public class EchoCommand extends BaseCommand public void execute(String[] params, Server server, Channel channel, IRCService service) throws CommandException { if (params.length > 1) { - Message message = new Message(BaseCommand.mergeParams(params)); + Message message = new Message(BaseHandler.mergeParams(params)); channel.addMessage(message); Intent intent = new Intent(Broadcast.CHANNEL_MESSAGE); diff --git a/src/org/yaaic/command/JoinCommand.java b/src/org/yaaic/command/handler/JoinHandler.java similarity index 90% rename from src/org/yaaic/command/JoinCommand.java rename to src/org/yaaic/command/handler/JoinHandler.java index 2a55897..70be71c 100644 --- a/src/org/yaaic/command/JoinCommand.java +++ b/src/org/yaaic/command/handler/JoinHandler.java @@ -18,8 +18,10 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Yaaic. If not, see . */ -package org.yaaic.command; +package org.yaaic.command.handler; +import org.yaaic.command.BaseHandler; +import org.yaaic.command.CommandException; import org.yaaic.irc.IRCService; import org.yaaic.model.Channel; import org.yaaic.model.Server; @@ -29,7 +31,7 @@ import org.yaaic.model.Server; * * @author Sebastian Kaspari */ -public class JoinCommand extends BaseCommand +public class JoinHandler extends BaseHandler { /** * Execute /join diff --git a/src/org/yaaic/command/KickCommand.java b/src/org/yaaic/command/handler/KickHandler.java similarity index 89% rename from src/org/yaaic/command/KickCommand.java rename to src/org/yaaic/command/handler/KickHandler.java index d0b7150..00ba39d 100644 --- a/src/org/yaaic/command/KickCommand.java +++ b/src/org/yaaic/command/handler/KickHandler.java @@ -18,8 +18,10 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Yaaic. If not, see . */ -package org.yaaic.command; +package org.yaaic.command.handler; +import org.yaaic.command.BaseHandler; +import org.yaaic.command.CommandException; import org.yaaic.irc.IRCService; import org.yaaic.model.Channel; import org.yaaic.model.Server; @@ -31,7 +33,7 @@ import org.yaaic.model.Server; * * @author Sebastian Kaspari */ -public class KickCommand extends BaseCommand +public class KickHandler extends BaseHandler { /** * Execute /kick diff --git a/src/org/yaaic/command/MeCommand.java b/src/org/yaaic/command/handler/MeHandler.java similarity index 89% rename from src/org/yaaic/command/MeCommand.java rename to src/org/yaaic/command/handler/MeHandler.java index d9f7d2a..00eceb5 100644 --- a/src/org/yaaic/command/MeCommand.java +++ b/src/org/yaaic/command/handler/MeHandler.java @@ -18,9 +18,11 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Yaaic. If not, see . */ -package org.yaaic.command; +package org.yaaic.command.handler; import org.yaaic.R; +import org.yaaic.command.BaseHandler; +import org.yaaic.command.CommandException; import org.yaaic.irc.IRCService; import org.yaaic.model.Broadcast; import org.yaaic.model.Channel; @@ -34,7 +36,7 @@ import android.content.Intent; * * @author Sebastian Kaspari */ -public class MeCommand extends BaseCommand +public class MeHandler extends BaseHandler { /** * Execute /me @@ -43,7 +45,7 @@ public class MeCommand extends BaseCommand public void execute(String[] params, Server server, Channel channel, IRCService service) throws CommandException { if (params.length > 1) { - String action = BaseCommand.mergeParams(params); + String action = BaseHandler.mergeParams(params); String nickname = service.getConnection(server.getId()).getNick(); Message message = new Message(nickname + " " + action); diff --git a/src/org/yaaic/command/NamesCommand.java b/src/org/yaaic/command/handler/NamesHandler.java similarity index 92% rename from src/org/yaaic/command/NamesCommand.java rename to src/org/yaaic/command/handler/NamesHandler.java index d247e2b..0d1994a 100644 --- a/src/org/yaaic/command/NamesCommand.java +++ b/src/org/yaaic/command/handler/NamesHandler.java @@ -18,9 +18,11 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Yaaic. If not, see . */ -package org.yaaic.command; +package org.yaaic.command.handler; import org.jibble.pircbot.User; +import org.yaaic.command.BaseHandler; +import org.yaaic.command.CommandException; import org.yaaic.irc.IRCService; import org.yaaic.model.Broadcast; import org.yaaic.model.Channel; @@ -35,7 +37,7 @@ import android.content.Intent; * * @author Sebastian Kaspari */ -public class NamesCommand extends BaseCommand +public class NamesHandler extends BaseHandler { /** * Execute /names diff --git a/src/org/yaaic/command/NickCommand.java b/src/org/yaaic/command/handler/NickHandler.java similarity index 89% rename from src/org/yaaic/command/NickCommand.java rename to src/org/yaaic/command/handler/NickHandler.java index ab33bd5..96aace1 100644 --- a/src/org/yaaic/command/NickCommand.java +++ b/src/org/yaaic/command/handler/NickHandler.java @@ -18,8 +18,10 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Yaaic. If not, see . */ -package org.yaaic.command; +package org.yaaic.command.handler; +import org.yaaic.command.BaseHandler; +import org.yaaic.command.CommandException; import org.yaaic.irc.IRCService; import org.yaaic.model.Channel; import org.yaaic.model.Server; @@ -29,7 +31,7 @@ import org.yaaic.model.Server; * * @author Sebastian Kaspari */ -public class NickCommand extends BaseCommand +public class NickHandler extends BaseHandler { /** * Execute /nick diff --git a/src/org/yaaic/command/OpCommand.java b/src/org/yaaic/command/handler/OpHandler.java similarity index 89% rename from src/org/yaaic/command/OpCommand.java rename to src/org/yaaic/command/handler/OpHandler.java index f635a86..5d5f1df 100644 --- a/src/org/yaaic/command/OpCommand.java +++ b/src/org/yaaic/command/handler/OpHandler.java @@ -18,8 +18,10 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Yaaic. If not, see . */ -package org.yaaic.command; +package org.yaaic.command.handler; +import org.yaaic.command.BaseHandler; +import org.yaaic.command.CommandException; import org.yaaic.irc.IRCService; import org.yaaic.model.Channel; import org.yaaic.model.Server; @@ -29,7 +31,7 @@ import org.yaaic.model.Server; * * @author Sebastian Kaspari */ -public class OpCommand extends BaseCommand +public class OpHandler extends BaseHandler { /** * Execute /deop diff --git a/src/org/yaaic/command/QuitCommand.java b/src/org/yaaic/command/handler/QuitHandler.java similarity index 85% rename from src/org/yaaic/command/QuitCommand.java rename to src/org/yaaic/command/handler/QuitHandler.java index 5191925..6a3e19f 100644 --- a/src/org/yaaic/command/QuitCommand.java +++ b/src/org/yaaic/command/handler/QuitHandler.java @@ -18,8 +18,10 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Yaaic. If not, see . */ -package org.yaaic.command; +package org.yaaic.command.handler; +import org.yaaic.command.BaseHandler; +import org.yaaic.command.CommandException; import org.yaaic.irc.IRCService; import org.yaaic.model.Channel; import org.yaaic.model.Server; @@ -29,7 +31,7 @@ import org.yaaic.model.Server; * * @author Sebastian Kaspari */ -public class QuitCommand extends BaseCommand +public class QuitHandler extends BaseHandler { /** * Execute /quit @@ -40,7 +42,7 @@ public class QuitCommand extends BaseCommand if (params.length == 1) { service.getConnection(server.getId()).quitServer(); } else { - service.getConnection(server.getId()).quitServer(BaseCommand.mergeParams(params)); + service.getConnection(server.getId()).quitServer(BaseHandler.mergeParams(params)); } } diff --git a/src/org/yaaic/command/TopicCommand.java b/src/org/yaaic/command/handler/TopicHandler.java similarity index 90% rename from src/org/yaaic/command/TopicCommand.java rename to src/org/yaaic/command/handler/TopicHandler.java index 40a508b..d0cc315 100644 --- a/src/org/yaaic/command/TopicCommand.java +++ b/src/org/yaaic/command/handler/TopicHandler.java @@ -18,8 +18,9 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Yaaic. If not, see . */ -package org.yaaic.command; +package org.yaaic.command.handler; +import org.yaaic.command.BaseHandler; import org.yaaic.irc.IRCService; import org.yaaic.model.Channel; import org.yaaic.model.Server; @@ -31,7 +32,7 @@ import org.yaaic.model.Server; * * @author Sebastian Kaspari */ -public class TopicCommand extends BaseCommand +public class TopicHandler extends BaseHandler { /** * Execute /topic @@ -44,7 +45,7 @@ public class TopicCommand extends BaseCommand service.getConnection(server.getId()).onTopic(channel.getName(), channel.getTopic(), "", 0, false); } else if (params.length > 1) { // Change topic - service.getConnection(server.getId()).setTopic(channel.getName(), BaseCommand.mergeParams(params)); + service.getConnection(server.getId()).setTopic(channel.getName(), BaseHandler.mergeParams(params)); } } diff --git a/src/org/yaaic/command/VoiceCommand.java b/src/org/yaaic/command/handler/VoiceHandler.java similarity index 89% rename from src/org/yaaic/command/VoiceCommand.java rename to src/org/yaaic/command/handler/VoiceHandler.java index e9c9cbb..e5ee8e2 100644 --- a/src/org/yaaic/command/VoiceCommand.java +++ b/src/org/yaaic/command/handler/VoiceHandler.java @@ -18,8 +18,10 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Yaaic. If not, see . */ -package org.yaaic.command; +package org.yaaic.command.handler; +import org.yaaic.command.BaseHandler; +import org.yaaic.command.CommandException; import org.yaaic.irc.IRCService; import org.yaaic.model.Channel; import org.yaaic.model.Server; @@ -29,7 +31,7 @@ import org.yaaic.model.Server; * * @author Sebastian Kaspari */ -public class VoiceCommand extends BaseCommand +public class VoiceHandler extends BaseHandler { /** * Execute /voice