|
Trull | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectedu.luc.cs.trull.EmptyComponent
edu.luc.cs.trull.TerminatingComponent
edu.luc.cs.trull.AbstractComponent
edu.luc.cs.trull.AbstractCombinator
edu.luc.cs.trull.Cycle
public class Cycle
A combinator that cycles round-robin among several components on any event from a given set of triggering events. It is largely equivalent to this nested Watching construct, but it does not cycle to the next component when the current component terminates.
cycle c e1 ... en =
loop
do e1 watching c ->
do e2 watching c ->
...
do en watching c
Loop,
Watching| Nested Class Summary | |
|---|---|
protected class |
Cycle.LocalListener
A dedicated listener that forwards the event from the currently active child component to all external listeners. |
| Nested classes/interfaces inherited from class edu.luc.cs.trull.AbstractCombinator |
|---|
AbstractCombinator.DefaultTerminationListener |
| Field Summary | |
|---|---|
private int |
currentComponentIndex
Theh index of the currently active component. |
private java.beans.PropertyChangeListener |
cycleAction
The action to be invoked when switching to the next component. |
private java.util.Set |
cycleEvents
The set of triggering events for cycling among components. |
private java.beans.PropertyChangeListener |
internalListener
An internal listener that listens to the currently active child branch of this component and forwards events to the external listeners. |
private static org.apache.log4j.Logger |
logger
|
| Fields inherited from class edu.luc.cs.trull.AbstractCombinator |
|---|
components |
| Constructor Summary | |
|---|---|
Cycle()
Constructs an empty Cycle component. |
|
Cycle(java.lang.String[] labels,
Component[] branches)
Cycle(labels, null, branches) |
|
Cycle(java.lang.String[] labels,
java.beans.PropertyChangeListener action,
Component[] branches)
Constructs a Cycle component. |
|
Cycle(java.lang.String label,
Component[] branches)
Cycle(label, null, branches) |
|
Cycle(java.lang.String label,
java.beans.PropertyChangeListener action,
Component[] branches)
Cycle([label], action, branches) |
|
| Method Summary | |
|---|---|
protected TerminationListener |
getChildTerminationListener()
Returns null because this component ignores termination of its children. |
protected Component |
getCurrentComponent()
Returns the currently active child component of this Cycle component. |
java.beans.PropertyChangeListener |
getCycleAction()
Returns the action to be invoked when switching to the next component. |
java.lang.String[] |
getCycleEvents()
Returns an array of triggering event labels for this component. |
void |
propertyChange(java.beans.PropertyChangeEvent evt)
This method forwards events received from external sources to the currently active child component. |
void |
removeComponent(Component c)
This method removes a component from the cycle. |
void |
resume()
Resumes this suspendable component. |
void |
setCycleAction(java.beans.PropertyChangeListener action)
Sets the action to be invoked when switching to the next component. |
void |
setCycleEvent(java.lang.String label)
Sets the triggering event label for this component to the given string. |
void |
setCycleEvents(java.util.Collection evts)
Sets the triggering event labels for this component to the given collection. |
void |
setCycleEvents(java.lang.String[] labels)
Sets the triggering event labels for this component to the given array. |
void |
start(java.beans.PropertyChangeEvent incoming)
Starts this startable component. |
protected void |
startCurrent(java.beans.PropertyChangeEvent incoming)
Starts the currently active component. |
void |
stop()
Stops this startable component. |
void |
suspend()
Suspends this suspendable component. |
protected void |
switchToFirstComponent()
Switches (cycles) to the first child component. |
protected void |
switchToNextComponent()
Switches (cycles) to the next child component. |
| Methods inherited from class edu.luc.cs.trull.AbstractCombinator |
|---|
addComponent, addComponent, addComponent, getComponent, getComponentCount, getComponents, removeAllComponents, removeComponent |
| Methods inherited from class edu.luc.cs.trull.AbstractComponent |
|---|
addPropertyChangeListener, firePropertyChange, firePropertyChange, firePropertyChange, getExternalListeners, getPropertyChangeListeners, removePropertyChangeListener |
| Methods inherited from class edu.luc.cs.trull.TerminatingComponent |
|---|
fireTermination, getParent, getTermEvent, scheduleTermination, setTerminationListener |
| Methods inherited from class edu.luc.cs.trull.EmptyComponent |
|---|
getTerminationListener |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface edu.luc.cs.trull.PropertyChangeSource |
|---|
addPropertyChangeListener, getPropertyChangeListeners, removePropertyChangeListener |
| Methods inherited from interface edu.luc.cs.trull.Terminating |
|---|
getTerminationListener, setTerminationListener |
| Field Detail |
|---|
private int currentComponentIndex
private java.beans.PropertyChangeListener cycleAction
private java.util.Set cycleEvents
private java.beans.PropertyChangeListener internalListener
private static final org.apache.log4j.Logger logger
| Constructor Detail |
|---|
public Cycle()
public Cycle(java.lang.String[] labels,
Component[] branches)
Cycle(labels, null, branches)
public Cycle(java.lang.String[] labels,
java.beans.PropertyChangeListener action,
Component[] branches)
labels - the array of String event labels triggering a switch.action - the action invoked when a switch is triggered. May be null.branches - the components among which this component cycles.
public Cycle(java.lang.String label,
Component[] branches)
Cycle(label, null, branches)
public Cycle(java.lang.String label,
java.beans.PropertyChangeListener action,
Component[] branches)
Cycle([label], action, branches)
| Method Detail |
|---|
protected TerminationListener getChildTerminationListener()
getChildTerminationListener in class AbstractCombinatorprotected Component getCurrentComponent()
public java.beans.PropertyChangeListener getCycleAction()
public java.lang.String[] getCycleEvents()
public void propertyChange(java.beans.PropertyChangeEvent evt)
propertyChange in interface java.beans.PropertyChangeListenerpropertyChange in class EmptyComponentevt - the event received.public void removeComponent(Component c)
removeComponent in interface CombinatorremoveComponent in class AbstractCombinatorc - the component to be removed.public void resume()
Suspendable
resume in interface Suspendableresume in class EmptyComponentpublic void setCycleAction(java.beans.PropertyChangeListener action)
action - the action to be invoked when switching to the next component.
May be null.public void setCycleEvent(java.lang.String label)
label - the triggering event label.public void setCycleEvents(java.util.Collection evts)
evts - the collection of triggering event labels.public void setCycleEvents(java.lang.String[] labels)
labels - the array of triggering event labels.public void start(java.beans.PropertyChangeEvent incoming)
Startable
start in interface Startablestart in class EmptyComponentincoming - the event that triggered the invocation of this method. May be null.protected void startCurrent(java.beans.PropertyChangeEvent incoming)
incoming - the triggering event.public void stop()
Startable
stop in interface Startablestop in class EmptyComponentpublic void suspend()
Suspendable
suspend in interface Suspendablesuspend in class EmptyComponentprotected void switchToFirstComponent()
protected void switchToNextComponent()
|
Trull | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||