uk.org.arlott.simon.hw.f24.lbsta
Class LAN

java.lang.Object
  extended by uk.org.arlott.simon.hw.f24.lbsta.LAN
All Implemented Interfaces:
PacketTransport

public class LAN
extends java.lang.Object
implements PacketTransport

Represents a LAN on the network.


Field Summary
private  java.util.HashSet<BridgePort> bridgePorts
          The bridge ports connected to this LAN.
private  java.util.HashSet<Host> hosts
          The hosts connected to this LAN.
private  java.util.HashSet<LAN> lans
          The LANs connected to this one.
private  java.util.HashSet<Packet> packets
          The packets attached to this LAN.
 int x1
          The top left X co-ordinate position of the LAN.
 int x2
          The bottom right X co-ordinate position of the LAN.
 int y1
          The top left Y co-ordinate position of the LAN.
 int y2
          The bottom right Y co-ordinate position of the LAN.
 
Constructor Summary
LAN(int x1, int y1, int x2, int y2)
          Creates a new LAN object.
LAN(LAN lan)
          Creates a new LAN object.
 
Method Summary
 void addPacket(Packet p)
          Adds a packet to this LAN.
 void connect(BridgePort b)
          Connects to a bridge port.
 void connect(Host h)
          Connects to a host.
 void connect(LAN l)
          Connects to another LAN.
 void disconnect(BridgePort b)
          Disconnects from a bridge port.
 void disconnect(Host h)
          Disconnects from a host.
 void disconnect(LAN l)
          Disconnects from a LAN.
 void disconnectAll()
          Disconnects all LANs, bridges and hosts from this LAN.
 void disconnectBridges()
          Disconnects all bridges from this LAN.
 void disconnectLANs()
          Disconnects all LANs from this one.
 void finishConnects()
          Finish reconnecting to any other network components that are not connected back to this one.
 java.util.HashSet<BridgePort> getBridges()
          Gets all bridges connected to this LAN.
 java.util.Vector<Host> getHosts()
          Gets all hosts connected to this LAN.
 java.util.HashSet<LAN> getLANs()
          Gets all LANs connected to this one.
 int getLength()
          Gets the length of the LAN.
 java.util.Vector<Packet> getPackets()
          Gets all the packets on this LAN.
 void halfConnect(BridgePort b)
          Connects to a bridge port but does not a require a reverse connection.
 void halfConnect(Host h)
          Connects to a host but does not require a reverse connection.
 void halfConnect(LAN l)
          Connects to another LAN but does not require a reverse connection.
 boolean isConnectedTo(BridgePort b)
          Find out if this LAN is connected to a bridge port.
 boolean isConnectedTo(LAN l)
          Find out if this LAN is connected to another LAN.
 void reconnect(LAN l)
          Reconnects to all the LANs a LAN is connected to.
 void reconnectPackets(LAN l)
          Reconnects to all the packets a LAN is connected to.
 void removeAllPackets()
          Removes all packets from this LAN.
 void removePacket(Packet p)
          Removes a packet from this LAN.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

lans

private java.util.HashSet<LAN> lans
The LANs connected to this one.


bridgePorts

private java.util.HashSet<BridgePort> bridgePorts
The bridge ports connected to this LAN.


hosts

private java.util.HashSet<Host> hosts
The hosts connected to this LAN.


packets

private java.util.HashSet<Packet> packets
The packets attached to this LAN.


x1

public int x1
The top left X co-ordinate position of the LAN.


y1

public int y1
The top left Y co-ordinate position of the LAN.


x2

public int x2
The bottom right X co-ordinate position of the LAN.


y2

public int y2
The bottom right Y co-ordinate position of the LAN.

Constructor Detail

LAN

public LAN(int x1,
           int y1,
           int x2,
           int y2)
    throws InvalidPositionException
Creates a new LAN object.

Parameters:
x1 - The top left X co-ordinate position.
y1 - The top left Y co-ordinate position.
x2 - The bottom right X co-ordinate positon.
y2 - The bottom right Y co-ordinate positon.
Throws:
InvalidPositionException - If the position is invalid.

LAN

public LAN(LAN lan)
    throws InvalidPositionException
Creates a new LAN object.

Parameters:
lan - An existing LAN object to copy.
Throws:
InvalidPositionException - If the position is invalid.
Method Detail

getLength

public int getLength()
Gets the length of the LAN.

Returns:
The length of the LAN.

getLANs

public java.util.HashSet<LAN> getLANs()
Gets all LANs connected to this one.

Returns:
All the LANs connected to this LAN.

connect

public void connect(LAN l)
Connects to another LAN.

Parameters:
l - The LAN to connect to.

halfConnect

public void halfConnect(LAN l)
Connects to another LAN but does not require a reverse connection.

Parameters:
l - The LAN to connect to.

reconnect

public void reconnect(LAN l)
Reconnects to all the LANs a LAN is connected to.

Parameters:
l - The LAN with the LANs to reconnect to.

reconnectPackets

public void reconnectPackets(LAN l)
Reconnects to all the packets a LAN is connected to.

Parameters:
l - The LAN with the packets to reconnect to.

isConnectedTo

public boolean isConnectedTo(LAN l)
Find out if this LAN is connected to another LAN.

Parameters:
l - The other LAN.
Returns:
true if connected to l.

disconnect

public void disconnect(LAN l)
Disconnects from a LAN.

Parameters:
l - The LAN to disconnect from.

getBridges

public java.util.HashSet<BridgePort> getBridges()
Gets all bridges connected to this LAN.

Returns:
The bridge ports connected to this LAN.

connect

public void connect(BridgePort b)
Connects to a bridge port.

Parameters:
b - The BridgePort to connect to.

halfConnect

public void halfConnect(BridgePort b)
Connects to a bridge port but does not a require a reverse connection.

Parameters:
b - The BridgePort to connect to.

isConnectedTo

public boolean isConnectedTo(BridgePort b)
Find out if this LAN is connected to a bridge port.

Parameters:
b - The BridgePort.
Returns:
true if connected to b.

disconnect

public void disconnect(BridgePort b)
Disconnects from a bridge port.

Parameters:
b - The BridgePort to disconnect from.

getHosts

public java.util.Vector<Host> getHosts()
Gets all hosts connected to this LAN.

Returns:
All the hosts on this LAN.

connect

public void connect(Host h)
Connects to a host.

Parameters:
h - The Host to connect to.

halfConnect

public void halfConnect(Host h)
Connects to a host but does not require a reverse connection.

Parameters:
h - The Host to connect to.

disconnect

public void disconnect(Host h)
Disconnects from a host.

Parameters:
h - The Host to disconnect from.

finishConnects

public void finishConnects()
Finish reconnecting to any other network components that are not connected back to this one.


disconnectLANs

public void disconnectLANs()
Disconnects all LANs from this one.


disconnectBridges

public void disconnectBridges()
Disconnects all bridges from this LAN.


disconnectAll

public void disconnectAll()
Disconnects all LANs, bridges and hosts from this LAN.


addPacket

public void addPacket(Packet p)
Adds a packet to this LAN.

Specified by:
addPacket in interface PacketTransport
Parameters:
p - The Packet to add.

removePacket

public void removePacket(Packet p)
Removes a packet from this LAN.

Specified by:
removePacket in interface PacketTransport
Parameters:
p - The Packet to remove.

removeAllPackets

public void removeAllPackets()
Removes all packets from this LAN.


getPackets

public java.util.Vector<Packet> getPackets()
Gets all the packets on this LAN.

Returns:
The packets on this LAN.