Prism.framework
Class Connector

java.lang.Object
  |
  +--Prism.framework.Brick
        |
        +--Prism.framework.Connector
All Implemented Interfaces:
ArchitectureEventConstants, IConnector, ScaffoldConstants
Direct Known Subclasses:
BottomBorderConnector, ConnectorThread, TopBorderConnector

public class Connector
extends Brick
implements IConnector, ArchitectureEventConstants

A connector provides interaction and mediation services to attached components. The connector is connected to a set of components on both sides (a set may be empty). This connector is a simple message dispatching connector.

Version:
0.1
Author:
Nikunj Mehta

Fields inherited from class Prism.framework.Brick
bottomId, myId, name, scaffold, sideId, topId
 
Fields inherited from interface Prism.framework.ArchitectureEventConstants
NOTIF_BEING_HDLD, NOTIF_HDLD, NOTIF_RECD, NOTIF_SENT, PEER_BEING_HDLD, PEER_HDLD, PEER_RECD, PEER_SENT, REQ_BEING_HDLD, REQ_HDLD, REQ_RECD, REQ_SENT
 
Fields inherited from interface Prism.framework.ScaffoldConstants
DISPATCH, MONITOR, SCHEDULER
 
Constructor Summary
Connector(java.lang.String str)
          Constructor for connector that defines a simple connector with the given name
Connector(java.lang.String str, int sizeTop, int sizeBottom)
           
 
Method Summary
 void addToBottom(Brick b)
          Connect the component to the lBottom of this connector
 void addToTop(Brick t)
          Connect the component to the lTop of this connector
 java.lang.Object getBottom()
          Get the connector at the bottom
 java.lang.Object getTop()
          Get the connector at the top
 void handle(Message m)
          Direct the message to all the bricks attached to the opposite side
 void handle(Notification n)
          Direct the notification to all the bricks attached to the bottom
 void handle(Request r)
          Direct the request to all the bricks attached to the top
 boolean hasBottom()
          Find out if the brick has connected bricks at its bottom
 boolean hasTop()
          Find out if the brick has connected bricks at its top
 void removeFromBottom(Brick b)
          Remove the component from the lBottom of this connector
 void removeFromTop(Brick t)
          Remove the component from the lTop of this connector
 java.lang.String toString()
          Create the stringified object with recursive description
 java.lang.String toString(boolean recurse)
          Create the stringified object
 
Methods inherited from class Prism.framework.Brick
add, fireEvent, getBottomId, getSideId, getTopId, setBottomId, setName, setNameAfterTheFact, setScaffold, setSideId, setTopId, start
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Connector

public Connector(java.lang.String str)
Constructor for connector that defines a simple connector with the given name
Parameters:
str - String name of the connector

Connector

public Connector(java.lang.String str,
                 int sizeTop,
                 int sizeBottom)
Method Detail

handle

public void handle(Request r)
Direct the request to all the bricks attached to the top
Parameters:
r - Request to be sent to attached bricks

handle

public void handle(Message m)
Direct the message to all the bricks attached to the opposite side
Overrides:
handle in class Brick
Parameters:
m - Message to be sent to attached bricks on the opposite side

handle

public void handle(Notification n)
Direct the notification to all the bricks attached to the bottom
Parameters:
n - Notification to be sent to attached bricks

addToTop

public void addToTop(Brick t)
Connect the component to the lTop of this connector
Specified by:
addToTop in interface IConnector
Parameters:
t - Brick to be added to the lTop

addToBottom

public void addToBottom(Brick b)
Connect the component to the lBottom of this connector
Specified by:
addToBottom in interface IConnector
Parameters:
b - Brick to be added to the lBottom

removeFromTop

public void removeFromTop(Brick t)
Remove the component from the lTop of this connector
Specified by:
removeFromTop in interface IConnector
Parameters:
t - Brick to be added to the lTop

removeFromBottom

public void removeFromBottom(Brick b)
Remove the component from the lBottom of this connector
Specified by:
removeFromBottom in interface IConnector
Parameters:
b - Brick to be added to the lBottom

hasTop

public boolean hasTop()
Find out if the brick has connected bricks at its top
Returns:
boolean whether there are connectors at the top

hasBottom

public boolean hasBottom()
Find out if the brick has connected bricks at its bottom
Returns:
boolean whether there are connectors at the bottom

getTop

public java.lang.Object getTop()
Get the connector at the top
Returns:
Object the top connector

getBottom

public java.lang.Object getBottom()
Get the connector at the bottom
Returns:
Object the bottom connector

toString

public java.lang.String toString(boolean recurse)
Create the stringified object
Parameters:
recurse - boolean whether to recurse through the stringified connector description

toString

public java.lang.String toString()
Create the stringified object with recursive description
Overrides:
toString in class java.lang.Object