com.tractrac.clientmodule.data
Class DataController

java.lang.Object
  extended by com.tractrac.clientmodule.data.DataController
All Implemented Interfaces:
java.lang.Runnable

public class DataController
extends java.lang.Object
implements java.lang.Runnable

The main class for data subscription/retrieval.

Version:
2.0
Author:
jmr

Nested Class Summary
static interface DataController.Listener
          Provides information on the status of live and stored data.
static interface DataController.TimeListener
          A callback that will be called when the UTC time of the live data server is received.
 
Constructor Summary
DataController(java.net.URI liveUri, java.net.URI storedUri, DataController.Listener listener)
          Creates a data controller to be used when subscribing data.
 
Method Summary
 void add(com.maptrack.client.io.TypeController typeController)
          Adds a subscription to the TTCM May be called before or after executing the run method.
 void getUtcTime(DataController.TimeListener timeListener)
          Requests the UTC time of the data server.
 boolean hasLiveData()
          Returns whether this controller is set up to receive live data
 boolean hasStoredData()
          Returns whether this controller is set up to receive stored data
 void remove(com.maptrack.client.io.TypeController typeController)
          Cancels a subscription from the TTCM.
 void run()
           
 void stop(boolean abortStored)
          Stop receiving live and stored data
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DataController

public DataController(java.net.URI liveUri,
                      java.net.URI storedUri,
                      DataController.Listener listener)
               throws java.io.FileNotFoundException,
                      java.net.MalformedURLException
Creates a data controller to be used when subscribing data. Supported live data URI's: Supported stored data URI's:

Parameters:
liveUri - the URI for live data. null is allowed, in which case no live data will be received.
storedUri - the URI for stored data. null is allowed, in which case no stored data will be received.
listener -
Throws:
java.io.FileNotFoundException
java.net.MalformedURLException
Method Detail

hasLiveData

public boolean hasLiveData()
Returns whether this controller is set up to receive live data

Returns:
whether this controller is set up to receive live data

hasStoredData

public boolean hasStoredData()
Returns whether this controller is set up to receive stored data

Returns:
whether this controller is set up to receive stored data

add

public void add(com.maptrack.client.io.TypeController typeController)
Adds a subscription to the TTCM

May be called before or after executing the run method.

Parameters:
typeController -

remove

public void remove(com.maptrack.client.io.TypeController typeController)
Cancels a subscription from the TTCM. May be called before or after executing the run method.

Parameters:
typeController -

run

public void run()
Specified by:
run in interface java.lang.Runnable

getUtcTime

public void getUtcTime(DataController.TimeListener timeListener)
Requests the UTC time of the data server.

The answer will arrive asynchronously through the provided callback.

Note that the answer will only arrive once the connection to the live server has been established (e.g., after the DataControllerAsio.Listener.liveDataConnected() call)

Parameters:
timeListenerInQueue -

stop

public void stop(boolean abortStored)
Stop receiving live and stored data

Parameters:
abortStored - true if processes currently fetching stored data should be stopped; otherwise, these processes will be allowed to finish