net.sf.extjwnl.princeton.file
Class PrincetonChannelDictionaryFile

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
              extended by net.sf.extjwnl.princeton.file.PrincetonChannelDictionaryFile
All Implemented Interfaces:
DictionaryFile, DictionaryFileFactory<PrincetonChannelDictionaryFile>, RandomAccessDictionaryFile, Owned

public class PrincetonChannelDictionaryFile
extends AbstractPrincetonRandomAccessDictionaryFile
implements DictionaryFileFactory<PrincetonChannelDictionaryFile>

A RandomAccessDictionaryFile that accesses files named with Princeton's dictionary file naming convention. Uses java.nio.channels.FileChannel for file access.

Author:
John Didion , Aliaksandr Autayeu

Field Summary
 
Fields inherited from class net.sf.extjwnl.princeton.file.AbstractPrincetonRandomAccessDictionaryFile
encoding, ENCODING
 
Fields inherited from class net.sf.extjwnl.dictionary.file.AbstractDictionaryFile
dictionary, file, params
 
Constructor Summary
PrincetonChannelDictionaryFile(Dictionary dictionary, Map<String,Param> params)
           
PrincetonChannelDictionaryFile(Dictionary dictionary, String path, POS pos, DictionaryFileType fileType, Map<String,Param> params)
           
 
Method Summary
 void close()
          Closes the file.
 long getFilePointer()
          Returns the current position of the file pointer.
 boolean isOpen()
          Returns true if the file is open.
 long length()
          Returns the length, in bytes, of the file.
 PrincetonChannelDictionaryFile newInstance(Dictionary dictionary, String path, POS pos, DictionaryFileType fileType)
          Creates a new instance of the dictionary file.
protected  void openFile()
          Opens 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 save()
          Saves the file.
 void seek(long pos)
          Goes to position pos in the file.
 
Methods inherited from class net.sf.extjwnl.princeton.file.AbstractPrincetonRandomAccessDictionaryFile
edit, getNextLineOffset, getOffsetFormatString, isPreviousLineOffset, setNextLineOffset, writeLine, writeStrings
 
Methods inherited from class net.sf.extjwnl.princeton.file.AbstractPrincetonDictionaryFile
getFilename
 
Methods inherited from class net.sf.extjwnl.dictionary.file.AbstractDictionaryFile
delete, getDictionary, getFile, getFileType, getPOS, open, 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.DictionaryFile
delete, getFile, getFileType, getPOS, open
 
Methods inherited from interface net.sf.extjwnl.util.factory.Owned
getDictionary, setDictionary
 

Constructor Detail

PrincetonChannelDictionaryFile

public PrincetonChannelDictionaryFile(Dictionary dictionary,
                                      Map<String,Param> params)

PrincetonChannelDictionaryFile

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

newInstance

public PrincetonChannelDictionaryFile newInstance(Dictionary dictionary,
                                                  String path,
                                                  POS pos,
                                                  DictionaryFileType fileType)
Description copied from interface: DictionaryFileFactory
Creates a new instance of the dictionary file.

Specified by:
newInstance in interface DictionaryFileFactory<PrincetonChannelDictionaryFile>
Parameters:
dictionary - owner dictionary
path - path to dictionary files
pos - part of speech
fileType - file type
Returns:
a new instance of the dictionary file

readLine

public String readLine()
                throws IOException
Description copied from interface: RandomAccessDictionaryFile
Reads a line from the file.

Specified by:
readLine in interface RandomAccessDictionaryFile
Returns:
a line from the file
Throws:
IOException - IOException

readLineWord

public String readLineWord()
                    throws IOException
Description copied from interface: RandomAccessDictionaryFile
Reads the first word from a file (ie offset, index word).

Specified by:
readLineWord in interface RandomAccessDictionaryFile
Returns:
the first word from a file (ie offset, index word)
Throws:
IOException - IOException

seek

public void seek(long pos)
          throws IOException
Description copied from interface: RandomAccessDictionaryFile
Goes to position pos in the file.

Specified by:
seek in interface RandomAccessDictionaryFile
Parameters:
pos - position pos in the file
Throws:
IOException - IOException

getFilePointer

public long getFilePointer()
                    throws IOException
Description copied from interface: RandomAccessDictionaryFile
Returns the current position of the file pointer.

Specified by:
getFilePointer in interface RandomAccessDictionaryFile
Returns:
the current position of the file pointer
Throws:
IOException - IOException

isOpen

public boolean isOpen()
Description copied from interface: DictionaryFile
Returns true if the file is open.

Specified by:
isOpen in interface DictionaryFile
Returns:
true if the file is open

save

public void save()
Description copied from interface: DictionaryFile
Saves the file.

Specified by:
save in interface DictionaryFile

close

public void close()
Description copied from interface: DictionaryFile
Closes the file.

Specified by:
close in interface DictionaryFile
Overrides:
close in class AbstractDictionaryFile

openFile

protected void openFile()
                 throws IOException
Description copied from class: AbstractDictionaryFile
Opens the file.

Specified by:
openFile in class AbstractDictionaryFile
Throws:
IOException - IOException

length

public long length()
            throws IOException
Description copied from interface: RandomAccessDictionaryFile
Returns the length, in bytes, of the file.

Specified by:
length in interface RandomAccessDictionaryFile
Returns:
the length, in bytes, of the file
Throws:
IOException - IOException

read

public int read()
         throws IOException
Description copied from interface: RandomAccessDictionaryFile
Reads a byte from the file.

Specified by:
read in interface RandomAccessDictionaryFile
Returns:
a byte from the file
Throws:
IOException - IOException


Copyright © 2011. All Rights Reserved.