public class FileManagerImpl extends java.lang.Object implements FileManager
FileManager that reads files from the local file system.| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
CACHE_USE_COUNT_KEY
Whether to cache use counts, default false.
|
static java.lang.String |
CHECK_PATH_KEY
Whether to check dictionary path existence.
|
| Constructor and Description |
|---|
FileManagerImpl(Dictionary dictionary,
java.util.Map<java.lang.String,Param> params) |
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Shuts down the file manager.
|
boolean |
delete()
Deletes the dictionary.
|
void |
edit()
Reopens files for writing.
|
Dictionary |
getDictionary()
Returns the dictionary this object belongs to.
|
long |
getFirstLineOffset(POS pos,
DictionaryFileType fileType)
Returns the offset of the first valid line in the file (i.e.
|
PointedCharSequence |
getIndexedLine(POS pos,
DictionaryFileType fileType,
java.lang.String index)
Returns the line whose first word is index or null if not found.
|
PointedCharSequence |
getMatchingLine(POS pos,
DictionaryFileType fileType,
long offset,
java.lang.String substring)
Returns the line whose index word contains substring,
starting at offset or null if not found.
|
PointedCharSequence |
getRandomLine(POS pos,
DictionaryFileType fileType)
Returns a randomly-chosen line.
|
int |
getUseCount(java.lang.String senseKey)
Returns the number of times the sense marked by senseKey occurs in a semantic concordance.
|
PointedCharSequence |
readLineAt(POS pos,
DictionaryFileType fileType,
long offset)
Returns the line that begins at file offset offset.
|
void |
save()
Saves the files.
|
void |
setDictionary(Dictionary dictionary)
Sets the dictionary this object belongs to.
|
public static final java.lang.String CHECK_PATH_KEY
public static final java.lang.String CACHE_USE_COUNT_KEY
true speeds up elements
loading from files considerably, at the expense of some amount of memory.public FileManagerImpl(Dictionary dictionary, java.util.Map<java.lang.String,Param> params) throws JWNLException
JWNLExceptionpublic void close()
throws JWNLException
FileManagerclose in interface FileManagerJWNLException - JWNLExceptionpublic boolean delete()
throws JWNLException
FileManagerdelete in interface FileManagerJWNLException - JWNLExceptionpublic void edit()
throws JWNLException
FileManageredit in interface FileManagerJWNLException - JWNLExceptionpublic PointedCharSequence readLineAt(POS pos, DictionaryFileType fileType, long offset) throws JWNLException
FileManagerreadLineAt in interface FileManagerpos - part of speechfileType - file typeoffset - file offsetJWNLException - JWNLExceptionpublic PointedCharSequence getMatchingLine(POS pos, DictionaryFileType fileType, long offset, java.lang.String substring) throws JWNLException
FileManagergetMatchingLine in interface FileManagerpos - part of speechfileType - file typeoffset - file offsetsubstring - substring to search for in indexwordJWNLException - JWNLExceptionpublic PointedCharSequence getIndexedLine(POS pos, DictionaryFileType fileType, java.lang.String index) throws JWNLException
FileManagergetIndexedLine in interface FileManagerpos - part of speechfileType - file typeindex - word to search forJWNLException - JWNLExceptionpublic PointedCharSequence getRandomLine(POS pos, DictionaryFileType fileType) throws JWNLException
FileManagergetRandomLine in interface FileManagerpos - part of speechfileType - file typeJWNLException - JWNLExceptionpublic long getFirstLineOffset(POS pos, DictionaryFileType fileType) throws JWNLException
FileManagergetFirstLineOffset in interface FileManagerpos - part of speechfileType - file typeJWNLException - JWNLExceptionpublic Dictionary getDictionary()
OwnedgetDictionary in interface Ownedpublic void setDictionary(Dictionary dictionary)
OwnedsetDictionary in interface Owneddictionary - the dictionary this object belongs topublic void save()
throws JWNLException
FileManagersave in interface FileManagerJWNLException - JWNLExceptionpublic int getUseCount(java.lang.String senseKey)
throws JWNLException
FileManagergetUseCount in interface FileManagersenseKey - sense keyJWNLException - JWNLException