Package com.github.mafelp.utils
Class CommandParser
java.lang.Object
com.github.mafelp.utils.CommandParser
Class to create new Commands
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic Command
parseFromArray(String[] inputCommandArray)
method for parsing commands and arguments into the command class.static Command
parseFromString(String commandArgumentString)
method for parsing commands and arguments into the command class.
-
Constructor Details
-
CommandParser
public CommandParser()
-
-
Method Details
-
parseFromString
public static Command parseFromString(String commandArgumentString) throws CommandNotFinishedException, NoCommandGivenExceptionmethod for parsing commands and arguments into the command class.- Parameters:
commandArgumentString
- command and arguments contained in a string.- Returns:
- the command parsed from the string
- Throws:
CommandNotFinishedException
- if the command has an uneven number of quotation marks.NoCommandGivenException
- if the input is null.
-
parseFromArray
public static Command parseFromArray(String[] inputCommandArray) throws NoCommandGivenException, CommandNotFinishedExceptionmethod for parsing commands and arguments into the command class.- Parameters:
inputCommandArray
- the array to parse the commands from- Returns:
- the built command
- Throws:
NoCommandGivenException
- if no command was given, the input is null or has a length of 0 aka. is empty.CommandNotFinishedException
- if there is an uneven number of quotation marks.
-