edu.brandeis.cs.steele.wn
Interface FileManagerInterface

All Superinterfaces:
java.rmi.Remote
All Known Implementing Classes:
FileManager, RemoteFileManager, WNFileManager

public interface FileManagerInterface
extends java.rmi.Remote

FileManagerInterface defines the interface between the FileBackedDictionary and the file system. FileBackedDictionary invokes methods from this interface to retrieve lines of text from the WordNet data files.

Methods in this interface take filenames as arguments. The filename is the name of a WordNet file, and is relative to the database directory (e.g. "data.noun", not "Dictionary/data.noun"), and uses the UNIX/MacOS naming conventions for WordNet files (e.g. "data.noun", not "noun.dat"), regardless of the platform the FileManagerInterface server is running on. (The reason for this is that the client doesn't generally know what platform the server is running on.)

Methods in this interface operate on and return pointers, which are indices into the file named by filename.

FileManagerInterface is designed to work efficiently across a network. To this end, it obeys two design principles: it uses only primitive types (including String) as argument and return types, and operations that search a file for a line with a specific property are provided by the server. The first principle ensures that scanning a database won't create a large number of remote objects that must then be queried and garbage-collected (each requiring additional RPC). The second principle avoids paging an entire database file across the network in order to search for an entry.

Making FileBackedDictionary would violate the first of these properties (it would require that Word, Synset, POS, etc. be supported as remote objects); a generic remote file system interface would violate the second.

A third design principle is that sessions are stateless -- this simplifies the implementation of the server. A consequence of this principle together with the restriction of return values to primitives is that pairs of operations such as getNextLinePointer/readLineAt are required in order to step through a file. The implementor of FileManagerInterface can cache the file position before and after readLineAt in order to eliminate the redundant IO activity that a naive implementation of these methods would necessitate.

Author:
Oliver Steele, steele@cs.brandeis.edu

Method Summary
 long getIndexedLinePointer(java.lang.String filename, java.lang.String index)
          Search for the line whose first word is index (that is, that begins with index followed by a space or tab).
 long getMatchingLinePointer(java.lang.String filename, long offset, java.lang.String substring)
          Search for a line whose index word contains substring.
 long getNextLinePointer(java.lang.String filename, long offset)
          Search for the line following the line that begins at offset.
 java.lang.String readLineAt(java.lang.String filename, long offset)
          Read the line that begins at file offset offset in the file named by filename.
 

Method Detail

getIndexedLinePointer

long getIndexedLinePointer(java.lang.String filename,
                           java.lang.String index)
                           throws java.io.IOException,
                                  java.rmi.RemoteException
Search for the line whose first word is index (that is, that begins with index followed by a space or tab). filename must name a file whose lines are sorted by index word.

Returns:
The file offset of the start of the matching line, or -1 if no such line exists.
Throws:
java.io.IOException
java.rmi.RemoteException

readLineAt

java.lang.String readLineAt(java.lang.String filename,
                            long offset)
                            throws java.io.IOException,
                                   java.rmi.RemoteException
Read the line that begins at file offset offset in the file named by filename.

Throws:
java.io.IOException
java.rmi.RemoteException

getNextLinePointer

long getNextLinePointer(java.lang.String filename,
                        long offset)
                        throws java.io.IOException,
                               java.rmi.RemoteException
Search for the line following the line that begins at offset.

Returns:
The file offset of the start of the line, or -1 if offset is the last line in the file.
Throws:
java.io.IOException
java.rmi.RemoteException

getMatchingLinePointer

long getMatchingLinePointer(java.lang.String filename,
                            long offset,
                            java.lang.String substring)
                            throws java.io.IOException,
                                   java.rmi.RemoteException
Search for a line whose index word contains substring.

Returns:
The file offset of the start of the matchng line, or -1 if no such line exists.
Throws:
java.io.IOException
java.rmi.RemoteException