net.sf.extjwnl.dictionary.file
Interface RandomAccessDictionaryFile

All Superinterfaces:
DictionaryFile, Owned
All Known Implementing Classes:
AbstractPrincetonRandomAccessDictionaryFile, PrincetonChannelDictionaryFile, PrincetonRandomAccessDictionaryFile

public interface RandomAccessDictionaryFile
extends DictionaryFile

DictionaryFile that reads lines from a random-access text file.

Author:
John Didion , Aliaksandr Autayeu

Method Summary
 long getFilePointer()
          Returns the current position of the file pointer.
 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.
 long length()
          Returns the length, in bytes, of the file.
 int read()
          Reads a byte from the file.
 String readLine()
          Reads a line from the file.
 String readLineWord()
          Reads the first word from a file (ie offset, index word).
 void seek(long pos)
          Goes to position pos in the file.
 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 interface net.sf.extjwnl.dictionary.file.DictionaryFile
close, delete, edit, getFile, getFileType, getPOS, isOpen, open, save
 
Methods inherited from interface net.sf.extjwnl.util.factory.Owned
getDictionary, setDictionary
 

Method Detail

read

int read()
         throws IOException
Reads a byte from the file.

Returns:
a byte from the file
Throws:
IOException - IOException

readLine

String readLine()
                throws IOException
Reads a line from the file.

Returns:
a line from the file
Throws:
IOException - IOException

writeLine

void writeLine(String line)
               throws IOException
Writes a line to the file.

Parameters:
line - a line to write
Throws:
IOException - IOException

readLineWord

String readLineWord()
                    throws IOException
Reads the first word from a file (ie offset, index word).

Returns:
the first word from a file (ie offset, index word)
Throws:
IOException - IOException

seek

void seek(long pos)
          throws IOException
Goes to position pos in the file.

Parameters:
pos - position pos in the file
Throws:
IOException - IOException

getFilePointer

long getFilePointer()
                    throws IOException
Returns the current position of the file pointer.

Returns:
the current position of the file pointer
Throws:
IOException - IOException

length

long length()
            throws IOException
Returns the length, in bytes, of the file.

Returns:
the length, in bytes, of the file
Throws:
IOException - IOException

setNextLineOffset

void setNextLineOffset(long previousOffset,
                       long nextOffset)
Moves the file pointer so that its next line offset is nextOffset.

Parameters:
previousOffset - previous offset
nextOffset - next offset

isPreviousLineOffset

boolean isPreviousLineOffset(long offset)
Returns true if offset is the previous offset.

Parameters:
offset - previous offset
Returns:
true if offset is the previous offset

getNextLineOffset

long getNextLineOffset()
Returns the byte offset of the next line (after the position of the file pointer).

Returns:
the byte offset of the next line

writeStrings

void writeStrings(Collection<String> strings)
                  throws IOException
Writes strings in file.

Parameters:
strings - strings to write
Throws:
IOException - IOException

getOffsetFormatString

String getOffsetFormatString()
Returns offset format string that accommodates largest offset.

Returns:
offset format string that accommodates largest offset


Copyright © 2011. All Rights Reserved.