c408h006
Class Connection

java.lang.Object
  extended byc408h006.Connection

public class Connection
extends java.lang.Object

Connection to a file within the OmniEditor System.


Constructor Summary
Connection(java.lang.String fileName)
          Constructs an instance of this class.
 
Method Summary
 int addUser()
          Adds a new user to the list of users using this connection and returns that user's ID.
 java.lang.String disConnect(int id)
          Disconnect a User from the OmniEditor system.
 java.lang.String download(Command c)
          Save the file to the WebService.
 java.lang.String getFileName()
          Returns the name of the file that this connection is linked to.
 FileState getFileState(int id)
          Return the current state of the file.
 java.lang.String mark(Command c)
          Mark the current position with the file.
 java.lang.String move(Command c)
          Move the user's cursor position.
 java.lang.String performCommand(Command c)
          Performs the necessary action on the file as requested by the user and returns a string message which indicates whether the action was performed succesfully.
 java.lang.String select(Command c)
          Selects a block of text specified from the mark position to end position specified by the user.
 java.lang.String upload(Command c)
          Opens the file for use for editing.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Connection

public Connection(java.lang.String fileName)
Constructs an instance of this class.

Parameters:
fileName - The name of the file to connect to
Method Detail

getFileName

public java.lang.String getFileName()
Returns the name of the file that this connection is linked to.

Returns:
The name of the file that this connection is linked to

addUser

public int addUser()
Adds a new user to the list of users using this connection and returns that user's ID.

Returns:
The ID of the new user

performCommand

public java.lang.String performCommand(Command c)
Performs the necessary action on the file as requested by the user and returns a string message which indicates whether the action was performed succesfully.

Parameters:
c - A command object which contains the command that the user wants to perform on the file
Returns:
A string message which indicates whether action was successful

download

public java.lang.String download(Command c)
Save the file to the WebService.

Parameters:
c - A Command object which contains the name of the file to be saved
Returns:
A string message which indicates whether action was successful

upload

public java.lang.String upload(Command c)
Opens the file for use for editing.

Parameters:
c - A Command object which contains the user's ID
Returns:
The contents of the file if successful, otherwise returns an error message

move

public java.lang.String move(Command c)
Move the user's cursor position.

Parameters:
c - A Command object which contains the user's ID and the position to move to
Returns:
A string message which indicates whether action was successful

mark

public java.lang.String mark(Command c)
Mark the current position with the file.

Parameters:
c - A Command object which contains the user's ID and the position to mark
Returns:
A string message which indicates whether action was successful

select

public java.lang.String select(Command c)
Selects a block of text specified from the mark position to end position specified by the user.

Parameters:
c - A Command object which contains the end position and the user's ID
Returns:
A string message which indicates whether action was successful

getFileState

public FileState getFileState(int id)
Return the current state of the file.

Parameters:
id - The id of the User who is requesting the FileState
Returns:
The current state of the file

disConnect

public java.lang.String disConnect(int id)
Disconnect a User from the OmniEditor system.

Parameters:
id - The id of the User to disconnect
Returns:
"#OK#" if the disconnect was successfull, "#ERR#" if the User does not exist, "#EMP#" if the User is last User connected to the file