net.sf.extjwnl.princeton.file
Class PrincetonObjectDictionaryFile

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.PrincetonObjectDictionaryFile
All Implemented Interfaces:
DictionaryFile, DictionaryFileFactory<PrincetonObjectDictionaryFile>, ObjectDictionaryFile, Owned

public class PrincetonObjectDictionaryFile
extends AbstractPrincetonDictionaryFile
implements ObjectDictionaryFile, DictionaryFileFactory<PrincetonObjectDictionaryFile>

ObjectDictionaryFile that accesses files names with the Princeton dictionary file naming convention.

Author:
John Didion , Aliaksandr Autayeu

Field Summary
 
Fields inherited from class net.sf.extjwnl.dictionary.file.AbstractDictionaryFile
dictionary, file, params
 
Constructor Summary
PrincetonObjectDictionaryFile(Dictionary dictionary, Map<String,Param> params)
           
PrincetonObjectDictionaryFile(Dictionary dictionary, String path, POS pos, DictionaryFileType fileType, Map<String,Param> params)
           
 
Method Summary
 boolean canRead()
           
 boolean canWrite()
           
 void close()
          Closes the file.
 void edit()
          Reopens file in write mode.
 ObjectInputStream getInputStream()
           
 ObjectOutputStream getOutputStream()
           
 boolean isOpen()
          Returns true if the file is open.
 PrincetonObjectDictionaryFile newInstance(Dictionary dictionary, String path, POS pos, DictionaryFileType fileType)
          Creates a new instance of the dictionary file.
protected  void openFile()
          Here we try to be intelligent about opening streams.
 void openStreams()
          Open the input and output streams.
 Object readObject()
          Reads and deserializes an object from the file.
 void save()
          Saves the file.
 void writeObject(Object obj)
          Serializes and write an object ot the file.
 
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

PrincetonObjectDictionaryFile

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

PrincetonObjectDictionaryFile

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

newInstance

public PrincetonObjectDictionaryFile 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<PrincetonObjectDictionaryFile>
Parameters:
dictionary - owner dictionary
path - path to dictionary files
pos - part of speech
fileType - file type
Returns:
a new instance of the dictionary file

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()
          throws IOException
Description copied from interface: DictionaryFile
Saves the file.

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

close

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

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

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

openStreams

public void openStreams()
                 throws IOException
Open the input and output streams.

Throws:
IOException - IOException

getInputStream

public ObjectInputStream getInputStream()
                                 throws IOException
Throws:
IOException

getOutputStream

public ObjectOutputStream getOutputStream()
                                   throws IOException
Throws:
IOException

canRead

public boolean canRead()

canWrite

public boolean canWrite()

readObject

public Object readObject()
                  throws IOException,
                         ClassNotFoundException
Description copied from interface: ObjectDictionaryFile
Reads and deserializes an object from the file.

Specified by:
readObject in interface ObjectDictionaryFile
Returns:
deserialized an object
Throws:
IOException - IOException
ClassNotFoundException - ClassNotFoundException

writeObject

public void writeObject(Object obj)
                 throws IOException
Description copied from interface: ObjectDictionaryFile
Serializes and write an object ot the file.

Specified by:
writeObject in interface ObjectDictionaryFile
Parameters:
obj - object to write
Throws:
IOException - IOException

openFile

protected void openFile()
                 throws IOException
Here we try to be intelligent about opening streams. If the file does not already exist, we assume that we are going to be creating it and writing to it, otherwise we assume that we are going to be reading from it. If you want the other stream open, you must do it explicitly by calling openStreams.

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


Copyright © 2011. All Rights Reserved.