network
Class AbCommsDG

java.lang.Object
  extended by network.AbCommsDG
All Implemented Interfaces:
java.io.Serializable, java.lang.Runnable
Direct Known Subclasses:
RecieveComms, SendComms

public abstract class AbCommsDG
extends java.lang.Object
implements java.io.Serializable, java.lang.Runnable

Created on November 8, 2006, 4:31 PM
Abstract comms used as the parent for SendComms and RecieveComms.

Uses datagrams to handle the communications.
Sending or waiting for acks is handled by the classes that implement AbCommsDG.
Each child implements and uses the socket, packet, remoteHost, and connectedAddress variables differently.
Created to help simplify and organize communications.

Version:
t.4
Author:
Eric Angeli
See Also:
Serialized Form

Constructor Summary
AbCommsDG()
          Creates a new instance of AbCommsDG
 
Method Summary
 void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
          Adds the property change listener.
 byte[] getBuffer()
          Gets the buffer to be sent.
 java.net.InetAddress getConnectedAddress()
          Gets the address connected to.
 java.net.DatagramPacket getPacket()
          Gets the packet used for communications.
 int getPort()
          Gets the port number.
 java.beans.PropertyChangeSupport getPropertySupport()
          Gets the property change support.
 java.lang.String getRemoteHost()
          Gets the remote host.
 java.lang.Thread getRunner()
          Gets the current thread that is running.
 java.net.DatagramSocket getSocket()
          Gets the datagram socket.
 boolean isAckRequired()
          The ack state.
 boolean isAlreadyConnected()
          The state of the connection.
 boolean isPauseComms()
          The pause state of communications.
 boolean isRunning()
          The running state of the thread.
 void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
          Removes the property change listener.
abstract  void run()
          Runs the thread.
 void setAckRequired(boolean ackRequired)
          Sets the ack state.
 void setAlreadyConnected(boolean alreadyConnected)
          Set the connection state.
 void setBuffer(byte[] buffer)
          Sets the buffer with the byte array containing the data to be sent.
 void setConnectedAddress(java.net.InetAddress connectedAddress)
          Sets teh connected address.
 void setPacket(java.net.DatagramPacket packet)
          Sets the datagram packet used for communications.
 void setPauseComms(boolean pauseComms)
          Set the pause state of communications.
 void setPort(int port)
          Sets the port number to send to.
 void setRemoteHost(java.lang.String remoteHost)
          Sets the remote host.
 void setRunner(java.lang.Thread runner)
          Sets the currently running thread.
 void setRunning(boolean running)
          Sets the running state of the thread.
 void setSocket(java.net.DatagramSocket socket)
          Sets the data gram socket.
 void startComms()
          Starts the communications.
 void stopComms()
          Stops the communications.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbCommsDG

public AbCommsDG()
Creates a new instance of AbCommsDG

Method Detail

addPropertyChangeListener

public void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
Adds the property change listener.

Parameters:
listener - The new listener.

removePropertyChangeListener

public void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
Removes the property change listener.

Parameters:
listener - The listener to remove.

getPropertySupport

public java.beans.PropertyChangeSupport getPropertySupport()
Gets the property change support.

Returns:
The property change support.

getRunner

public java.lang.Thread getRunner()
Gets the current thread that is running.

Returns:
The thread that is running.

setRunner

public void setRunner(java.lang.Thread runner)
Sets the currently running thread.

Parameters:
runner - THe new thread that is running.

isRunning

public boolean isRunning()
The running state of the thread.

Returns:
True if running, otherwise false.

setRunning

public void setRunning(boolean running)
Sets the running state of the thread.

Parameters:
running - The new running state, true if running, otherwise false.

isPauseComms

public boolean isPauseComms()
The pause state of communications.

Returns:
True if comms is paused, otherwise false.

setPauseComms

public void setPauseComms(boolean pauseComms)
Set the pause state of communications.

Parameters:
pauseComms - The new pause state, true if paused, otheriwse false.

getRemoteHost

public java.lang.String getRemoteHost()
Gets the remote host.

Returns:
The remote host.

setRemoteHost

public void setRemoteHost(java.lang.String remoteHost)
Sets the remote host.

Parameters:
remoteHost - The new remote host.

getPacket

public java.net.DatagramPacket getPacket()
Gets the packet used for communications.

Returns:
The packet.

setPacket

public void setPacket(java.net.DatagramPacket packet)
Sets the datagram packet used for communications.

Parameters:
packet - The new datagram packet.

getSocket

public java.net.DatagramSocket getSocket()
Gets the datagram socket.

Returns:
The datagram socket used for communications.

setSocket

public void setSocket(java.net.DatagramSocket socket)
Sets the data gram socket.

Parameters:
socket - The socket used for communications.

isAlreadyConnected

public boolean isAlreadyConnected()
The state of the connection.

Returns:
True if already connected, false if not.

setAlreadyConnected

public void setAlreadyConnected(boolean alreadyConnected)
Set the connection state.

Parameters:
alreadyConnected - The new connection sate, true if connected, false if not.

getConnectedAddress

public java.net.InetAddress getConnectedAddress()
Gets the address connected to.

Returns:
The connected address.

setConnectedAddress

public void setConnectedAddress(java.net.InetAddress connectedAddress)
Sets teh connected address.

Parameters:
connectedAddress - The new connected address.

getPort

public int getPort()
Gets the port number.

Returns:
The port number.

setPort

public void setPort(int port)
Sets the port number to send to.

Parameters:
port - The new port number.

getBuffer

public byte[] getBuffer()
Gets the buffer to be sent.

Returns:
The buffer to be sent.

setBuffer

public void setBuffer(byte[] buffer)
Sets the buffer with the byte array containing the data to be sent.

Parameters:
buffer - The buffer array containing the data.

isAckRequired

public boolean isAckRequired()
The ack state.

Returns:
True if required otherwise false.

setAckRequired

public void setAckRequired(boolean ackRequired)
Sets the ack state.

Parameters:
ackRequired - True if an ack is required. Otherwise false.

startComms

public void startComms()
Starts the communications.


stopComms

public void stopComms()
Stops the communications.


run

public abstract void run()
Runs the thread.

Specified by:
run in interface java.lang.Runnable