Package it.polito.appeal.traci.protocol
Class Command
- java.lang.Object
-
- it.polito.appeal.traci.protocol.Command
-
public class Command extends Object
Represents a single TraCI command, with its identifier and content. It can be used either as a request (i.e. from client to server) and as a response (i.e. from server to client). The "command" term reflects the description in the wiki. Each command is characterized by a type identifier and a variable-sized content. The command can be constructed either from a data block (aStorage
) or from scratch; its content can be read or written to aStorage
.- Author:
- Enrico Gueli <enrico.gueli@polito.it>
- See Also:
- Messages
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Storage
content()
Returns the content.int
id()
Returns the type identifier.int
rawSize()
Returns the expected size of the serialized form of this command.void
writeRawTo(Storage out)
Writes the serialized form of this command to the givenStorage
object.
-
-
-
Constructor Detail
-
Command
public Command(Storage rawStorage)
Builds a command from aStorage
received from the other endpoint.Note that this will advance the storage's internal pointer to the next data.
- Parameters:
rawStorage
- raw storage
-
Command
public Command(int id)
Creates a command with a given identifier and an empty content.- Parameters:
id
- id
-
-
Method Detail
-
id
public int id()
Returns the type identifier.- Returns:
- the id
-
content
public Storage content()
Returns the content.- Returns:
- the content
-
writeRawTo
public void writeRawTo(Storage out)
Writes the serialized form of this command to the givenStorage
object.Note: this will advance the internal pointer of the given storage.
- Parameters:
out
- output
-
rawSize
public int rawSize()
Returns the expected size of the serialized form of this command.- Returns:
- raw size
-
-