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 (a Storage) or from scratch; its content can be read or written to a Storage.
Author:
Enrico Gueli <enrico.gueli@polito.it>
See Also:
  • Constructor Details

    • Command

      public Command(Storage rawStorage)
      Builds a command from a Storage 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 Details

    • 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 given Storage 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