public final class CommandArgs extends Object
Constructor and Description |
---|
CommandArgs(String rawInput,
List<SingleArg> args)
Create a new CommandArgs instance with the given raw input and arguments.
|
Modifier and Type | Method and Description |
---|---|
ArgumentParseException |
createError(Text message)
Create a parse exception with the provided message which has the position of the last parsed argument attached.
|
List<String> |
getAll()
Get a list of all arguments as a string.
|
String |
getRaw()
Return the raw string used to provide input to this arguments object.
|
int |
getRawPosition()
Get the current position in raw input.
|
Object |
getState()
Return this arguments object's current state.
|
boolean |
hasNext()
Return whether more arguments remain to be read.
|
void |
insertArg(String value)
Insert an arg as the next arg to be returned by
next() . |
String |
next()
Try to read the next argument, advancing the current index if successful.
|
Optional<String> |
nextIfPresent()
Try to read the next argument, advancing the current index if successful or returning an absent optional if not.
|
String |
peek()
Try to read the next argument without advancing the current index.
|
void |
removeArgs(Object startState,
Object endState)
Remove the arguments parsed between startState and endState.
|
void |
setState(Object state)
Restore the arguments object's state to a state previously used.
|
public boolean hasNext()
public String peek() throws ArgumentParseException
ArgumentParseException
- if not enough arguments are presentpublic String next() throws ArgumentParseException
ArgumentParseException
- if not enough arguments are presentpublic Optional<String> nextIfPresent()
public ArgumentParseException createError(Text message)
message
- The message for the exceptionpublic List<String> getAll()
public Object getState()
setState(Object)
method.public void setState(Object state)
state
- the previous statepublic String getRaw()
public void insertArg(String value)
next()
.value
- The argument to insertpublic void removeArgs(Object startState, Object endState)
startState
- The starting stateendState
- The ending statepublic int getRawPosition()