public final class Command extends Object
Represents a command string sent from a client to the server, after being parsed into a more convenient data structure. It includes fields for the three parts of these commands, the type, the two parameters (which may or may not be present), and the payload (which also may not be present). See the protocol specification for more details about the command format.
You should not edit this file.
Modifier and Type | Class and Description |
---|---|
static class |
Command.Type
This enumeration defines the various types of commands that the clients
and server operate with.
|
Constructor and Description |
---|
Command(Command.Type type,
String payload)
Convenience constructor for
Command s with no parameters. |
Command(Command.Type type,
String param0,
String param1,
String payload)
Constructs a
Command with the provided components. |
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object o) |
String |
getParameter(int index)
Returns the specified parameter.
|
int |
getParameterCount()
Counts the number of parameters in this command.
|
String |
getPayload()
Returns the payload.
|
Command.Type |
getType()
Returns the command type.
|
int |
hashCode() |
String |
toString()
Returns the representation of the
Command as it would be sent
over the wire to the server. |
public Command(Command.Type type, String param0, String param1, String payload)
Command
with the provided components. The parameter
count and the presence or absence of a payload must agree with the
command type according to the specification.type
- the command typeparam0
- the first parameter, or null
if absentparam1
- the second parameter, or null
if absentpayload
- the payload, or null
if absentIllegalArgumentException
- if type
is null
, or if the command is
syntactically invalid; it has an incorrect parameter count, it
is missing a payload where one is required, or it has a payload
where one is invalidpublic Command(Command.Type type, String payload)
Command
s with no parameters.type
- the command typepayload
- the payload, or null
if absentCommand(Type, String, String, String)
public Command.Type getType()
public String getParameter(int index)
index
- the 0-based index of the parameter to retrieveIllegalArgumentException
- if index
is invalidpublic int getParameterCount()
public String getPayload()
null
if there is none