com.khubla.telnet.shell.command.AbstractTelnetCommandRegistry Maven / Gradle / Ivy
/*
* Copyright (C) khubla.com - All Rights Reserved
* Unauthorized copying of this file, via any medium is strictly prohibited
* Proprietary and confidential
* Written by Tom Everett , 2018
*/
package com.khubla.telnet.shell.command;
import java.util.HashMap;
public abstract class AbstractTelnetCommandRegistry implements TelnetCommandRegistry {
/**
* commands
*/
private final HashMap commands = new HashMap();
@Override
public void addCommand(TelnetCommand telnetCommand) {
final String[] names = telnetCommand.getNames();
for (final String name : names) {
commands.put(name, telnetCommand);
}
}
@Override
public TelnetCommand getCommand(String line) {
if (line.length() > 0) {
final String[] parts = line.split(" ");
return commands.get(parts[0]);
}
return null;
}
}