All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class ControlBeans.TCPIPCommunicator

java.lang.Object
   |
   +----java.awt.Component
           |
           +----java.awt.Container
                   |
                   +----com.sun.java.swing.JComponent
                           |
                           +----com.sun.java.swing.JPanel
                                   |
                                   +----ControlBeans.AbstractCommunicator
                                           |
                                           +----ControlBeans.TCPIPCommunicator

public class TCPIPCommunicator
extends AbstractCommunicator
implements Serializable, ActionListener, FocusListener
This class implements a control component which can send and receive values over a TCP/IP network. For each value it wishes to send or receive, it does so according to the following protocol:
Type: an integer value describing what type of value will follow.
Tag: an integer value to allow the recipient to determine where to distribute the data.
Data: either an integer, double or string.
Time: an optional double value timestamp.


Variable Index

 o DOUBLE_AND_TIME
Set if two doubles should be received or sent.
 o INPUT_SOCKET_ERROR
Set if an inputsocket error has been caught.
 o INPUT_STREAM_BROKEN_ERROR
Set if the inputstream has been broken.
 o INPUT_STREAM_ERROR
Set if an inputstream error has been caught.
 o INPUT_STREAM_LOST_ERROR
Set if the input stream disapeared for some reason.
 o INT_AND_TIME
Set if both an integer and a double should be received or sent.
 o ONLY_DOUBLE
Set if a single double has been received or should be sent.
 o ONLY_INT
Set if a single integer has been received or should be sent.
 o ONLY_STRING
Set if a single string has been received or should be sent.
 o OUTPUT_SOCKET_ERROR
Set if an outputsocket error has been caught.
 o OUTPUT_STREAM_BROKEN_ERROR
Set if the outputstream has been broken.
 o OUTPUT_STREAM_ERROR
Set if an outputstream error has been caught.
 o OUTPUT_STREAM_LOST_ERROR
Set if the output stream disapeared for some reason.
 o PROTOCOL_ERROR
Set if the received data does not conform to the protocol.
 o STRING_AND_TIME
Set if both a string and a double should be received or sent.
 o UNKNOWN_HOST_ERROR
Set if host cannot be found.

Constructor Index

 o TCPIPCommunicator()
Constructs a new TCPIPCommunicator.

Method Index

 o actionPerformed(ActionEvent)
Invoked when the user either changes the value of one of the textfields or clicks the connectbutton.
 o finalize()
Closes everything at shutdown.
 o focusGained(FocusEvent)
Invoked when either of the textfields gain focus.
 o focusLost(FocusEvent)
Invoked when either of the textfields lose focus.
 o getEditable()
Gets whether or not the textfields within the communicator are visible and hence editable.
 o getHostName()
Gets the name of host computer.
 o getReceiverPort()
Gets the number of the port used for incoming values.
 o getSenderPort()
Gets the number of the port used for outgoing values.
 o getStatusfield()
Gets whether or not the statusfield within the communicator is visible.
 o sendValue(double, int, double)
Used for sending a double value over the network.
 o sendValue(int, int, double)
Used for sending an integer value over the network.
 o sendValue(String, int, double)
Used for sending a string value over the network.
 o setEditable(boolean)
Sets whether or not the textfields within the communicator should be visible and hence editable.
 o setHostName(String)
Sets the name of host computer.
 o setReceiverPort(int)
Sets the number of the port used for incoming values.
 o setSenderPort(int)
Sets the number of the port used for outgoing values.
 o setStatusfield(boolean)
Sets whether or not the statusfield within the communicator should be visible.

Variables

 o ONLY_INT
 protected static final int ONLY_INT
Set if a single integer has been received or should be sent.

 o ONLY_DOUBLE
 protected static final int ONLY_DOUBLE
Set if a single double has been received or should be sent.

 o ONLY_STRING
 protected static final int ONLY_STRING
Set if a single string has been received or should be sent.

 o INT_AND_TIME
 protected static final int INT_AND_TIME
Set if both an integer and a double should be received or sent.

 o DOUBLE_AND_TIME
 protected static final int DOUBLE_AND_TIME
Set if two doubles should be received or sent.

 o STRING_AND_TIME
 protected static final int STRING_AND_TIME
Set if both a string and a double should be received or sent.

 o OUTPUT_SOCKET_ERROR
 protected static final int OUTPUT_SOCKET_ERROR
Set if an outputsocket error has been caught.

 o OUTPUT_STREAM_ERROR
 protected static final int OUTPUT_STREAM_ERROR
Set if an outputstream error has been caught.

 o INPUT_SOCKET_ERROR
 protected static final int INPUT_SOCKET_ERROR
Set if an inputsocket error has been caught.

 o INPUT_STREAM_ERROR
 protected static final int INPUT_STREAM_ERROR
Set if an inputstream error has been caught.

 o OUTPUT_STREAM_BROKEN_ERROR
 protected static final int OUTPUT_STREAM_BROKEN_ERROR
Set if the outputstream has been broken.

 o INPUT_STREAM_BROKEN_ERROR
 protected static final int INPUT_STREAM_BROKEN_ERROR
Set if the inputstream has been broken.

 o PROTOCOL_ERROR
 protected static final int PROTOCOL_ERROR
Set if the received data does not conform to the protocol.

 o UNKNOWN_HOST_ERROR
 protected static final int UNKNOWN_HOST_ERROR
Set if host cannot be found.

 o OUTPUT_STREAM_LOST_ERROR
 protected static final int OUTPUT_STREAM_LOST_ERROR
Set if the output stream disapeared for some reason.

 o INPUT_STREAM_LOST_ERROR
 protected static final int INPUT_STREAM_LOST_ERROR
Set if the input stream disapeared for some reason.

Constructors

 o TCPIPCommunicator
 public TCPIPCommunicator()
Constructs a new TCPIPCommunicator.

Methods

 o finalize
 public void finalize()
Closes everything at shutdown.

Overrides:
finalize in class Object
 o getEditable
 public boolean getEditable()
Gets whether or not the textfields within the communicator are visible and hence editable.

Returns:
true if the textfields are visible; false otherwise.
 o setEditable
 public void setEditable(boolean value)
Sets whether or not the textfields within the communicator should be visible and hence editable.

Parameters:
value - true if the textfields should be visible; false otherwise.
 o getStatusfield
 public boolean getStatusfield()
Gets whether or not the statusfield within the communicator is visible.

Returns:
true if the stausfield is visible; false otherwise.
 o setStatusfield
 public void setStatusfield(boolean value)
Sets whether or not the statusfield within the communicator should be visible.

Parameters:
value - true if the statusfield should be visible; false otherwise.
 o getHostName
 public String getHostName()
Gets the name of host computer. This is the computer which this communicator will attempt to connect to.

Returns:
the name of the host computer.
 o setHostName
 public void setHostName(String value)
Sets the name of host computer. This is the computer which this communicator will attempt to connect to.

Parameters:
value - the desired name of the host computer.
 o getReceiverPort
 public int getReceiverPort()
Gets the number of the port used for incoming values.

Returns:
the port number.
 o setReceiverPort
 public void setReceiverPort(int value)
Sets the number of the port used for incoming values.

Parameters:
value - the desired port number.
 o getSenderPort
 public int getSenderPort()
Gets the number of the port used for outgoing values.

Returns:
the port number.
 o setSenderPort
 public void setSenderPort(int value)
Sets the number of the port used for outgoing values.

Parameters:
value - the desired port number.
 o sendValue
 protected void sendValue(int value,
                          int aTag,
                          double time)
Used for sending an integer value over the network.
NOTE: This method is automatically invoked by AbstractCommunicator when it wishes to send a value and should therefore not be called directly by the user.

Parameters:
value - the value to be transmitted
aTag - the tag of components to receive the value
time - a time tag for the value
Overrides:
sendValue in class AbstractCommunicator
 o sendValue
 protected void sendValue(double value,
                          int aTag,
                          double time)
Used for sending a double value over the network.
NOTE: This method is automatically invoked by AbstractCommunicator when it wishes to send a value and should therefore not be called directly by the user.

Parameters:
value - the value to be transmitted
aTag - the tag of components to receive the value
time - a time tag for the value
Overrides:
sendValue in class AbstractCommunicator
 o sendValue
 protected void sendValue(String value,
                          int aTag,
                          double time)
Used for sending a string value over the network.
NOTE: This method is automatically invoked by AbstractCommunicator when it wishes to send a value and should therefore not be called directly by the user.

Parameters:
value - the value to be transmitted
aTag - the tag of components to receive the value
time - a time tag for the value
Overrides:
sendValue in class AbstractCommunicator
 o focusGained
 public void focusGained(FocusEvent e)
Invoked when either of the textfields gain focus.
NOTE: This method is invoked by the AWT event handling and should therefore never be called directly by the user.

Parameters:
e - the event describing that a component gained focus.
 o focusLost
 public void focusLost(FocusEvent e)
Invoked when either of the textfields lose focus. When that happens, this communicator will check to see that no illegal values have been entered in the textfield (such as a invalid portnumber).
NOTE: This method is invoked by the AWT event handling and should therefore never be called directly by the user.

Parameters:
e - the event describing that a component gained focus.
 o actionPerformed
 public void actionPerformed(ActionEvent e)
Invoked when the user either changes the value of one of the textfields or clicks the connectbutton.
NOTE: This method is invoked by the AWT event handling and should therefore never be called directly by the user.

Parameters:
e - the event describing that someone either clicked the button or changed the text in one of the textfields.

All Packages  Class Hierarchy  This Package  Previous  Next  Index