public class SimEventFilter extends BasicSimEntity
This class filters events by name. A list of the names of filtered events is kept, and selected events dispatched directly to listeners to an instance of this class.
If allButThese
is false (default), then any event whose name is
on the list will be passed through. If allButThese
is true, then
every event except the ones on the list is passed through.
Modifier and Type | Field and Description |
---|---|
private boolean |
allButTheseEvents |
private java.util.Set<java.lang.String> |
events
List of event names to either be passed through or not passed through.
|
eventList, property
DEFAULT_ENTITY_NAME, DEFAULT_EVENT_NAME, DEFAULT_PRIORITY, EVENT_METHOD_PREFIX, NL
Constructor and Description |
---|
SimEventFilter() |
SimEventFilter(java.util.Collection<java.lang.String> ev)
Construct an instance with the Collection's events filtered
|
SimEventFilter(java.lang.String name)
Construct an instance with the single event to be filtered
|
SimEventFilter(java.lang.String[] names)
Construct an instance with the given array of events to be filtered
|
SimEventFilter(java.lang.String name,
boolean allBut)
A convenience constructor to easily create a filter that passes all
events except for one.
|
Modifier and Type | Method and Description |
---|---|
void |
addFilteredEvent(java.lang.String eventName)
Add an event to be filtered
|
void |
handleSimEvent(SimEvent simEvent)
Does nothing, since no events will be scheduled
|
boolean |
isAllButTheseEvents() |
void |
processSimEvent(SimEvent simEvent)
If passing through events and event is on list, send to listeners.
|
void |
removeFilteredEvent(java.lang.String eventName)
Removes a filtered event
|
void |
setAllButTheseEvents(boolean b) |
java.lang.String |
toString()
A default string description of this entity, name (Entity Priority)
<list of all properties as key = value pairs>
|
addPropertyChangeListener, addPropertyChangeListener, attemptSchedule, clearAddedProperty, compareTo, fireIndexedPropertyChange, fireIndexedPropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getAddedProperties, getEventList, getEventListID, getName, getPriority, getPropertiesString, getProperty, getProperty, getPropertyChangeListeners, getSerial, interrupt, interrupt, interruptAll, interruptAll, interruptAll, interruptAllWithArgs, interruptAllWithArgs, isClearAddedPropertiesOnReset, isJustDefinedProperties, isPersistant, isReRunnable, isVerbose, parametersMatch, removePropertyChangeListener, removePropertyChangeListener, reset, resetNextSerial, setClearAddedPropertiesOnReset, setEventList, setEventListID, setJustDefinedProperties, setName, setPersistant, setPriority, setProperty, setVerbose, waitDelay, waitDelay, waitDelay, waitDelay
addSimEventListener, getSimEventListeners, notifyListeners, removeSimEventListener
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
addSimEventListener, getSimEventListeners, notifyListeners, removeSimEventListener
private boolean allButTheseEvents
private java.util.Set<java.lang.String> events
public SimEventFilter(java.util.Collection<java.lang.String> ev)
ev
- Collection of event namespublic SimEventFilter(java.lang.String[] names)
names
- Array of event names to be filteredpublic SimEventFilter(java.lang.String name)
name
- A single event to be filteredpublic SimEventFilter(java.lang.String name, boolean allBut)
true
as the second argument:
new SimEventFilter("Foo", true)
name
- Single Event nameallBut
- Whether events are passed or filteredpublic SimEventFilter()
public void addFilteredEvent(java.lang.String eventName)
eventName
- The name of the event to be filteredpublic void removeFilteredEvent(java.lang.String eventName)
eventName
- The name of the venet to be removed from the filterpublic void setAllButTheseEvents(boolean b)
b
- whether the events will be passed or all but the events will be
passedpublic boolean isAllButTheseEvents()
public void handleSimEvent(SimEvent simEvent)
handleSimEvent
in interface SimEventScheduler
handleSimEvent
in class BasicSimEntity
simEvent
- SimEvent from Event Listpublic void processSimEvent(SimEvent simEvent)
If passing through events and event is on list, send to listeners.
Otherwise, if not on list, sent to listeners
processSimEvent
in interface SimEventListener
processSimEvent
in class BasicSimEntity
simEvent
- Heard SimEventpublic java.lang.String toString()
BasicSimEntity
toString
in class BasicSimEntity