1
0
mirror of https://github.com/moparisthebest/Yaaic synced 2024-12-26 01:18:57 -05:00

Moved command handlers to org.yaaic.command.handler and renamend them.

This commit is contained in:
Sebastian Kaspari 2010-03-10 09:01:49 +01:00
parent 0342c6ea7f
commit 64c7ad2f45
14 changed files with 79 additions and 44 deletions

View File

@ -29,7 +29,7 @@ import org.yaaic.model.Server;
*
* @author Sebastian Kaspari <sebastian@yaaic.org>
*/
public abstract class BaseCommand
public abstract class BaseHandler
{
/**
* Execute the command

View File

@ -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<String, BaseCommand> commands;
private HashMap<String, BaseHandler> commands;
private static CommandParser instance;
/**
@ -47,20 +59,20 @@ public class CommandParser
*/
private CommandParser()
{
commands = new HashMap<String, BaseCommand>();
commands = new HashMap<String, BaseHandler>();
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) {

View File

@ -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 <http://www.gnu.org/licenses/>.
*/
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 <sebastian@yaaic.org>
*/
public class DeopCommand extends BaseCommand
public class DeopHandler extends BaseHandler
{
/**
* Execute /voice

View File

@ -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 <http://www.gnu.org/licenses/>.
*/
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 <sebastian@yaaic.org>
*/
public class DevoiceCommand extends BaseCommand
public class DevoiceHandler extends BaseHandler
{
/**
* Execute /devoice

View File

@ -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 <http://www.gnu.org/licenses/>.
*/
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 <sebastian@yaaic.org>
*/
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);

View File

@ -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 <http://www.gnu.org/licenses/>.
*/
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 <sebastian@yaaic.org>
*/
public class JoinCommand extends BaseCommand
public class JoinHandler extends BaseHandler
{
/**
* Execute /join

View File

@ -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 <http://www.gnu.org/licenses/>.
*/
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 <sebastian@yaaic.org>
*/
public class KickCommand extends BaseCommand
public class KickHandler extends BaseHandler
{
/**
* Execute /kick

View File

@ -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 <http://www.gnu.org/licenses/>.
*/
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 <sebastian@yaaic.org>
*/
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);

View File

@ -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 <http://www.gnu.org/licenses/>.
*/
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 <sebastian@yaaic.org>
*/
public class NamesCommand extends BaseCommand
public class NamesHandler extends BaseHandler
{
/**
* Execute /names

View File

@ -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 <http://www.gnu.org/licenses/>.
*/
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 <sebastian@yaaic.org>
*/
public class NickCommand extends BaseCommand
public class NickHandler extends BaseHandler
{
/**
* Execute /nick

View File

@ -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 <http://www.gnu.org/licenses/>.
*/
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 <sebastian@yaaic.org>
*/
public class OpCommand extends BaseCommand
public class OpHandler extends BaseHandler
{
/**
* Execute /deop

View File

@ -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 <http://www.gnu.org/licenses/>.
*/
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 <sebastian@yaaic.org>
*/
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));
}
}

View File

@ -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 <http://www.gnu.org/licenses/>.
*/
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 <sebastian@yaaic.org>
*/
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));
}
}

View File

@ -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 <http://www.gnu.org/licenses/>.
*/
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 <sebastian@yaaic.org>
*/
public class VoiceCommand extends BaseCommand
public class VoiceHandler extends BaseHandler
{
/**
* Execute /voice