net.sf.extjwnl.princeton.file
Class AbstractPrincetonRandomAccessDictionaryFile

java.lang.Object
  extended by net.sf.extjwnl.dictionary.file.AbstractDictionaryFile
      extended by net.sf.extjwnl.princeton.file.AbstractPrincetonDictionaryFile
          extended by net.sf.extjwnl.princeton.file.AbstractPrincetonRandomAccessDictionaryFile
All Implemented Interfaces:
DictionaryFile, RandomAccessDictionaryFile, Owned
Direct Known Subclasses:
PrincetonChannelDictionaryFile, PrincetonRandomAccessDictionaryFile

public abstract class AbstractPrincetonRandomAccessDictionaryFile
extends AbstractPrincetonDictionaryFile
implements RandomAccessDictionaryFile

Base class for random access files.

Author:
John Didion , Aliaksandr Autayeu

Field Summary
protected  String encoding
           
static String ENCODING
          Dictionary file encoding.
 
Fields inherited from class net.sf.extjwnl.dictionary.file.AbstractDictionaryFile
dictionary, file, params
 
Constructor Summary
protected AbstractPrincetonRandomAccessDictionaryFile(Dictionary dictionary, Map<String,Param> params)
           
protected AbstractPrincetonRandomAccessDictionaryFile(Dictionary dictionary, String path, POS pos, DictionaryFileType fileType, Map<String,Param> params)
           
 
Method Summary
 void edit()
          Reopens file in write mode.
 long getNextLineOffset()
          Returns the byte offset of the next line (after the position of the file pointer).
 String getOffsetFormatString()
          Returns offset format string that accommodates largest offset.
 boolean isPreviousLineOffset(long offset)
          Returns true if offset is the previous offset.
 void setNextLineOffset(long previousOffset, long nextOffset)
          Moves the file pointer so that its next line offset is nextOffset.
 void writeLine(String line)
          Writes a line to the file.
 void writeStrings(Collection<String> strings)
          Writes strings in file.
 
Methods inherited from class net.sf.extjwnl.princeton.file.AbstractPrincetonDictionaryFile
getFilename
 
Methods inherited from class net.sf.extjwnl.dictionary.file.AbstractDictionaryFile
close, delete, getDictionary, getFile, getFileType, getPOS, open, openFile, setDictionary
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface net.sf.extjwnl.dictionary.file.RandomAccessDictionaryFile
getFilePointer, length, read, readLine, readLineWord, seek
 
Methods inherited from interface net.sf.extjwnl.dictionary.file.DictionaryFile
close, delete, getFile, getFileType, getPOS, isOpen, open, save
 
Methods inherited from interface net.sf.extjwnl.util.factory.Owned
getDictionary, setDictionary
 

Field Detail

ENCODING

public static final String ENCODING
Dictionary file encoding. Use Java compatible encoding names. See Charset.

See Also:
Constant Field Values

encoding

protected String encoding
Constructor Detail

AbstractPrincetonRandomAccessDictionaryFile

protected AbstractPrincetonRandomAccessDictionaryFile(Dictionary dictionary,
                                                      Map<String,Param> params)

AbstractPrincetonRandomAccessDictionaryFile

protected AbstractPrincetonRandomAccessDictionaryFile(Dictionary dictionary,
                                                      String path,
                                                      POS pos,
                                                      DictionaryFileType fileType,
                                                      Map<String,Param> params)
Method Detail

setNextLineOffset

public void setNextLineOffset(long previousOffset,
                              long nextOffset)
Description copied from interface: RandomAccessDictionaryFile
Moves the file pointer so that its next line offset is nextOffset.

Specified by:
setNextLineOffset in interface RandomAccessDictionaryFile
Parameters:
previousOffset - previous offset
nextOffset - next offset

isPreviousLineOffset

public boolean isPreviousLineOffset(long offset)
Description copied from interface: RandomAccessDictionaryFile
Returns true if offset is the previous offset.

Specified by:
isPreviousLineOffset in interface RandomAccessDictionaryFile
Parameters:
offset - previous offset
Returns:
true if offset is the previous offset

getNextLineOffset

public long getNextLineOffset()
Description copied from interface: RandomAccessDictionaryFile
Returns the byte offset of the next line (after the position of the file pointer).

Specified by:
getNextLineOffset in interface RandomAccessDictionaryFile
Returns:
the byte offset of the next line

edit

public void edit()
          throws IOException
Description copied from interface: DictionaryFile
Reopens file in write mode.

Specified by:
edit in interface DictionaryFile
Throws:
IOException - IOException

writeStrings

public void writeStrings(Collection<String> strings)
                  throws IOException
Description copied from interface: RandomAccessDictionaryFile
Writes strings in file.

Specified by:
writeStrings in interface RandomAccessDictionaryFile
Parameters:
strings - strings to write
Throws:
IOException - IOException

getOffsetFormatString

public String getOffsetFormatString()
Description copied from interface: RandomAccessDictionaryFile
Returns offset format string that accommodates largest offset.

Specified by:
getOffsetFormatString in interface RandomAccessDictionaryFile
Returns:
offset format string that accommodates largest offset

writeLine

public void writeLine(String line)
               throws IOException
Description copied from interface: RandomAccessDictionaryFile
Writes a line to the file.

Specified by:
writeLine in interface RandomAccessDictionaryFile
Parameters:
line - a line to write
Throws:
IOException - IOException


Copyright © 2011. All Rights Reserved.