Package de.tudresden.sumo.util

## Class Query

- java.lang.Object
- - de.tudresden.sumo.util.Observable
  - - de.tudresden.sumo.util.Query

- Direct Known Subclasses:
    `CloseQuery`, `CommandProcessor`

      public abstract class Query
      extends Observable

  The Class Query.

- - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `Query​(Socket sock)` | Instantiates a new query.

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `protected void` | `doClose()` | Disconnect client from the sumo server.
    `protected ResponseMessage` | `doQuery​(RequestMessage msg)` | Sends a request message to SUMO and returns a response message.
    `protected ResponseContainer` | `doQuerySingle​(Command request)` | Like `doQuery(RequestMessage)`, but good for one-command/ one-response queries.
    `protected void` | `doSetOrder​(int index)` | Set multi-client ordering index.
    `protected void` | `doSimulationStep​(double targetTime)` | Do next time step and update subscription results.
    `protected void` | `fireAndForget​(Command request)` | fireAndForget function.
    `DataOutputStream` | `getOutStream()` | Gets the out stream.
    `protected ResponseMessage` | `queryAndVerify​(RequestMessage reqMsg)` | Like `doQuery(RequestMessage)`; in addition, verifies that all responses are successful and and the statuses match the requests.
    `protected ResponseContainer` | `queryAndVerifySingle​(Command request)` | Like `queryAndVerify(RequestMessage)`, but good for one-command/ one-response queries.
    `protected static void` | `verify​(String description, int expected, byte actual)` | Verify.
    `protected static void` | `verify​(String description, int expected, short actual)` | Verify.
    `protected static void` | `verify​(String description, Object expected, Object actual)` | Verify.
    `protected static String` | `verifyGetVarResponse​(Command resp, int commandID, int variable, String objectID)` | Verify get var response.

    - ### Methods inherited from class de.tudresden.sumo.util.Observable

      `addObserver, notifyObservers`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### Query

          public Query​(Socket sock)
                throws IOException

      Instantiates a new query.
      Parameters:
        `sock` - the sock
      Throws:
        `IOException` - Signals that an I/O exception has occurred.

  - ### Method Detail

    - #### doQuery

          protected ResponseMessage doQuery​(RequestMessage msg)
                                     throws IOException

      Sends a request message to SUMO and returns a response message.
      Parameters:
        `msg` - the msg
      Returns:
        the response message
      Throws:
        `IOException` - Signals that an I/O exception has occurred.

    - #### queryAndVerify

          protected ResponseMessage queryAndVerify​(RequestMessage reqMsg)
                                            throws IOException

      Like `doQuery(RequestMessage)`; in addition, verifies that all responses are successful and and the statuses match the requests.
      Parameters:
        `reqMsg` - the req msg
      Returns:
        the verified response message
      Throws:
        `IOException` - Signals that an I/O exception has occurred.
      See Also:
        `doQuery(RequestMessage)`

    - #### doQuerySingle

          protected ResponseContainer doQuerySingle​(Command request)
                                             throws IOException

      Like `doQuery(RequestMessage)`, but good for one-command/ one-response queries.
      Parameters:
        `request` - the request
      Returns:
        the response container
      Throws:
        `IOException` - Signals that an I/O exception has occurred.

    - #### doSetOrder

          protected void doSetOrder​(int index)
                             throws IOException

      Set multi-client ordering index.
      Parameters:
        `index` - the index
      Throws:
        `IOException` - Signals that an I/O exception has occurred.

    - #### doClose

          protected void doClose()
                          throws IOException

      Disconnect client from the sumo server.
      Throws:
        `IOException` - Signals that an I/O exception has occurred.

    - #### doSimulationStep

          protected void doSimulationStep​(double targetTime)
                                   throws IOException

      Do next time step and update subscription results.
      Parameters:
        `targetTime` - the target time
      Throws:
        `IOException` - Signals that an I/O exception has occurred.

    - #### queryAndVerifySingle

          protected ResponseContainer queryAndVerifySingle​(Command request)
                                                    throws IOException

      Like `queryAndVerify(RequestMessage)`, but good for one-command/ one-response queries.
      Parameters:
        `request` - the request
      Returns:
        the response container for the specified request
      Throws:
        `IOException` - Signals that an I/O exception has occurred.

    - #### fireAndForget

          protected void fireAndForget​(Command request)

      fireAndForget function.
      Parameters:
        `request` - the request

    - #### verifyGetVarResponse

          protected static String verifyGetVarResponse​(Command resp,
                                                       int commandID,
                                                       int variable,
                                                       String objectID)
                                                throws TraCIException.UnexpectedData

      Verify get var response.
      Parameters:
        `resp` - the resp
        `commandID` - the command ID
        `variable` - the variable
        `objectID` - the object ID
      Returns:
        the string
      Throws:
        `TraCIException.UnexpectedData` - the unexpected data

    - #### verify

          protected static void verify​(String description,
                                       Object expected,
                                       Object actual)
                                throws TraCIException.UnexpectedData

      Verify.
      Parameters:
        `description` - the description
        `expected` - the expected
        `actual` - the actual
      Throws:
        `TraCIException.UnexpectedData` - the unexpected data

    - #### verify

          protected static void verify​(String description,
                                       int expected,
                                       short actual)
                                throws TraCIException.UnexpectedData

      Verify.
      Parameters:
        `description` - the description
        `expected` - the expected
        `actual` - the actual
      Throws:
        `TraCIException.UnexpectedData` - the unexpected data

    - #### verify

          protected static void verify​(String description,
                                       int expected,
                                       byte actual)
                                throws TraCIException.UnexpectedData

      Verify.
      Parameters:
        `description` - the description
        `expected` - the expected
        `actual` - the actual
      Throws:
        `TraCIException.UnexpectedData` - the unexpected data

    - #### getOutStream

          public DataOutputStream getOutStream()

      Gets the out stream.
      Returns:
        the out stream