Trull

edu.luc.cs.trull
Class Rename

java.lang.Object
  extended by edu.luc.cs.trull.EmptyComponent
      extended by edu.luc.cs.trull.TerminatingComponent
          extended by edu.luc.cs.trull.AbstractComponent
              extended by edu.luc.cs.trull.AbstractCombinator
                  extended by edu.luc.cs.trull.SingleChildCombinator
                      extended by edu.luc.cs.trull.Rename
All Implemented Interfaces:
Combinator, Component, PropertyChangeSource, Startable, Suspendable, Terminating, java.beans.PropertyChangeListener, java.util.EventListener
Direct Known Subclasses:
CarryCounter, Local, Office, OfficeControl, TestComponent, WristWatch

public class Rename
extends SingleChildCombinator

A combinator for event renaming and event hiding. It provides an implementation of consistent renaming of event labels within a given component from any event labels seen externally.

See Also:
Local

Nested Class Summary
protected  class Rename.LocalListener
          A dedicated listener that forwards the event to all external listeners.
 
Nested classes/interfaces inherited from class edu.luc.cs.trull.AbstractCombinator
AbstractCombinator.DefaultTerminationListener
 
Field Summary
private  java.beans.PropertyChangeListener internalListener
          The listener to the child component.
private  java.util.Set localEvents
          The set of hidden events local to this component.
private static org.apache.log4j.Logger logger
           
private  java.util.Map renameEventsInside
          A hashmap for inside events that needs to be renamed when leaving the component.
private  java.util.Map renameEventsOutside
          A hashmap for outside eventsthat needs to be renamed when entering the component.
private  TerminationListener terminationListener
          The child termination listener of this component.
 
Fields inherited from class edu.luc.cs.trull.AbstractCombinator
components
 
Constructor Summary
Rename()
          Constructs a Rename component.
Rename(Component body)
          Rename([], [], body)
Rename(java.lang.String[] internalLabels, java.lang.String[] externalLabels, Component body)
          Constructs a Rename component.
Rename(java.lang.String internalLabel, java.lang.String externalLabel, Component body)
          Rename([internalLabel], [externalLabel], body)
 
Method Summary
 void addEventRenaming(java.lang.String internalEvent, java.lang.String externalEvent)
          Adds an event renaming to this component.
protected  TerminationListener getChildTerminationListener()
          Returns the internal listener that is notified if the child component terminates.
protected  Component getDefaultChild()
          This method returns the default child component.
 java.util.Map.Entry[] getEventRenamings()
          Returns the array of event renamings currently in effect.
protected  java.beans.PropertyChangeListener getInternalListener()
          Returns the internal listener that listens to the child component.
 java.lang.String[] getLocalEvents()
          Returns the event labels that have been hidden.
 void propertyChange(java.beans.PropertyChangeEvent evt)
          This method processes incoming events by forwarding them to the child component.
 void removeEventRenaming(java.lang.String internalEvent)
          Removes the event renaming for the given internal event label.
 void setLocalEvent(java.lang.String label)
          Sets the event label to be hidden.
 void setLocalEvents(java.util.Collection evts)
          Sets the event labels to be hidden.
 void setLocalEvents(java.lang.String[] labels)
          Sets the event labels to be hidden.
 
Methods inherited from class edu.luc.cs.trull.SingleChildCombinator
addComponent, getChild, removeComponent, resume, start, stop, suspend
 
Methods inherited from class edu.luc.cs.trull.AbstractCombinator
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

internalListener

private java.beans.PropertyChangeListener internalListener
The listener to the child component.


localEvents

private java.util.Set localEvents
The set of hidden events local to this component.


logger

private static final org.apache.log4j.Logger logger

renameEventsInside

private java.util.Map renameEventsInside
A hashmap for inside events that needs to be renamed when leaving the component.


renameEventsOutside

private java.util.Map renameEventsOutside
A hashmap for outside eventsthat needs to be renamed when entering the component.


terminationListener

private TerminationListener terminationListener
The child termination listener of this component.

Constructor Detail

Rename

public Rename()
Constructs a Rename component. Specific properties can be changed later.


Rename

public Rename(Component body)
Rename([], [], body)


Rename

public Rename(java.lang.String[] internalLabels,
              java.lang.String[] externalLabels,
              Component body)
Constructs a Rename component.

Parameters:
internalLabels - the array of original event labels before the renaming.
externalLabels - the array of resulting event labels after the renaming.
body - the body component.

Rename

public Rename(java.lang.String internalLabel,
              java.lang.String externalLabel,
              Component body)
Rename([internalLabel], [externalLabel], body)

Method Detail

addEventRenaming

public void addEventRenaming(java.lang.String internalEvent,
                             java.lang.String externalEvent)
Adds an event renaming to this component. An incoming externalEvent is seen by the component as an internalEvent; an outgoing internalEvent is seen by the outside world as an externalEvent.

Parameters:
internalEvent - the original event seen inside the component.
externalEvent - the corresponding event seen outside the component.

getChildTerminationListener

protected TerminationListener getChildTerminationListener()
Description copied from class: AbstractCombinator
Returns the internal listener that is notified if the child component terminates.

Specified by:
getChildTerminationListener in class AbstractCombinator
Returns:
the termination listener.

getDefaultChild

protected Component getDefaultChild()
Description copied from class: SingleChildCombinator
This method returns the default child component.

Specified by:
getDefaultChild in class SingleChildCombinator

getEventRenamings

public java.util.Map.Entry[] getEventRenamings()
Returns the array of event renamings currently in effect.

Returns:
the array of event renamings.

getInternalListener

protected java.beans.PropertyChangeListener getInternalListener()
Description copied from class: SingleChildCombinator
Returns the internal listener that listens to the child component.

Specified by:
getInternalListener in class SingleChildCombinator

getLocalEvents

public java.lang.String[] getLocalEvents()
Returns the event labels that have been hidden.

Returns:
the array of event labels that have been hidden.

propertyChange

public void propertyChange(java.beans.PropertyChangeEvent evt)
This method processes incoming events by forwarding them to the child component.

Specified by:
propertyChange in interface java.beans.PropertyChangeListener
Overrides:
propertyChange in class SingleChildCombinator
Parameters:
evt - the event received.

removeEventRenaming

public void removeEventRenaming(java.lang.String internalEvent)
Removes the event renaming for the given internal event label.

Parameters:
internalEvent - the internal event label.

setLocalEvent

public void setLocalEvent(java.lang.String label)
Sets the event label to be hidden.

Parameters:
label - the event label to be hidden.

setLocalEvents

public void setLocalEvents(java.util.Collection evts)
Sets the event labels to be hidden.

Parameters:
evts - the collection of event labels to be hidden.

setLocalEvents

public void setLocalEvents(java.lang.String[] labels)
Sets the event labels to be hidden.

Parameters:
labels - the array of event labels to be hidden.

Trull

http://www.cs.luc.edu/trull/