nodeNet
Class Channel

java.lang.Object
  |
  +--nodeNet.Channel

public class Channel
extends java.lang.Object
implements NodeNetElement, InputChannel, OutputChannel, java.io.Serializable

A Channel object is a NodeNetElement that connects two Nodes. A channel implements both the InputChannel and OutputChannel interfaces. Channels have an assocated capacity and latency. The capacity of a channel indicates how many packets may be present before a ChannelFullException is thrown. The latency of a channel is a measure of how long (in ms) a packet takes to travel from the input to the output.

Copyright (c) 1998 Massachusetts Institute of Technology

See Also:
Serialized Form

Field Summary
static int MAX_CAPACITY
          the maximum allowable capacity
static int MAX_LATENCY
          the maximum allowable latency
 
Constructor Summary
Channel(Node start, Node end)
          Creates a new Channel with the given start and end nodes.
 
Method Summary
 void configure()
           
 void destroy()
          Destroy the Channel.
 boolean equals(java.lang.Object o)
          Determines if two Channels are equal.
protected  void finalize()
           
 int getCapacity()
           
 int getLatency()
           
 java.lang.String getName()
           
 boolean isDestroyed()
           
 boolean isEditable()
           
 boolean isEnabled()
           
 boolean isInside(int x, int y)
           
 boolean isInside(java.awt.Point p)
           
 boolean isSelected()
           
 void notifyOfDestruction(NodeNetElement nne)
          Notify this that a NodeNetElement has been destroyed.
 void paint(java.awt.Graphics g)
           
 java.lang.Object readObject()
          Read an object from the channel.
 void run()
           
 void setCapacity(int cap)
           
 void setEnabled(boolean b)
           
 void setLatency(int lat)
           
 void setName(java.lang.String n)
           
 void setSelected(boolean b)
           
 void start()
           
 void stop()
           
 void writeObject(java.lang.Object o)
          Insert an object into the channel.
 
Methods inherited from class java.lang.Object
clone, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MAX_LATENCY

public static final int MAX_LATENCY
the maximum allowable latency

MAX_CAPACITY

public static final int MAX_CAPACITY
the maximum allowable capacity
Constructor Detail

Channel

public Channel(Node start,
               Node end)
        throws SameNodeException
Creates a new Channel with the given start and end nodes. If start and end are the same (as determined by equals), throws SameNodeException.
Method Detail

writeObject

public void writeObject(java.lang.Object o)
                 throws ChannelFullException,
                        ChannelDisabledException
Insert an object into the channel.
Specified by:
writeObject in interface OutputChannel
Parameters:
o - The object to be inserted.
Throws:
ChannelFullException - if the number of objects in the channel already equals or exceeds the capacity.
ChannelDisabledException - if the channel is currently disabled

readObject

public java.lang.Object readObject()
                            throws ChannelEmptyException,
                                   ChannelDisabledException
Read an object from the channel.
Specified by:
readObject in interface InputChannel
Returns:
the oldest (in terms of insertion time) object in the channel
Throws:
ChannelEmptyException - if no objects are present in the channel or the oldest object has not propigated through the channel yet (due to a non-zero latency).
ChannelDisabledException - if the channel is diabled

getCapacity

public int getCapacity()

setCapacity

public void setCapacity(int cap)

getLatency

public int getLatency()

setLatency

public void setLatency(int lat)

setSelected

public void setSelected(boolean b)
Specified by:
setSelected in interface NodeNetElement

isSelected

public boolean isSelected()
Specified by:
isSelected in interface NodeNetElement

setEnabled

public void setEnabled(boolean b)
Specified by:
setEnabled in interface NodeNetElement

isEnabled

public boolean isEnabled()
Specified by:
isEnabled in interface NodeNetElement

isInside

public boolean isInside(int x,
                        int y)
Specified by:
isInside in interface NodeNetElement

isInside

public boolean isInside(java.awt.Point p)
Specified by:
isInside in interface NodeNetElement

setName

public void setName(java.lang.String n)
Specified by:
setName in interface NodeNetElement

getName

public java.lang.String getName()
Specified by:
getName in interface NodeNetElement

destroy

public void destroy()
Destroy the Channel. destroy() should be called whenever a Channel will no longer be used. When destroyed, Channels notify all connected Nodes of the impending destruction. Note: Channel.finalize() automatically calls destroy().
Specified by:
destroy in interface NodeNetElement

isDestroyed

public boolean isDestroyed()
Specified by:
isDestroyed in interface NodeNetElement

notifyOfDestruction

public void notifyOfDestruction(NodeNetElement nne)
Notify this that a NodeNetElement has been destroyed. Typically, this method will be called by one of the two connected Nodes. If that is the case, the channel destroys itself.
Specified by:
notifyOfDestruction in interface NodeNetElement

isEditable

public boolean isEditable()

configure

public void configure()
Specified by:
configure in interface NodeNetElement

paint

public void paint(java.awt.Graphics g)
Specified by:
paint in interface NodeNetElement

start

public void start()
Specified by:
start in interface NodeNetElement

stop

public void stop()
Specified by:
stop in interface NodeNetElement

run

public void run()

equals

public boolean equals(java.lang.Object o)
Determines if two Channels are equal.
Overrides:
equals in class java.lang.Object

finalize

protected void finalize()
                 throws java.io.IOException
Overrides:
finalize in class java.lang.Object