edu.mit.jwi.data
Class BinarySearchWordnetFile<T>
java.lang.Object
edu.mit.jwi.data.WordnetFile<T>
edu.mit.jwi.data.BinarySearchWordnetFile<T>
- Type Parameters:
T
- the type of object represented in this data resource
- All Implemented Interfaces:
- IClosable, IDataSource<T>, IHasLifecycle, ILoadable, ILoadableDataSource<T>, IHasVersion, java.lang.Iterable<java.lang.String>
public class BinarySearchWordnetFile<T>
- extends WordnetFile<T>
Concrete implementation of a wordnet file data source. This particular
implementation is for files on disk, and uses a binary search algorithm to
find requested lines. It is appropriate for alphabetically-ordered Wordnet
files.
- Since:
- JWI 2.0.0
- Version:
- 2.4.0
- Author:
- Mark A. Finlayson
Field Summary |
protected java.util.Comparator<java.lang.String> |
fComparator
|
Constructor Summary |
BinarySearchWordnetFile(java.io.File file,
IContentType<T> contentType)
Constructs a new binary search wordnet file, on the specified file with
the specified content type. |
Method Summary |
java.lang.String |
getLine(java.lang.String key)
Returns the line in the resource contains the data indexed by the
specified key. |
WordnetFile.LineIterator |
makeIterator(java.nio.ByteBuffer buffer,
java.lang.String key)
Constructs an iterator that can be used to iterate over the specified
ByteBuffer , starting from the specified key. |
Methods inherited from class edu.mit.jwi.data.WordnetFile |
close, equals, getBuffer, getContentType, getFile, getLine, getLine, getName, getVersion, hashCode, isLoaded, isOpen, iterator, iterator, load, load, open, rewindToLineStart |
Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait |
fComparator
protected final java.util.Comparator<java.lang.String> fComparator
BinarySearchWordnetFile
public BinarySearchWordnetFile(java.io.File file,
IContentType<T> contentType)
- Constructs a new binary search wordnet file, on the specified file with
the specified content type.
- Parameters:
file
- the file which backs this wordnet file; may not be
null
contentType
- the content type for this file; may not be null
- Throws:
{@link
- NullPointerException} if either the file or content type
is null
- Since:
- JWI 2.0.0
getLine
public java.lang.String getLine(java.lang.String key)
- Description copied from interface:
IDataSource
- Returns the line in the resource contains the data indexed by the
specified key. If the file cannot find the key in its data resource, it
returns
null
- Parameters:
key
- the key which indexes the desired data
- Returns:
- the line indexed by the specified key in the resource
makeIterator
public WordnetFile.LineIterator makeIterator(java.nio.ByteBuffer buffer,
java.lang.String key)
- Description copied from class:
WordnetFile
- Constructs an iterator that can be used to iterate over the specified
ByteBuffer
, starting from the specified key.
- Specified by:
makeIterator
in class WordnetFile<T>
- Parameters:
buffer
- the buffer over which the iterator will iterate, should not be
null
key
- the key at which the iterator should begin, should not be
null
- Returns:
- an iterator that can be used to iterate over the lines of the
ByteBuffer
Copyright © 2007-2013 Massachusetts Institute of Technology. All Rights Reserved.