input
Class ExternalEventsQueue

java.lang.Object
  extended by input.ExternalEventsQueue
All Implemented Interfaces:
EventQueue

public class ExternalEventsQueue
extends java.lang.Object
implements EventQueue

Queue of external events. This class also takes care of buffering the events and preloading only a proper amount of them.


Field Summary
static int DEFAULT_NROF_PRELOAD
          default number of preloaded events
static java.lang.String PATH_SETTING
          path of external events file -setting id ("filePath")
static java.lang.String PRELOAD_SETTING
          number of event to preload -setting id ("nrofPreload")
static java.lang.String SETTINGS_NAMESPACE
          ExternalEvents namespace ("ExternalEvents")
 
Constructor Summary
ExternalEventsQueue(Settings s)
          Create a new Queue based on the given settings: PRELOAD_SETTING and PATH_SETTING.
ExternalEventsQueue(java.lang.String filePath, int nrofPreload)
          Creates a new Queue from a file
 
Method Summary
 int eventsLeftInBuffer()
          Returns the amount of events left in the buffer at the moment (the amount can increase later if more events are read).
 ExternalEvent nextEvent()
          Returns the next event in the queue or ExternalEvent with time of double.MAX_VALUE if there are no events left
 double nextEventsTime()
          Returns next event's time or Double.MAX_VALUE if there are no events left
 void setNrofPreload(int nrof)
          Sets maximum number of events that are read when the next preload occurs
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SETTINGS_NAMESPACE

public static final java.lang.String SETTINGS_NAMESPACE
ExternalEvents namespace ("ExternalEvents")

See Also:
Constant Field Values

PRELOAD_SETTING

public static final java.lang.String PRELOAD_SETTING
number of event to preload -setting id ("nrofPreload")

See Also:
Constant Field Values

PATH_SETTING

public static final java.lang.String PATH_SETTING
path of external events file -setting id ("filePath")

See Also:
Constant Field Values

DEFAULT_NROF_PRELOAD

public static final int DEFAULT_NROF_PRELOAD
default number of preloaded events

See Also:
Constant Field Values
Constructor Detail

ExternalEventsQueue

public ExternalEventsQueue(java.lang.String filePath,
                           int nrofPreload)
Creates a new Queue from a file

Parameters:
filePath - Path to the file where the events are read from. If file ends with extension defined in BinaryEventsReader.BINARY_EXT the file is assumed to be a binary file.
nrofPreload - How many events to preload
See Also:
BinaryEventsReader.BINARY_EXT, BinaryEventsReader.storeToBinaryFile(String, List)

ExternalEventsQueue

public ExternalEventsQueue(Settings s)
Create a new Queue based on the given settings: PRELOAD_SETTING and PATH_SETTING. The path setting supports value filling.

Parameters:
s - The settings
Method Detail

setNrofPreload

public void setNrofPreload(int nrof)
Sets maximum number of events that are read when the next preload occurs

Parameters:
nrof - Maximum number of events to read. If less than 1, default value ( 500 ) is used.

nextEventsTime

public double nextEventsTime()
Returns next event's time or Double.MAX_VALUE if there are no events left

Specified by:
nextEventsTime in interface EventQueue
Returns:
Next event's time

nextEvent

public ExternalEvent nextEvent()
Returns the next event in the queue or ExternalEvent with time of double.MAX_VALUE if there are no events left

Specified by:
nextEvent in interface EventQueue
Returns:
The next event

eventsLeftInBuffer

public int eventsLeftInBuffer()
Returns the amount of events left in the buffer at the moment (the amount can increase later if more events are read).

Returns:
The amount of events left or 0 there aren't any events