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
JWNLException
public void close() throws JWNLException
FileManager
close
in interface FileManager
JWNLException
- JWNLExceptionpublic boolean delete() throws JWNLException
FileManager
delete
in interface FileManager
JWNLException
- JWNLExceptionpublic void edit() throws JWNLException
FileManager
edit
in interface FileManager
JWNLException
- JWNLExceptionpublic PointedCharSequence readLineAt(POS pos, DictionaryFileType fileType, long offset) throws JWNLException
FileManager
readLineAt
in interface FileManager
pos
- part of speechfileType
- file typeoffset
- file offsetJWNLException
- JWNLExceptionpublic PointedCharSequence getMatchingLine(POS pos, DictionaryFileType fileType, long offset, java.lang.String substring) throws JWNLException
FileManager
getMatchingLine
in interface FileManager
pos
- 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
FileManager
getIndexedLine
in interface FileManager
pos
- part of speechfileType
- file typeindex
- word to search forJWNLException
- JWNLExceptionpublic PointedCharSequence getRandomLine(POS pos, DictionaryFileType fileType) throws JWNLException
FileManager
getRandomLine
in interface FileManager
pos
- part of speechfileType
- file typeJWNLException
- JWNLExceptionpublic long getFirstLineOffset(POS pos, DictionaryFileType fileType) throws JWNLException
FileManager
getFirstLineOffset
in interface FileManager
pos
- part of speechfileType
- file typeJWNLException
- JWNLExceptionpublic 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 JWNLException
FileManager
save
in interface FileManager
JWNLException
- JWNLExceptionpublic int getUseCount(java.lang.String senseKey) throws JWNLException
FileManager
getUseCount
in interface FileManager
senseKey
- sense keyJWNLException
- JWNLException