public class ContextArgumentStack extends java.lang.Object implements ArgumentStack
CommandContext
into a stack of arguments
that can be consumed.a user of this class
Constructor and Description |
---|
ContextArgumentStack(CommandContext context)
Create a new instance using the given context.
|
Modifier and Type | Method and Description |
---|---|
java.lang.String |
getConsumed()
Return the arguments that were consumed between this point and that marked point.
|
CommandContext |
getContext()
Get the underlying context.
|
java.lang.String |
getUnconsumed()
Get the unconsumed arguments left over, without touching the stack.
|
void |
mark()
Mark the current position of the stack.
|
void |
markConsumed()
Set as completely consumed.
|
java.lang.String |
next()
Get the next string, which may come from the stack or a value flag.
|
java.lang.Boolean |
nextBoolean()
Get the next boolean, which may come from the stack or a value flag.
|
java.lang.Double |
nextDouble()
Get the next double, which may come from the stack or a value flag.
|
java.lang.Integer |
nextInt()
Get the next integer, which may come from the stack or a value flag.
|
int |
position()
Return the current position.
|
java.lang.String |
remaining()
Get all remaining string values, which will consume the rest of the stack.
|
java.lang.String |
reset()
Reset to the previously
mark() ed position of the stack, and return
the arguments that were consumed between this point and that previous point. |
boolean |
wasConsumed()
Return whether any arguments were consumed between the marked position
and the current position.
|
public ContextArgumentStack(CommandContext context)
context
- the contextpublic java.lang.String next() throws ParameterException
ArgumentStack
next
in interface ArgumentStack
ParameterException
- on a parameter errorpublic java.lang.Integer nextInt() throws ParameterException
ArgumentStack
nextInt
in interface ArgumentStack
ParameterException
- on a parameter errorpublic java.lang.Double nextDouble() throws ParameterException
ArgumentStack
nextDouble
in interface ArgumentStack
ParameterException
- on a parameter errorpublic java.lang.Boolean nextBoolean() throws ParameterException
ArgumentStack
nextBoolean
in interface ArgumentStack
ParameterException
- on a parameter errorpublic java.lang.String remaining() throws ParameterException
ArgumentStack
remaining
in interface ArgumentStack
ParameterException
- on a parameter errorpublic java.lang.String getUnconsumed()
public void markConsumed()
ArgumentStack
markConsumed
in interface ArgumentStack
public int position()
public void mark()
The marked position initially starts at 0.
public java.lang.String reset()
mark()
ed position of the stack, and return
the arguments that were consumed between this point and that previous point.
The marked position initially starts at 0.
public boolean wasConsumed()
The marked position initially starts at 0.
public java.lang.String getConsumed()
The marked position initially starts at 0.
public CommandContext getContext()
getContext
in interface ArgumentStack