c408h003.omnieditor
Class File

java.lang.Object
  extended byc408h003.omnieditor.File

public class File
extends java.lang.Object


Constructor Summary
File(java.lang.String fileName, java.lang.String content)
          Constructs a File object with name and id.
 
Method Summary
 boolean addAction(Action act)
           
 int addUser()
          Adds a user to the list of users current editing the file.
 java.lang.String delete()
          Removes a previously selected string.
 int find(int start, java.lang.String target, boolean fwd, boolean caseSensitive)
          The following are methods providing editing functionalities, such as find, move, insert, etc.
 Action getAction(int index)
          Gets the index-th action performed on this file.
 java.lang.String getContent()
          Gets the contents of the file, as a string.
 java.lang.String getName()
          Gets the file's name.
 int getUserCount()
          Gets the number of users currently working on the file.
 int getVersionNumber()
          Gets the current working version of the file.
 void mark(int position)
          Marks a start position for the following select operation.
 void move(int newPos)
          Moves the cursor to new position.
 int removeUser()
          Removes a user ID from the list of the users who is editing the file
 java.lang.String select(int position)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

File

public File(java.lang.String fileName,
            java.lang.String content)
Constructs a File object with name and id.

Parameters:
fileName - name of the File
content - the contents of the file
Method Detail

addUser

public int addUser()
Adds a user to the list of users current editing the file.

Returns:
the number of the users current editing the file

removeUser

public int removeUser()
Removes a user ID from the list of the users who is editing the file

Returns:
the number of the users current editing the file

find

public int find(int start,
                java.lang.String target,
                boolean fwd,
                boolean caseSensitive)
         throws java.lang.NullPointerException
The following are methods providing editing functionalities, such as find, move, insert, etc.

Throws:
java.lang.NullPointerException

move

public void move(int newPos)
Moves the cursor to new position.

Parameters:
newPos - the new position of the cursor

mark

public void mark(int position)
          throws java.lang.IndexOutOfBoundsException
Marks a start position for the following select operation.

Parameters:
position - the current position of the cursor
Throws:
IllegalPositionException - if the position is not within the bound of the file, throw this Exception.
java.lang.IndexOutOfBoundsException

select

public java.lang.String select(int position)
                        throws java.lang.IndexOutOfBoundsException
Throws:
java.lang.IndexOutOfBoundsException

delete

public java.lang.String delete()
Removes a previously selected string.

Returns:
the string removed or null, if no string selected

getContent

public java.lang.String getContent()
Gets the contents of the file, as a string.

Returns:
a string stands for the contents

getName

public java.lang.String getName()
Gets the file's name.

Returns:
file name as a string

getVersionNumber

public int getVersionNumber()
Gets the current working version of the file.

Returns:
version number as an int, version number is greater than or equal to 0.

getAction

public Action getAction(int index)
Gets the index-th action performed on this file.

Parameters:
index - the action number you want to have.
Returns:
an Action object

addAction

public boolean addAction(Action act)

getUserCount

public int getUserCount()
Gets the number of users currently working on the file.

Returns:
the user count, must be greater than or equal to zero.