You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

32 lines
785 B

package internal.hw.crawler.commands;
public class InputParser {
private InputParser() {}
public static ParsedInput parse(String input) {
String text = input == null ? "" : input.trim();
if (text.isEmpty()) {
return null;
}
String[] parts = text.split("\\s+");
return new ParsedInput(parts[0].toLowerCase(), parts);
}
public static class ParsedInput {
private final String command;
private final String[] args;
public ParsedInput(String command, String[] args) {
this.command = command;
this.args = args;
}
public String command() {
return command;
}
public String[] args() {
return args;
}
}
}