|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.sf.extjwnl.dictionary.file_manager.FileManagerImpl
public class FileManagerImpl
An implementation of FileManager
that reads files from the local file system.
FileManagerImpl
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.
Field Summary | |
---|---|
static String |
CACHE_USE_COUNT_KEY
Whether to cache use counts, default false. |
Constructor Summary | |
---|---|
FileManagerImpl(Dictionary dictionary,
Map<String,Param> params)
|
Method Summary | |
---|---|
void |
close()
Shuts down the file manager. |
void |
delete()
Deletes the dictionary. |
void |
edit()
Reopens files for writing. |
String |
fileReadLineAt(RandomAccessDictionaryFile file,
long offset)
|
Dictionary |
getDictionary()
Returns the dictionary this object belongs to. |
RandomAccessDictionaryFile |
getFile(POS pos,
DictionaryFileType fileType)
Returns the file from a part of speech and file type (ie data.noun). |
long |
getFirstLinePointer(POS pos,
DictionaryFileType fileType)
Return the first valid line pointer in the specified file. |
long |
getIndexedLinePointer(POS pos,
DictionaryFileType fileType,
String target)
Returns indexed line pointer is typically used to find a word within an index file matching a given part of speech. |
long |
getMatchingLinePointer(POS pos,
DictionaryFileType fileType,
long offset,
String substring)
Search for a line whose index word contains substring, starting at offset. |
long |
getNextLinePointer(POS pos,
DictionaryFileType fileType,
long offset)
Search for the line following the line that begins at offset. |
long |
getRandomLinePointer(POS pos,
DictionaryFileType fileType)
Return a randomly-chosen line pointer (offset of the beginning of a line). |
int |
getUseCount(String senseKey)
Returns the number of times the sense marked by senseKey occurs in a semantic concordance. |
String |
readLineAt(POS pos,
DictionaryFileType fileType,
long offset)
Read the line that begins at file offset offset. |
void |
save()
Saves the files. |
void |
setDictionary(Dictionary dictionary)
Sets the dictionary this object belongs to. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String CACHE_USE_COUNT_KEY
true speeds up elements
loading from files considerably, at the expense of some amount of memory.
- See Also:
- Constant Field Values
Constructor Detail |
---|
public FileManagerImpl(Dictionary dictionary, Map<String,Param> params) throws JWNLException
JWNLException
Method Detail |
---|
public void close()
FileManager
close
in interface FileManager
public void delete() throws IOException
FileManager
delete
in interface FileManager
IOException
- IOExceptionpublic void edit() throws IOException
FileManager
edit
in interface FileManager
IOException
- IOExceptionpublic RandomAccessDictionaryFile getFile(POS pos, DictionaryFileType fileType)
pos
- - the part of speech (NOUN, ADJ, VERB, ADV) or nullfileType
- - the file type (data, index, exc, cntlist)
public String readLineAt(POS pos, DictionaryFileType fileType, long offset) throws IOException
FileManager
readLineAt
in interface FileManager
pos
- part of speechfileType
- file typeoffset
- file offset
IOException
- IOExceptionpublic String fileReadLineAt(RandomAccessDictionaryFile file, long offset) throws IOException
IOException
public long getNextLinePointer(POS pos, DictionaryFileType fileType, long offset) throws IOException
FileManager
getNextLinePointer
in interface FileManager
pos
- part of speechfileType
- file typeoffset
- file offset
-1
if offset
is the last line in the file.
IOException
- IOExceptionpublic long getMatchingLinePointer(POS pos, DictionaryFileType fileType, long offset, String substring) throws IOException
FileManager
getMatchingLinePointer
in interface FileManager
pos
- part of speechfileType
- file typeoffset
- file offsetsubstring
- substring to search for in indexword
-1
if
no such line exists.
IOException
- IOExceptionpublic long getIndexedLinePointer(POS pos, DictionaryFileType fileType, String target) throws IOException
getIndexedLinePointer
in interface FileManager
pos
- part of speechfileType
- file typetarget
- word to search for
-1
if no such line exists.
IOException
- IOExceptionpublic long getRandomLinePointer(POS pos, DictionaryFileType fileType) throws IOException
FileManager
getRandomLinePointer
in interface FileManager
pos
- part of speechfileType
- file type
IOException
- IOExceptionpublic long getFirstLinePointer(POS pos, DictionaryFileType fileType) throws IOException
FileManager
getFirstLinePointer
in interface FileManager
pos
- part of speechfileType
- file type
IOException
- IOExceptionpublic Dictionary getDictionary()
Owned
getDictionary
in interface Owned
public void setDictionary(Dictionary dictionary)
Owned
setDictionary
in interface Owned
dictionary
- the dictionary this object belongs topublic void save() throws IOException, JWNLException
FileManager
save
in interface FileManager
IOException
- IOException
JWNLException
- JWNLExceptionpublic int getUseCount(String senseKey) throws IOException
FileManager
getUseCount
in interface FileManager
senseKey
- sense key
IOException
- IOException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |