network
Class ChannelList

java.lang.Object
  extended bycore.EventNotifier
      extended bynetwork.ChannelList

public class ChannelList
extends EventNotifier

Contains a list of neighbors that can be channels to send a message through. FIFO replacement.

Author:
hoele

Constructor Summary
ChannelList(Neighbor neighbor, java.lang.String virtualAddress, java.util.Vector channelListeners)
          Constructs a ChannelList with one neighbor and a display
 
Method Summary
 void add(Neighbor neighbor)
          Add a reference of neighbor as one of the channels.
 void fireChannelAdded(java.lang.String virtualAddress, Neighbor addedNeighbor)
           
 void fireChannelRemoved(java.lang.String virtualAddress, Neighbor removedNeighbor)
           
 void fireSetChannelAdded(java.lang.String virtualAddress, Neighbor addedNeighbor)
           
 void fireSetChannelRemoved(java.lang.String virtualAddress, Neighbor addedNeighbor)
           
 Neighbor getChannel(Neighbor fromNeighbor)
          Returns a random neighbor in the ChannelList.
 void print()
          Print the channel list in a readable format.
 void remove(int index)
          Removes the reference to a neighbor at the given index from the ChannelList.
 
Methods inherited from class core.EventNotifier
addListener, removeListener
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ChannelList

public ChannelList(Neighbor neighbor,
                   java.lang.String virtualAddress,
                   java.util.Vector channelListeners)
Constructs a ChannelList with one neighbor and a display

Parameters:
neighbor - The first neighbor in the ChannelList.
Method Detail

add

public void add(Neighbor neighbor)
Add a reference of neighbor as one of the channels.

Parameters:
neighbor - The Neighbor to be added.

remove

public void remove(int index)
Removes the reference to a neighbor at the given index from the ChannelList.

Parameters:
index - The index of the neighbor to remove.

getChannel

public Neighbor getChannel(Neighbor fromNeighbor)
Returns a random neighbor in the ChannelList.

Returns:
A neighbor in the list or null if the list is empty.

print

public void print()
Print the channel list in a readable format.


fireChannelRemoved

public void fireChannelRemoved(java.lang.String virtualAddress,
                               Neighbor removedNeighbor)

fireChannelAdded

public void fireChannelAdded(java.lang.String virtualAddress,
                             Neighbor addedNeighbor)

fireSetChannelRemoved

public void fireSetChannelRemoved(java.lang.String virtualAddress,
                                  Neighbor addedNeighbor)

fireSetChannelAdded

public void fireSetChannelAdded(java.lang.String virtualAddress,
                                Neighbor addedNeighbor)