c408h006
Class Connections

java.lang.Object
  extended byc408h006.Connections

public class Connections
extends java.lang.Object

Connections maintains a list of Connection objects.


Constructor Summary
Connections()
          Contructs an instance of this class.
 
Method Summary
 java.lang.String disConnect(int id, java.lang.String fileName)
          Disconnect a User from the OmniEditor system, if that User is the last User connected to the file, the Connection to the file will be removed.
 Connection getConnection(java.lang.String fileName)
          Returns the Connections associated with the specified file.
static Connections getConnections()
          Returns the static instance of this class.
 FileState getFileState(int id, java.lang.String fileName)
          Return the current state of the file.
 int makeConnection(java.lang.String fileName)
          Returns the user's ID when a connection to a file has been established.
 java.lang.String sendCommand(Command c)
          Passes the command to the appropriate connection so that it can be performed on the correct file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Connections

public Connections()
Contructs an instance of this class. Note that only one instance of this class is created per session with the OmniEditor.

Method Detail

getConnections

public static Connections getConnections()
Returns the static instance of this class. Only one user may access this method at a time.

Returns:
The instance of this class if one already exists or a new one if none previously existed

makeConnection

public int makeConnection(java.lang.String fileName)
Returns the user's ID when a connection to a file has been established. Only one user may access this method at a time.

Parameters:
fileName - The name of the file to connect to
Returns:
The ID of the user

disConnect

public java.lang.String disConnect(int id,
                                   java.lang.String fileName)
Disconnect a User from the OmniEditor system, if that User is the last User connected to the file, the Connection to the file will be removed.

Parameters:
id - The id of the User to disconnect
fileName - The file the User is connected to
Returns:
"#OK#" if the disconnect was successfull, "#ERR#" otherwise

sendCommand

public java.lang.String sendCommand(Command c)
Passes the command to the appropriate connection so that it can be performed on the correct file.

Parameters:
c - A Command object which contains the command to be performed and the name of the file that the command will be performed on
Returns:
A message which indicates whether the command was performed successfully

getConnection

public Connection getConnection(java.lang.String fileName)
Returns the Connections associated with the specified file.

Parameters:
fileName - The name of the file associated with a Connection
Returns:
The Connection associated with the file with name fileName

getFileState

public FileState getFileState(int id,
                              java.lang.String fileName)
Return the current state of the file.

Parameters:
id - The id of the User who is requesting the FileState
fileName - The name of the file who's FileState is being requested.
Returns:
The current state of the file