|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectedu.illinois.cs.cogcomp.lbj.coref.io.WNFileManager
public class WNFileManager
An implementation of FileManagerInterface that reads files from the local
file system, including from jar files. The 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.
Modifications (By Eric Bengtson) to this file change the type of file from RandomAccessFile to something compatible with InputStream so that getResourceAsStream can be used to enable loading of the files inside a jar.
Nested Class Summary | |
---|---|
protected class |
WNFileManager.NextLineCache
|
Field Summary | |
---|---|
protected java.util.Hashtable<java.lang.String,RandomAccessInput> |
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 WNFileManager.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 | |
---|---|
WNFileManager()
Construct a file manager backed by a set of files contained in the default WN search directory. |
|
WNFileManager(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 RandomAccessInput |
getFileStream(java.lang.String filename)
Loads database files located relative to the classpath. |
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(RandomAccessInput 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(RandomAccessInput stream)
|
protected void |
skipLine(RandomAccessInput 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,RandomAccessInput> filenameCache
protected WNFileManager.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 WNFileManager()
public WNFileManager(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 RandomAccessInput getFileStream(java.lang.String filename) throws java.io.IOException
java.io.IOException
protected java.lang.String readLine(RandomAccessInput stream) throws java.io.IOException
java.io.IOException
protected void skipLine(RandomAccessInput 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(RandomAccessInput 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 |