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.
-
DOUBLE_AND_TIME
- Set if two doubles should be received or sent.
-
INPUT_SOCKET_ERROR
- Set if an inputsocket error has been caught.
-
INPUT_STREAM_BROKEN_ERROR
- Set if the inputstream has been broken.
-
INPUT_STREAM_ERROR
- Set if an inputstream error has been caught.
-
INPUT_STREAM_LOST_ERROR
- Set if the input stream disapeared for some reason.
-
INT_AND_TIME
- Set if both an integer and a double should be received or sent.
-
ONLY_DOUBLE
- Set if a single double has been received or should be sent.
-
ONLY_INT
- Set if a single integer has been received or should be sent.
-
ONLY_STRING
- Set if a single string has been received or should be sent.
-
OUTPUT_SOCKET_ERROR
- Set if an outputsocket error has been caught.
-
OUTPUT_STREAM_BROKEN_ERROR
- Set if the outputstream has been broken.
-
OUTPUT_STREAM_ERROR
- Set if an outputstream error has been caught.
-
OUTPUT_STREAM_LOST_ERROR
- Set if the output stream disapeared for some reason.
-
PROTOCOL_ERROR
- Set if the received data does not conform to the protocol.
-
STRING_AND_TIME
- Set if both a string and a double should be received or sent.
-
UNKNOWN_HOST_ERROR
- Set if host cannot be found.
-
TCPIPCommunicator()
- Constructs a new TCPIPCommunicator.
-
actionPerformed(ActionEvent)
- Invoked when the user either changes the value of one of the textfields
or clicks the connectbutton.
-
finalize()
- Closes everything at shutdown.
-
focusGained(FocusEvent)
- Invoked when either of the textfields gain focus.
-
focusLost(FocusEvent)
- Invoked when either of the textfields lose focus.
-
getEditable()
- Gets whether or not the textfields within the communicator are visible
and hence editable.
-
getHostName()
- Gets the name of host computer.
-
getReceiverPort()
- Gets the number of the port used for incoming values.
-
getSenderPort()
- Gets the number of the port used for outgoing values.
-
getStatusfield()
- Gets whether or not the statusfield within the communicator is visible.
-
sendValue(double, int, double)
- Used for sending a double value over the network.
-
sendValue(int, int, double)
- Used for sending an integer value over the network.
-
sendValue(String, int, double)
- Used for sending a string value over the network.
-
setEditable(boolean)
- Sets whether or not the textfields within the communicator should be
visible and hence editable.
-
setHostName(String)
- Sets the name of host computer.
-
setReceiverPort(int)
- Sets the number of the port used for incoming values.
-
setSenderPort(int)
- Sets the number of the port used for outgoing values.
-
setStatusfield(boolean)
- Sets whether or not the statusfield within the communicator should be
visible.
ONLY_INT
protected static final int ONLY_INT
- Set if a single integer has been received or should be sent.
ONLY_DOUBLE
protected static final int ONLY_DOUBLE
- Set if a single double has been received or should be sent.
ONLY_STRING
protected static final int ONLY_STRING
- Set if a single string has been received or should be sent.
INT_AND_TIME
protected static final int INT_AND_TIME
- Set if both an integer and a double should be received or sent.
DOUBLE_AND_TIME
protected static final int DOUBLE_AND_TIME
- Set if two doubles should be received or sent.
STRING_AND_TIME
protected static final int STRING_AND_TIME
- Set if both a string and a double should be received or sent.
OUTPUT_SOCKET_ERROR
protected static final int OUTPUT_SOCKET_ERROR
- Set if an outputsocket error has been caught.
OUTPUT_STREAM_ERROR
protected static final int OUTPUT_STREAM_ERROR
- Set if an outputstream error has been caught.
INPUT_SOCKET_ERROR
protected static final int INPUT_SOCKET_ERROR
- Set if an inputsocket error has been caught.
INPUT_STREAM_ERROR
protected static final int INPUT_STREAM_ERROR
- Set if an inputstream error has been caught.
OUTPUT_STREAM_BROKEN_ERROR
protected static final int OUTPUT_STREAM_BROKEN_ERROR
- Set if the outputstream has been broken.
INPUT_STREAM_BROKEN_ERROR
protected static final int INPUT_STREAM_BROKEN_ERROR
- Set if the inputstream has been broken.
PROTOCOL_ERROR
protected static final int PROTOCOL_ERROR
- Set if the received data does not conform to the protocol.
UNKNOWN_HOST_ERROR
protected static final int UNKNOWN_HOST_ERROR
- Set if host cannot be found.
OUTPUT_STREAM_LOST_ERROR
protected static final int OUTPUT_STREAM_LOST_ERROR
- Set if the output stream disapeared for some reason.
INPUT_STREAM_LOST_ERROR
protected static final int INPUT_STREAM_LOST_ERROR
- Set if the input stream disapeared for some reason.
TCPIPCommunicator
public TCPIPCommunicator()
- Constructs a new TCPIPCommunicator.
finalize
public void finalize()
- Closes everything at shutdown.
- Overrides:
- finalize in class Object
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.
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.
getStatusfield
public boolean getStatusfield()
- Gets whether or not the statusfield within the communicator is visible.
- Returns:
-
true
if the stausfield is visible;
false
otherwise.
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.
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.
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.
getReceiverPort
public int getReceiverPort()
- Gets the number of the port used for incoming values.
- Returns:
- the port number.
setReceiverPort
public void setReceiverPort(int value)
- Sets the number of the port used for incoming values.
- Parameters:
- value - the desired port number.
getSenderPort
public int getSenderPort()
- Gets the number of the port used for outgoing values.
- Returns:
- the port number.
setSenderPort
public void setSenderPort(int value)
- Sets the number of the port used for outgoing values.
- Parameters:
- value - the desired port number.
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
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
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
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.
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.
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