public class PrincetonRandomAccessDictionaryFile extends AbstractPrincetonRandomAccessDictionaryFile implements DictionaryFileFactory<PrincetonRandomAccessDictionaryFile>, DictionaryDiskFile
RandomAccessDictionaryFile that accesses files
named with Princeton's dictionary file naming convention.| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
CHECK_DATA_FILE_LINE_LENGTH_LIMIT_KEY
Whether to warn about data file line length being off limits, default: true.
|
static java.lang.String |
CHECK_LEX_FILE_NUMBER_KEY
Whether to warn about lex file numbers correctness, default: true.
|
static java.lang.String |
CHECK_LEX_ID_LIMIT_KEY
Whether to warn about lex id being off limits, default: true.
|
static java.lang.String |
CHECK_POINTER_INDEX_LIMIT_KEY
Whether to warn about pointer target indices being off limits, default: true
|
static java.lang.String |
CHECK_RELATION_LIMIT_KEY
Whether to warn about relation count being off limits, default: true.
|
static java.lang.String |
CHECK_VERB_FRAME_LIMIT_KEY
Whether to warn about verb frame indices being off limits, default: true
|
static java.lang.String |
CHECK_WORD_COUNT_LIMIT_KEY
Whether to warn about word count being off limits, default: true.
|
protected java.io.File |
file |
protected java.io.RandomAccessFile |
raFile |
protected long |
raFileLength |
static java.lang.String |
WRITE_PRINCETON_HEADER_KEY
Whether to add standard princeton header to files on save, default: false.
|
encoding, ENCODING_KEYdictionary, fileType, params, path, pos| Constructor and Description |
|---|
PrincetonRandomAccessDictionaryFile(Dictionary dictionary,
java.util.Map<java.lang.String,Param> params)
Factory constructor.
|
PrincetonRandomAccessDictionaryFile(Dictionary dictionary,
java.lang.String path,
POS pos,
DictionaryFileType fileType,
java.util.Map<java.lang.String,Param> params)
Instance constructor.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Closes the file.
|
boolean |
delete()
Deletes the file.
|
void |
edit()
Reopens file in write mode.
|
static void |
formatOffset(long i,
int formatLength,
java.lang.StringBuilder target) |
java.io.File |
getFile()
Returns the file.
|
long |
getFirstLineOffset()
Returns offset of the first line.
|
long |
getNextLineOffset(long offset)
Returns start of the next line or -1 if no new line.
|
int |
getOffsetLength()
Returns offset length that accommodates largest offset.
|
protected PointedCharSequence |
getPointedCharSequence(long offset,
byte[] line,
int i) |
protected boolean |
isInvalidOffset(long offset) |
boolean |
isOpen()
Returns true if the file is open.
|
long |
length()
Returns the length, in bytes, of the file.
|
PrincetonRandomAccessDictionaryFile |
newInstance(Dictionary dictionary,
java.lang.String path,
POS pos,
DictionaryFileType fileType)
Creates a new instance of dictionary file.
|
void |
open()
Opens the file.
|
PointedCharSequence |
readLine(long offset)
Reads starting at offset and till the end of line.
|
PointedCharSequence |
readWord(long offset)
Reads starting at offset and till space.
|
void |
save()
Saves the file.
|
void |
setOffsetLength(int length)
Sets offset length to be used while rendering the file.
|
protected void |
writePrincetonHeader() |
getFilenamegetDictionary, getFileType, getPOS, setDictionaryclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetFilename, getFileType, getPOSgetDictionary, setDictionarypublic static final java.lang.String WRITE_PRINCETON_HEADER_KEY
public static final java.lang.String CHECK_LEX_FILE_NUMBER_KEY
public static final java.lang.String CHECK_RELATION_LIMIT_KEY
public static final java.lang.String CHECK_WORD_COUNT_LIMIT_KEY
public static final java.lang.String CHECK_LEX_ID_LIMIT_KEY
public static final java.lang.String CHECK_POINTER_INDEX_LIMIT_KEY
public static final java.lang.String CHECK_VERB_FRAME_LIMIT_KEY
public static final java.lang.String CHECK_DATA_FILE_LINE_LENGTH_LIMIT_KEY
protected final java.io.File file
protected java.io.RandomAccessFile raFile
protected long raFileLength
public PrincetonRandomAccessDictionaryFile(Dictionary dictionary, java.util.Map<java.lang.String,Param> params)
dictionary - dictionaryparams - paramspublic PrincetonRandomAccessDictionaryFile(Dictionary dictionary, java.lang.String path, POS pos, DictionaryFileType fileType, java.util.Map<java.lang.String,Param> params)
dictionary - dictionarypath - file pathpos - part of speechfileType - file typeparams - paramspublic static void formatOffset(long i,
int formatLength,
java.lang.StringBuilder target)
public PrincetonRandomAccessDictionaryFile newInstance(Dictionary dictionary, java.lang.String path, POS pos, DictionaryFileType fileType)
DictionaryFileFactorynewInstance in interface DictionaryFileFactory<PrincetonRandomAccessDictionaryFile>dictionary - owner dictionarypath - path to dictionary filespos - part of speechfileType - file typepublic PointedCharSequence readLine(long offset) throws JWNLException
RandomAccessDictionaryFilereadLine in interface RandomAccessDictionaryFileoffset - offsetJWNLException - JWNLExceptionpublic PointedCharSequence readWord(long offset) throws JWNLException
RandomAccessDictionaryFilereadWord in interface RandomAccessDictionaryFileoffset - offsetJWNLException - JWNLExceptionpublic long getFirstLineOffset()
throws JWNLException
RandomAccessDictionaryFilegetFirstLineOffset in interface RandomAccessDictionaryFileJWNLException - JWNLExceptionpublic long getNextLineOffset(long offset)
throws JWNLException
RandomAccessDictionaryFilegetNextLineOffset in interface RandomAccessDictionaryFileoffset - starting offsetJWNLException - JWNLExceptionpublic void open()
throws JWNLException
DictionaryFileopen in interface DictionaryFileJWNLException - JWNLExceptionpublic boolean isOpen()
DictionaryFileisOpen in interface DictionaryFilepublic void close()
throws JWNLException
DictionaryFileclose in interface DictionaryFileJWNLException - JWNLExceptionpublic void edit()
throws JWNLException
DictionaryFileedit in interface DictionaryFileJWNLException - JWNLExceptionpublic long length()
throws JWNLException
RandomAccessDictionaryFilelength in interface RandomAccessDictionaryFileJWNLException - JWNLExceptionpublic void save()
throws JWNLException
DictionaryFilesave in interface DictionaryFileJWNLException - JWNLExceptionpublic int getOffsetLength()
throws JWNLException
RandomAccessDictionaryFilegetOffsetLength in interface RandomAccessDictionaryFileJWNLException - JWNLExceptionpublic void setOffsetLength(int length)
throws JWNLException
RandomAccessDictionaryFilesetOffsetLength in interface RandomAccessDictionaryFilelength - offset length to be used while rendering the fileJWNLException - JWNLExceptionpublic java.io.File getFile()
DictionaryDiskFilegetFile in interface DictionaryDiskFilepublic boolean delete()
throws JWNLException
DictionaryDiskFiledelete in interface DictionaryDiskFileJWNLException - JWNLExceptionprotected PointedCharSequence getPointedCharSequence(long offset, byte[] line, int i) throws JWNLIOException
JWNLIOExceptionprotected boolean isInvalidOffset(long offset)
throws JWNLException
JWNLExceptionprotected void writePrincetonHeader()
throws java.io.IOException
java.io.IOException