|
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.Switch
public class Switch
A data-driven selection mechanism that immediately evaluates its valuator (criterium) and chooses the corresponding branch. The resulting component terminates when the chosen branch terminates.
| Nested Class Summary | |
|---|---|
protected class |
Switch.LocalListener
A dedicated listener that forwards the event to all external listeners. |
protected class |
Switch.SwitchTerminationListener
This component terminates as soon as the chosen branch component terminates. |
| Nested classes/interfaces inherited from class edu.luc.cs.trull.AbstractCombinator |
|---|
AbstractCombinator.DefaultTerminationListener |
| Field Summary | |
|---|---|
private int |
currentComponentIndex
The index of the chosen branch. |
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
|
private TerminationListener |
terminationListener
The child termination listener for this component. |
private EventValuator |
valuator
The valuator (criterium) for this switch. |
| Fields inherited from class edu.luc.cs.trull.AbstractCombinator |
|---|
components |
| Constructor Summary | |
|---|---|
Switch()
Constructs a Switch component. |
|
Switch(EventValuator valuator,
Component[] components)
Constructs a Switch component. |
|
| Method Summary | |
|---|---|
protected void |
disconnectComponent(Component c)
Unhooks the given component from communication and termination. |
protected TerminationListener |
getChildTerminationListener()
Returns the internal listener that is notified if the child component terminates. |
protected Component |
getCurrentComponent()
The chosen branch comopnent. |
EventValuator |
getValuator()
Returns the criterium used by this Switch. |
void |
propertyChange(java.beans.PropertyChangeEvent evt)
This method forwards events received from external sources to the components of this combinator. |
void |
removeComponent(Component c)
Removes the specified component from this combinator. |
void |
resume()
Resumes this suspendable component. |
void |
setValuator(EventValuator valuator)
Sets the criterium of this Switch to the given valuator. |
void |
start(java.beans.PropertyChangeEvent incoming)
Starts this startable component. |
void |
stop()
Stops this startable component. |
void |
suspend()
Suspends this suspendable component. |
protected void |
switchToComponent(int choice)
Switches to the branch component with the given index. |
| 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 internalListener
private static final org.apache.log4j.Logger logger
private TerminationListener terminationListener
private EventValuator valuator
| Constructor Detail |
|---|
public Switch()
public Switch(EventValuator valuator,
Component[] components)
valuator - the criterium used to choose a branch.components - the array of branch components.| Method Detail |
|---|
protected void disconnectComponent(Component c)
c - the component to be unhooked.protected TerminationListener getChildTerminationListener()
AbstractCombinator
getChildTerminationListener in class AbstractCombinatorprotected Component getCurrentComponent()
public EventValuator getValuator()
public void propertyChange(java.beans.PropertyChangeEvent evt)
propertyChange in interface java.beans.PropertyChangeListenerpropertyChange in class EmptyComponentevt - the event received.public void removeComponent(Component c)
AbstractCombinator
removeComponent in interface CombinatorremoveComponent in class AbstractCombinatorc - the component to be removed.public void resume()
Suspendable
resume in interface Suspendableresume in class EmptyComponentpublic void setValuator(EventValuator valuator)
valuator - the valuator to be used as the criterium.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.public void stop()
Startable
stop in interface Startablestop in class EmptyComponentpublic void suspend()
Suspendable
suspend in interface Suspendablesuspend in class EmptyComponentprotected void switchToComponent(int choice)
choice - the index of the branch.
|
Trull | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||