Package net.didion.jwnl.princeton.file
Class PrincetonObjectDictionaryFile
java.lang.Object
net.didion.jwnl.dictionary.file.AbstractDictionaryFile
net.didion.jwnl.princeton.file.AbstractPrincetonDictionaryFile
net.didion.jwnl.princeton.file.PrincetonObjectDictionaryFile
- All Implemented Interfaces:
DictionaryFile
,ObjectDictionaryFile
public class PrincetonObjectDictionaryFile
extends AbstractPrincetonDictionaryFile
implements ObjectDictionaryFile
ObjectDictionaryFile
that accesses files names with the Princeton dictionary file naming convention.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate File
private ObjectInputStream
private ObjectOutputStream
Fields inherited from interface net.didion.jwnl.dictionary.file.DictionaryFile
COMMENT_HEADER
-
Constructor Summary
ConstructorsConstructorDescriptionPrincetonObjectDictionaryFile
(String path, POS pos, DictionaryFileType fileType) -
Method Summary
Modifier and TypeMethodDescriptionboolean
canRead()
boolean
canWrite()
void
close()
Close the fileboolean
isOpen()
Return true if the file is opennewInstance
(String path, POS pos, DictionaryFileType fileType) Create a new instance of the dictionary fileprotected void
Here we try to be intelligent about opening streams.private void
private void
void
Open the input and output streams.Read and deserialize an object from the filevoid
writeObject
(Object obj) Serialize and write an object ot the file.Methods inherited from class net.didion.jwnl.princeton.file.AbstractPrincetonDictionaryFile
makeFilename
Methods inherited from class net.didion.jwnl.dictionary.file.AbstractDictionaryFile
getFile, getFileType, getPOS, open
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface net.didion.jwnl.dictionary.file.DictionaryFile
getFile, getFileType, getPOS, open
-
Field Details
-
_file
-
_in
-
_out
-
-
Constructor Details
-
PrincetonObjectDictionaryFile
public PrincetonObjectDictionaryFile() -
PrincetonObjectDictionaryFile
-
-
Method Details
-
newInstance
Description copied from interface:DictionaryFile
Create a new instance of the dictionary file- Specified by:
newInstance
in interfaceDictionaryFile
-
isOpen
public boolean isOpen()Description copied from interface:DictionaryFile
Return true if the file is open- Specified by:
isOpen
in interfaceDictionaryFile
-
close
public void close()Description copied from interface:DictionaryFile
Close the file- Specified by:
close
in interfaceDictionaryFile
-
openStreams
Open the input and output streams.- Throws:
IOException
-
openOutputStream
- Throws:
IOException
-
openInputStream
- Throws:
IOException
-
getInputStream
- Throws:
IOException
-
getOutputStream
- Throws:
IOException
-
canRead
public boolean canRead() -
canWrite
public boolean canWrite() -
readObject
Description copied from interface:ObjectDictionaryFile
Read and deserialize an object from the file- Specified by:
readObject
in interfaceObjectDictionaryFile
- Throws:
IOException
ClassNotFoundException
-
writeObject
Description copied from interface:ObjectDictionaryFile
Serialize and write an object ot the file.- Specified by:
writeObject
in interfaceObjectDictionaryFile
- Throws:
IOException
-
openFile
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 callingopenStreams
.- Specified by:
openFile
in classAbstractDictionaryFile
- Throws:
IOException
-