public class GtpCommand
extends java.lang.Object
| Constructor and Description |
|---|
GtpCommand(java.lang.String line)
Construct command from command line.
|
| Modifier and Type | Method and Description |
|---|---|
void |
checkArgNone()
Check that command has no arguments.
|
void |
checkNuArg(int n)
Check that command has n arguments.
|
void |
checkNuArgLessEqual(int n)
Check that command has not more than n arguments.
|
java.lang.String |
getArg() |
java.lang.String |
getArg(int i)
Get argument.
|
java.lang.String |
getArgLine()
Get argument line.
|
GoColor |
getColorArg()
Get single color argument.
|
GoColor |
getColorArg(int i)
Get color argument.
|
java.lang.String |
getCommand()
Get command.
|
double |
getDoubleArg()
Get single floating point number argument.
|
double |
getDoubleArg(int i)
Get floating point number argument.
|
int |
getId()
Get command ID.
|
int |
getIntArg()
Get single integer argument.
|
int |
getIntArg(int i)
Get integer argument.
|
int |
getIntArg(int i,
int min,
int max)
Get integer argument in a range.
|
java.lang.String |
getLine()
Full command line without ID.
|
int |
getNuArg()
Get number of arguments.
|
GoPoint |
getPointArg(int i,
int boardSize)
Get point argument.
|
PointList |
getPointListArg(int boardSize)
Get point arguments.
|
java.lang.StringBuilder |
getResponse()
Get string buffer for construction the response.
|
boolean |
hasId()
Check if command has an ID.
|
boolean |
isQuit()
Check if command is quit command.
|
void |
setResponse(java.lang.String response)
Set the response.
|
public GtpCommand(java.lang.String line)
line - The full command line including ID.public void checkArgNone()
throws GtpError
GtpError - If command has any arguments.public void checkNuArg(int n)
throws GtpError
GtpError - If command has not n arguments.public void checkNuArgLessEqual(int n)
throws GtpError
GtpError - If command has more than n arguments.public boolean hasId()
public java.lang.String getArg(int i)
throws GtpError
i - The index of the argument (starting with zero).GtpError - If command has not enough arguments.public java.lang.String getArgLine()
public GoColor getColorArg() throws GtpError
GtpError - If command has not exactly one argument or argument
is not a color.public GoColor getColorArg(int i) throws GtpError
i - The index of the argument (starting with zero).GtpError - If command has not enough arguments or argument is
not a color.public java.lang.String getCommand()
public double getDoubleArg()
throws GtpError
GtpError - If command has not exactly one argument or argument
is not a floating point number.public double getDoubleArg(int i)
throws GtpError
i - The index of the argument (starting with zero).GtpError - If command has not enough arguments or argument is
not a floating point number.public int getIntArg()
throws GtpError
GtpError - If command has not exactly one argument or argument
is not an integer.public int getIntArg(int i)
throws GtpError
i - The index of the argument (starting with zero).GtpError - If command has not enough arguments or argument is
not an integer.public int getIntArg(int i,
int min,
int max)
throws GtpError
i - The index of the argument (starting with zero).min - Minimum allowed value.max - Maximum allowed value.GtpError - If command has not enough arguments or argument is
not an integer in the allowed range.public GoPoint getPointArg(int i, int boardSize) throws GtpError
i - The index of the argument (starting with zero).boardSize - The board size (points will be checked to be within
this board size).GtpError - If command has not enough arguments or argument is
not a valid point.public PointList getPointListArg(int boardSize) throws GtpError
boardSize - The board size (points will be checked to be within
this board size).GtpError - If at least one argument is not a valid point.public java.lang.String getLine()
public int getNuArg()
public java.lang.StringBuilder getResponse()
public int getId()
public boolean isQuit()
public void setResponse(java.lang.String response)
response - The string containing the new response.