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
ObjectDictionaryFilethat accesses files names with the Princeton dictionary file naming convention.
-
-
Field Summary
-
Fields inherited from interface net.didion.jwnl.dictionary.file.DictionaryFile
COMMENT_HEADER
-
-
Constructor Summary
Constructors Constructor Description PrincetonObjectDictionaryFile()PrincetonObjectDictionaryFile(String path, POS pos, DictionaryFileType fileType)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancanRead()booleancanWrite()voidclose()Close the fileObjectInputStreamgetInputStream()ObjectOutputStreamgetOutputStream()booleanisOpen()Return true if the file is openDictionaryFilenewInstance(String path, POS pos, DictionaryFileType fileType)Create a new instance of the dictionary fileprotected voidopenFile(File path)Here we try to be intelligent about opening streams.voidopenStreams()Open the input and output streams.ObjectreadObject()Read and deserialize an object from the filevoidwriteObject(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
-
-
-
-
Constructor Detail
-
PrincetonObjectDictionaryFile
public PrincetonObjectDictionaryFile()
-
PrincetonObjectDictionaryFile
public PrincetonObjectDictionaryFile(String path, POS pos, DictionaryFileType fileType)
-
-
Method Detail
-
newInstance
public DictionaryFile newInstance(String path, POS pos, DictionaryFileType fileType)
Description copied from interface:DictionaryFileCreate a new instance of the dictionary file- Specified by:
newInstancein interfaceDictionaryFile
-
isOpen
public boolean isOpen()
Description copied from interface:DictionaryFileReturn true if the file is open- Specified by:
isOpenin interfaceDictionaryFile
-
close
public void close()
Description copied from interface:DictionaryFileClose the file- Specified by:
closein interfaceDictionaryFile
-
openStreams
public void openStreams() throws IOExceptionOpen the input and output streams.- Throws:
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:ObjectDictionaryFileRead and deserialize an object from the file- Specified by:
readObjectin interfaceObjectDictionaryFile- Throws:
IOExceptionClassNotFoundException
-
writeObject
public void writeObject(Object obj) throws IOException
Description copied from interface:ObjectDictionaryFileSerialize and write an object ot the file.- Specified by:
writeObjectin interfaceObjectDictionaryFile- Throws:
IOException
-
openFile
protected void openFile(File path) 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 callingopenStreams.- Specified by:
openFilein classAbstractDictionaryFile- Throws:
IOException
-
-