|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object edu.brandeis.cs.steele.wn.FileManager
public class FileManager
An implementation of FileManagerInterface that reads files from the local file system.
a file. FileManager
caches the file position before and after
readLineAt
in order to eliminate the redundant IO activity that a naive implementation
of these methods would necessitate.
Instances of this class are guarded. Operations are synchronized by file.
Nested Class Summary | |
---|---|
protected class |
FileManager.NextLineCache
|
Field Summary | |
---|---|
protected java.util.Hashtable<java.lang.String,java.io.RandomAccessFile> |
filenameCache
|
protected static java.lang.String |
fileSeparator
|
protected static boolean |
IS_MAC_OS
|
protected static boolean |
IS_MW_VM
|
protected static boolean |
IS_WINDOWS_OS
|
protected FileManager.NextLineCache |
nextLineCache
|
protected java.lang.String |
searchDirectory
|
static boolean |
TRACE_LOOKUP
Set this to true to enable debugging messages in getIndexedLinePointer . |
static java.lang.String |
VERSION
The API version, used by RemoteFileManager for constructing a binding name. |
Constructor Summary | |
---|---|
FileManager()
Construct a file manager backed by a set of files contained in the default WN search directory. |
|
FileManager(java.lang.String searchDirectory)
Construct a file manager backed by a set of files contained in searchDirectory. |
Method Summary | |
---|---|
protected int |
compare(java.lang.String a,
java.lang.String b)
Return a negative value if a precedes b, a positive value if a follows b, otherwise 0. |
protected java.io.RandomAccessFile |
getFileStream(java.lang.String filename)
|
long |
getIndexedLinePointer(java.lang.String filename,
java.lang.String target)
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. |
protected static java.lang.String |
getWNHome()
|
protected static java.lang.String |
getWNSearchDir()
|
(package private) static java.lang.String |
mapToWindowsFilename(java.lang.String filename)
|
protected java.lang.String |
readLine(java.io.RandomAccessFile stream)
|
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. |
protected java.lang.String |
readLineWord(java.io.RandomAccessFile stream)
|
protected void |
skipLine(java.io.RandomAccessFile stream)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static java.lang.String VERSION
RemoteFileManager
for constructing a binding name.
public static final boolean TRACE_LOOKUP
getIndexedLinePointer
.
protected static final boolean IS_MW_VM
protected java.lang.String searchDirectory
protected java.util.Hashtable<java.lang.String,java.io.RandomAccessFile> filenameCache
protected FileManager.NextLineCache nextLineCache
protected static final boolean IS_WINDOWS_OS
protected static final boolean IS_MAC_OS
protected static final java.lang.String fileSeparator
Constructor Detail |
---|
public FileManager()
public FileManager(java.lang.String searchDirectory)
Method Detail |
---|
protected static java.lang.String getWNHome()
protected static java.lang.String getWNSearchDir()
static java.lang.String mapToWindowsFilename(java.lang.String filename)
protected java.io.RandomAccessFile getFileStream(java.lang.String filename) throws java.io.IOException
java.io.IOException
protected java.lang.String readLine(java.io.RandomAccessFile stream) throws java.io.IOException
java.io.IOException
protected void skipLine(java.io.RandomAccessFile stream) throws java.io.IOException
java.io.IOException
public java.lang.String readLineAt(java.lang.String filename, long offset) throws java.io.IOException
FileManagerInterface
readLineAt
in interface FileManagerInterface
java.io.IOException
protected java.lang.String readLineWord(java.io.RandomAccessFile stream) throws java.io.IOException
java.io.IOException
public long getNextLinePointer(java.lang.String filename, long offset) throws java.io.IOException
FileManagerInterface
getNextLinePointer
in interface FileManagerInterface
-1
if offset
is the last line in the file.
java.io.IOException
public long getMatchingLinePointer(java.lang.String filename, long offset, java.lang.String substring) throws java.io.IOException
FileManagerInterface
getMatchingLinePointer
in interface FileManagerInterface
-1
if
no such line exists.
java.io.IOException
public long getIndexedLinePointer(java.lang.String filename, java.lang.String target) throws java.io.IOException
FileManagerInterface
getIndexedLinePointer
in interface FileManagerInterface
-1
if no such line
exists.
java.io.IOException
protected int compare(java.lang.String a, java.lang.String b)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |